Ethiopian multiplication: Difference between revisions

Content added Content deleted
(correct aarch64 assembly to overflow)
Line 215: Line 215:
stp x1,lr,[sp,-16]! // save registers
stp x1,lr,[sp,-16]! // save registers
stp x2,x3,[sp,-16]! // save registers
stp x2,x3,[sp,-16]! // save registers
stp x4,x5,[sp,-16]! // save registers
mov x2,#0 // init result
mov x2,#0 // init result
1: // loop
1: // loop
Line 221: Line 220:
blt 3f
blt 3f
ands x3,x0,#1 //
ands x3,x0,#1 //
add x4,x2,x1 // add factox2 to result
add x3,x2,x1 // add factor2 to result
csel x2,x2,x4,eq
csel x2,x2,x3,eq
mov x3,1
lsr x0,x0,x3 // divide factor1 by 2
cmp x1,0 // overflow ? if bit 63 = 1 ie negative number
blt 2f
mov x4,1
mov x4,1
lsr x0,x0,x4 // divide factox1 by 2
lsl x1,x1,x4 // multiply factor2 by 2
mov x4,1<63
and x5,x1,x4
cmp x5,x4 // overflow ?
beq 2f
mov x4,1
lsl x1,x1,x4 // multiply factox2 by 2
b 1b // or loop
b 1b // or loop
2: // error display
2: // error display