Task

Express a number in decimal as a fixed-length string with leading zeros.



For example, the number   7.125   could be expressed as   00007.125.




 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program formatNum64.s   */
/* use C library printf  ha, ha, ha !!! */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szFormat1:         .asciz " %09.3f\n"
.align 4
sfNumber:          .double  0f-7125E-3
sfNumber1:         .double  0f7125E-3
/*******************************************/
/* UnInitialized data                      */
/*******************************************/
.bss 
.align 4
/*******************************************/
/*  code section                           */
/*******************************************/
.text
.global main 
main:                                   // entry of program
 
    ldr x0,qAdrszFormat1                // format
    ldr x1,qAdrsfNumber                 // float number address
    ldr d0,[x1]                         // load float number in d0
    bl printf                           // call C function !!!
    ldr x0,qAdrszFormat1
    ldr x1,qAdrsfNumber1
    ldr d0,[x1]
    bl printf
 
100:                                    // standard end of the program
    mov x0,0                            // return code
    mov x8,EXIT                         // request to exit program
    svc 0                               // perform the system call
 
qAdrszFormat1:           .quad szFormat1
qAdrsfNumber:            .quad sfNumber
qAdrsfNumber1:           .quad sfNumber1
 
 