Include a file: Difference between revisions

m
Line 57:
ldp x2,x8,[sp],16 // restaur 2 registres
ldp x0,x1,[sp],16 // restaur 2 registres
ret // retour adresse lr x30
/******************************************************************/
/* Decimal conversion unsigned */
/******************************************************************/
/* x0 contains the value */
/* x1 contains the address of receiving area length >= 21 */
/* the receiving area return a string ascii left aligned */
/* and with final zero */
/* x0 return length string whitout zero final */
.equ LGZONECONV, 20
conversion10:
stp x5,lr,[sp,-16]! // save registers
stp x3,x4,[sp,-16]! // save registers
stp x1,x2,[sp,-16]! // save registers
mov x4,#LGZONECONV // position last digit
mov x5,#10 // decimal conversion
1: // loop begin
mov x2,x0 // copy starting number or successive quotients
udiv x0,x2,x5 // division by ten
msub x3,x0,x5,x2 //compute remainder
add x3,x3,#48 // digit
sub x4,x4,#1 // previous position
strb w3,[x1,x4] // store digit ascii
cbnz x0,1b // end if quotient = zero
mov x2,LGZONECONV // compute string length (20 - dernière position)
sub x0,x2,x4 // no instruction rsb in 64 bits !!!
// move result to area begin
cbz x4,3f // full area ?
mov x2,0 // start position
2:
ldrb w3,[x1,x4] // load digit
strb w3,[x1,x2] // store digit
add x4,x4,#1 // next position origin
add x2,x2,#1 // and next position destination
cmp x4,LGZONECONV - 1 // end ?
ble 2b // else loop
3:
mov w3,0
strb w3,[x1,x2] // zero final
100:
ldp x1,x2,[sp],16 // restaur des 2 registres
ldp x3,x4,[sp],16 // restaur des 2 registres
ldp x5,lr,[sp],16 // restaur des 2 registres
ret // retour adresse lr x30
/******************************************************************/
Line 66 ⟶ 109:
/* et avec un zero final */
/* x0 return length string whitout zero final */
.equ LGZONECONVLGZONECONVS, 21
conversion10S:
stp x5,lr,[sp,-16]! // save registers
Line 80 ⟶ 123:
12:
strb w3,[x1]
mov x4,#LGZONECONVLGZONECONVS // position last digit
mov x5,#10 // decimal conversion
1: // loop conversion start
Line 91 ⟶ 134:
cbnz x0,1b // end if quotient = zero
 
mov x2,LGZONECONVLGZONECONVS // compute string length (21 - dernière position)
sub x0,x2,x4 // no instruction rsb in 64 bits !!!
// move result to area begin
Line 102 ⟶ 145:
add x4,x4,#1 // last position
add x2,x2,#1 // et begin last postion
cmp x4,LGZONECONVLGZONECONVS - 1 // end ?
ble 2b // no -> loop
3: