-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiv.s
79 lines (55 loc) · 1.26 KB
/
div.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
; /*****************************************************************************
; *
; * Replacement for aeabi standard division functions
; * Using the NUC126 hardware divider
; *
; *****************************************************************************/
AREA |.text|, CODE, READONLY
HDIV EQU 0x50014000
; Signed division using the hardware divider.
; ~20 cycles
ALIGN
__aeabi_idivmod PROC
ROUT
EXPORT __aeabi_idivmod
LDR R2, = HDIV
STR R0, [ R2, #0 ]
STR R1, [ R2, #4 ]
LDR R0, [ R2, #8 ]
LDR R1, [ R2, #12 ]
BX LR
ENDP
ALIGN
__aeabi_idiv PROC
ROUT
EXPORT __aeabi_idiv
LDR R2, = HDIV
STR R0, [ R2, #0 ]
STR R1, [ R2, #4 ]
LDR R0, [ R2, #8 ]
BX LR
ENDP
; Unsigned divisions are just signed divisions,
; assuming that divisor and dividend never exceed 2^31-1.
; That's lazy but good enough.
__aeabi_uidivmod EQU __aeabi_idivmod
EXPORT __aeabi_uidivmod
__aeabi_uidiv EQU __aeabi_idiv
EXPORT __aeabi_uidiv
; Just in case
IF {FALSE}
ALIGN
__aeabi_uidivmod PROC
ROUT
EXPORT __aeabi_uidivmod
B __aeabi_idivmod
ENDP
ALIGN
__aeabi_uidiv PROC
ROUT
EXPORT __aeabi_uidiv
B __aeabi_idiv
ENDP
ENDIF
ALIGN
END