Fix udiv100000 and udiv1000000000 ASM macros changing the source
register
This commit is contained in:
parent
55b1658e45
commit
1d41674dc1
@ -41,12 +41,13 @@
|
||||
* k = 17
|
||||
*
|
||||
* This division uses the output produces by clang for a division by 100000.
|
||||
* I don't understand why it works, but it does.
|
||||
* I don't understand why it works, but it does. It also needs one extra
|
||||
* temporary register to preserve the value of rx.
|
||||
*/
|
||||
.macro udiv100000 rd, rx, rt
|
||||
lsr \rx, $5
|
||||
.macro udiv100000 rd, rx, rt, rtt
|
||||
lsr \rtt, \rx, $5
|
||||
ldr \rt, =0xA7C5AC5
|
||||
umull \rt, \rd, \rx, \rt
|
||||
umull \rt, \rd, \rtt, \rt
|
||||
lsrs \rd, $7
|
||||
.endm
|
||||
|
||||
@ -71,10 +72,10 @@
|
||||
/*
|
||||
* Same situation as udiv100000
|
||||
*/
|
||||
.macro udiv1000000000 rd, rx, rt
|
||||
lsr \rx, $9
|
||||
.macro udiv1000000000 rd, rx, rt, rtt
|
||||
lsr \rtt, \rx, $9
|
||||
ldr \rt, =0x44B83
|
||||
umull \rt, \rd, \rx, \rt
|
||||
umull \rt, \rd, \rtt, \rt
|
||||
lsrs \rd, $7
|
||||
.endm
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
.syntax unified
|
||||
|
||||
.include "mtl/armv4t/asm/math.s"
|
||||
.include "mtl/asm/math.s"
|
||||
|
||||
.section .iwram, "ax", %progbits
|
||||
.arm
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
.syntax unified
|
||||
|
||||
.include "mtl/armv4t/asm/math.s"
|
||||
.include "mtl/asm/math.s"
|
||||
|
||||
.section .iwram, "ax", %progbits
|
||||
.arm
|
||||
@ -133,7 +133,7 @@ push {r4-r6}
|
||||
add r3, $1
|
||||
.Ldigits_10:
|
||||
// Divide by 10^9 to get the most significant digit
|
||||
udiv1000000000 r5, r0, r12
|
||||
udiv1000000000 r5, r0, r12, r6
|
||||
// Write the digit to the string
|
||||
add r6, r5, '0'
|
||||
strb r6, [r1], $1
|
||||
@ -164,7 +164,7 @@ push {r4-r6}
|
||||
mul r6, r5
|
||||
sub r0, r6
|
||||
.Ldigits_6:
|
||||
udiv100000 r5, r0, r12
|
||||
udiv100000 r5, r0, r12, r6
|
||||
add r6, r5, '0'
|
||||
strb r6, [r1], $1
|
||||
ldr r6, =100000
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user