Fix udiv100000 and udiv1000000000 ASM macros changing the source
register
This commit is contained in:
parent
813a499734
commit
554c88f7f2
@ -41,12 +41,13 @@
|
|||||||
* k = 17
|
* k = 17
|
||||||
*
|
*
|
||||||
* This division uses the output produces by clang for a division by 100000.
|
* 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
|
.macro udiv100000 rd, rx, rt, rtt
|
||||||
lsr \rx, $5
|
lsr \rtt, \rx, $5
|
||||||
ldr \rt, =0xA7C5AC5
|
ldr \rt, =0xA7C5AC5
|
||||||
umull \rt, \rd, \rx, \rt
|
umull \rt, \rd, \rtt, \rt
|
||||||
lsrs \rd, $7
|
lsrs \rd, $7
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ -71,10 +72,10 @@
|
|||||||
/*
|
/*
|
||||||
* Same situation as udiv100000
|
* Same situation as udiv100000
|
||||||
*/
|
*/
|
||||||
.macro udiv1000000000 rd, rx, rt
|
.macro udiv1000000000 rd, rx, rt, rtt
|
||||||
lsr \rx, $9
|
lsr \rtt, \rx, $9
|
||||||
ldr \rt, =0x44B83
|
ldr \rt, =0x44B83
|
||||||
umull \rt, \rd, \rx, \rt
|
umull \rt, \rd, \rtt, \rt
|
||||||
lsrs \rd, $7
|
lsrs \rd, $7
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
.syntax unified
|
.syntax unified
|
||||||
|
|
||||||
.include "mtl/armv4t/asm/math.s"
|
.include "mtl/asm/math.s"
|
||||||
|
|
||||||
.section .iwram, "ax", %progbits
|
.section .iwram, "ax", %progbits
|
||||||
.arm
|
.arm
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
.syntax unified
|
.syntax unified
|
||||||
|
|
||||||
.include "mtl/armv4t/asm/math.s"
|
.include "mtl/asm/math.s"
|
||||||
|
|
||||||
.section .iwram, "ax", %progbits
|
.section .iwram, "ax", %progbits
|
||||||
.arm
|
.arm
|
||||||
@ -133,7 +133,7 @@ push {r4-r6}
|
|||||||
add r3, $1
|
add r3, $1
|
||||||
.Ldigits_10:
|
.Ldigits_10:
|
||||||
// Divide by 10^9 to get the most significant digit
|
// 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
|
// Write the digit to the string
|
||||||
add r6, r5, '0'
|
add r6, r5, '0'
|
||||||
strb r6, [r1], $1
|
strb r6, [r1], $1
|
||||||
@ -164,7 +164,7 @@ push {r4-r6}
|
|||||||
mul r6, r5
|
mul r6, r5
|
||||||
sub r0, r6
|
sub r0, r6
|
||||||
.Ldigits_6:
|
.Ldigits_6:
|
||||||
udiv100000 r5, r0, r12
|
udiv100000 r5, r0, r12, r6
|
||||||
add r6, r5, '0'
|
add r6, r5, '0'
|
||||||
strb r6, [r1], $1
|
strb r6, [r1], $1
|
||||||
ldr r6, =100000
|
ldr r6, =100000
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user