forked from TCShenanigans/symphony_stdlib
Changed mul_low algorithm to radix-4 multiplication
This commit is contained in:
+22
-13
@@ -6,20 +6,29 @@
|
|||||||
; r1 - The lower 32 bits of the result
|
; r1 - The lower 32 bits of the result
|
||||||
; Clobbers: r2, r3, r4, r5
|
; Clobbers: r2, r3, r4, r5
|
||||||
pub mul_low:
|
pub mul_low:
|
||||||
mov r3, 0 ; result
|
add r3, r2, r2 ; r3 = r2 * 2
|
||||||
mov r4, 31 ; loop counter
|
mov r4, 0 ; r4 has the result
|
||||||
|
|
||||||
mul_low_loop:
|
mul_low_loop:
|
||||||
asr r5, r2, 31
|
|
||||||
and r5, r5, r1
|
and r5, r1, 1 ; a0
|
||||||
lsl r5, r5, r4
|
neg r5, r5 ; mask
|
||||||
add r3, r3, r5
|
and r5, r2, r5 ; a0 ? r2 : 0
|
||||||
lsl r2, r2, 1
|
add r4, r4, r5
|
||||||
sub r4, r4, 1
|
|
||||||
cmp r4, 0
|
and r5, r1, 2 ; a1 is now 0 or 2
|
||||||
jge mul_low_loop
|
lsr r5, r5, 1 ; normalize to 0/1
|
||||||
mov r1, r3
|
neg r5, r5 ; mask
|
||||||
|
and r5, r3, r5 ; a1 ? r2 * 2 : 0
|
||||||
|
add r4, r4, r5
|
||||||
|
|
||||||
|
lsl r2, r2, 2
|
||||||
|
lsl r3, r3, 2
|
||||||
|
lsr r1, r1, 2
|
||||||
|
cmp r1, zr
|
||||||
|
jne mul_low_loop
|
||||||
|
|
||||||
|
mov r1, r4
|
||||||
jmp r13
|
jmp r13
|
||||||
|
|
||||||
; Calculates the absolute value of the value provided in the r1 register
|
; Calculates the absolute value of the value provided in the r1 register
|
||||||
|
|||||||
Reference in New Issue
Block a user