How to resolve the algorithm Sleep step by step in the AArch64 Assembly programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sleep step by step in the AArch64 Assembly programming language

Table of Contents

Problem Statement

Write a program that does the following in this order:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sleep step by step in the AArch64 Assembly programming language

Source code in the aarch64 programming language

/* 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"

  

You may also check:How to resolve the algorithm Summarize and say sequence step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the Logo programming language
You may also check:How to resolve the algorithm Dynamic variable names step by step in the Scheme programming language
You may also check:How to resolve the algorithm Array length step by step in the AutoIt programming language
You may also check:How to resolve the algorithm Determine if two triangles overlap step by step in the D programming language