Task

Write a program that does the following in this order:

 Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description.
 Print "Sleeping..."
 Sleep the main thread for the given amount of time.
 Print "Awake!"
 End.


Related task

   Nautical bell


 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program sleep64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeConstantesARM64.inc"
 
.equ SLEEP,  0x65                        // Linux syscall
 
 
.equ BUFFERSIZE,         100
/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessQuest:             .asciz "Enter the time to sleep in seconds : "
szMessError:             .asciz "Error occured.\n" 
szMessSleep:             .asciz "Sleeping Zzzzzzz.\n" 
szMessAwake:             .asciz "Awake!!!\n"
 
szCarriageReturn:        .asciz "\n"
/*******************************************/
/* UnInitialized data                      */
/*******************************************/
.bss 
.align 4
ZonesAttente:
  qSecondes:      .skip 8
  qMicroSecondes: .skip 8
ZonesTemps:       .skip 16
sBuffer:          .skip BUFFERSIZE
/*******************************************/
/*  code section                           */
/*******************************************/
.text
.global main 
main: 
    ldr x0,qAdrszMessQuest            // display invite message
    bl affichageMess
    mov x0,STDIN                      // input standard linux
    ldr x1,qAdrsBuffer
    mov x2,BUFFERSIZE
    mov x8,READ                       // read input string
    svc 0 
    cmp x0,0                          // read error ?
    ble 99f
    // 
    ldr x0,qAdrsBuffer                // buffer address
    bl conversionAtoD                 // conversion string in number in x0
 
    ldr x1,qAdrqSecondes 
    str x0,[x1]                       // store second number in area
    ldr x0,qAdrszMessSleep            // display sleeping message
    bl affichageMess
    ldr x0,qAdrZonesAttente           // delay area
    ldr x1,qAdrZonesTemps             //
    mov x8,#SLEEP                     // call system SLEEP
    svc 0 
    cmp x0,#0                         // error sleep ?
    blt 99f
    ldr x0,qAdrszMessAwake            // display awake message
    bl affichageMess
    mov x0, #0                        // return code
    b 100f
99:                                   // display error message
    ldr x0,qAdrszMessError
    bl affichageMess
    mov x0, 1                         // return code
 
100:                                  // standard end of the program
    mov x8,EXIT                       // request to exit program
    svc 0                             // perform system call
qAdrszMessQuest:          .quad szMessQuest
qAdrszMessError:          .quad szMessError
qAdrszMessSleep:          .quad szMessSleep
qAdrszMessAwake:          .quad szMessAwake
qAdrqSecondes:            .quad qSecondes
qAdrZonesAttente:         .quad ZonesAttente
qAdrZonesTemps:           .quad ZonesTemps
qAdrsBuffer:              .quad sBuffer
qAdrszCarriageReturn:     .quad szCarriageReturn
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 