summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-11-07 21:44:11 +0000
committerCamil Staps2016-11-07 21:44:11 +0000
commit08f4cf835d2038591702e16c4df7c83348c842d3 (patch)
tree447728c50aff1f998e24c13e9693015b77e6f76a
parentFix some incorrect offsets in thumb2divmod.s (dynamically computed offsets st... (diff)
Fix divmodgc-flipped
-rw-r--r--thumb2divmod.s39
1 files changed, 22 insertions, 17 deletions
diff --git a/thumb2divmod.s b/thumb2divmod.s
index 2f19976..8aeabb4 100644
--- a/thumb2divmod.s
+++ b/thumb2divmod.s
@@ -29,19 +29,17 @@ divide:
bhs divide_large_result
add r1,r1,r1,lsl #1
- .align
- add r14,pc,#8
+ .align @ alignment is right now, try to not make this a nop
+ add r14,pc,#6
add r14,r14,r1,lsl #2
mov pc,r14
- nop
.set shift,32-5-11
.rept 32-5-11
.set shift,shift-1
subs r1,r3,r4,lsl #shift
- it cs
+ itt cs
movcs r3,r1
- it cs
orrcs r2,r2,#1<<shift
.endr
@@ -77,8 +75,8 @@ divide_result_0:
.thumb_func
divide_by_small_number:
.align
- add r1,pc,#10
- add r1,r1,r4,lsl #3
+ mov r1,r4,lsl #3
+ add r1,r1,pc
ldrb r4,[r1,#(div_mod_table+1)-(divide_by_small_number+8)]
ldr r2,[r1,#(div_mod_table+4)-(divide_by_small_number+8)]
ldrb r1,[r1,#div_mod_table-(divide_by_small_number+8)]
@@ -95,6 +93,7 @@ divide_by_small_number:
.globl modulo
.thumb_func
modulo:
+ eor r12,r3,r4
cmp r4,#0
it lt
neglt r4,r4
@@ -114,10 +113,9 @@ modulo:
bhs modulo_large_divide_result
.align
- add r14,pc,#8
+ add r14,pc,#6
add r14,r14,r1,lsl #3
mov pc,r14
- nop
.set shift,32
.rept 32
@@ -127,6 +125,13 @@ modulo:
movcs r3,r1
.endr
+ mov r4,r3
+ cmp r12,#0
+ it lt
+ neglt r4,r4
+ ldr lr,[sp],#4
+ mov pc,lr
+
.thumb_func
modulo_large_divide_result:
bpl modulo_divide_result_0
@@ -149,13 +154,14 @@ modulo_divide_result_0:
mov pc,lr
.thumb_func
-modulo_of_small_number:
+modulo_of_small_number_:
.align
- add r1,pc,#10
+modulo_of_small_number:
+ add r1,pc,#2
add r1,r1,r4,lsl #3
- ldrb r0,[r1,#(div_mod_table+1)-(modulo_of_small_number+8)]
- ldr r2,[r1,#(div_mod_table+4)-(modulo_of_small_number+8)]
- ldrb r1,[r1,#div_mod_table-(modulo_of_small_number+8)]
+ ldrb r0,[r1,#(div_mod_table+1)-(modulo_of_small_number_+8)]
+ ldr r2,[r1,#(div_mod_table+4)-(modulo_of_small_number_+8)]
+ ldrb r1,[r1,#div_mod_table-(modulo_of_small_number_+8)]
adds r14,r3,r0
it cc
umullcc r0,r2,r14,r2
@@ -166,12 +172,11 @@ modulo_from_quotient:
neg r3,r3
mla r4,r4,r2,r3
cmp r12,#0
- it lt
- neglt r4,r4
+ it ge
+ negge r4,r4
ldr lr,[sp],#4
mov pc,lr
- .thumb_func
div_mod_table:
.long 0,0
.long 0x100,0xffffffff