From bdaf097230053cca853fdab65b026ce1e3678161 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Wed, 2 Sep 2015 11:58:16 +0000 Subject: add runtime system for the ARM --- armdivmod.s | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 armdivmod.s (limited to 'armdivmod.s') diff --git a/armdivmod.s b/armdivmod.s new file mode 100644 index 0000000..cafc9ca --- /dev/null +++ b/armdivmod.s @@ -0,0 +1,169 @@ + + .arch armv7-a + .fpu vfpv3-d16 + .text + + .globl divide +divide: + eor r12,r3,r4 + cmp r4,#0 + neglt r4,r4 + cmp r3,#0 + neglt r3,r3 + + cmp r4,#32 + bls divide_by_small_number + + clz r1,r4 + clz r2,r3 + rsb r1,r1,#31-5-11 + add r1,r1,r2 + mov r2,#0 + + cmp r1,#32-5-11 + bhs divide_large_result + + add r1,r1,r1,lsl #1 + add pc,pc,r1,lsl #2 + nop + + .set shift,32-5-11 + .rept 32-5-11 + .set shift,shift-1 + subs r1,r3,r4,lsl #shift + movcs r3,r1 + orrcs r2,r2,#1<