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 .set noreorder
30 .set noat
31
32 .text
33
34 .globl __udiv_qrnnd
35 .ent __udiv_qrnnd
36__udiv_qrnnd:
37 .frame $30,0,$26,0
38 .prologue 0
39
40#define cnt $2
41#define tmp $3
42#define rem_ptr $16
43#define n1 $17
44#define n0 $18
45#define d $19
46#define qb $20
47#define AT $at
48
49 ldiq cnt,16
50 blt d,$largedivisor
51
52$loop1: cmplt n0,0,tmp
53 addq n1,n1,n1
54 bis n1,tmp,n1
55 addq n0,n0,n0
56 cmpule d,n1,qb
57 subq n1,d,tmp
58 cmovne qb,tmp,n1
59 bis n0,qb,n0
60 cmplt n0,0,tmp
61 addq n1,n1,n1
62 bis n1,tmp,n1
63 addq n0,n0,n0
64 cmpule d,n1,qb
65 subq n1,d,tmp
66 cmovne qb,tmp,n1
67 bis n0,qb,n0
68 cmplt n0,0,tmp
69 addq n1,n1,n1
70 bis n1,tmp,n1
71 addq n0,n0,n0
72 cmpule d,n1,qb
73 subq n1,d,tmp
74 cmovne qb,tmp,n1
75 bis n0,qb,n0
76 cmplt n0,0,tmp
77 addq n1,n1,n1
78 bis n1,tmp,n1
79 addq n0,n0,n0
80 cmpule d,n1,qb
81 subq n1,d,tmp
82 cmovne qb,tmp,n1
83 bis n0,qb,n0
84 subq cnt,1,cnt
85 bgt cnt,$loop1
86 stq n1,0(rem_ptr)
87 bis $31,n0,$0
88 ret $31,($26),1
89
90$largedivisor:
91 and n0,1,$4
92
93 srl n0,1,n0
94 sll n1,63,tmp
95 or tmp,n0,n0
96 srl n1,1,n1
97
98 and d,1,$6
99 srl d,1,$5
100 addq $5,$6,$5
101
102$loop2: cmplt n0,0,tmp
103 addq n1,n1,n1
104 bis n1,tmp,n1
105 addq n0,n0,n0
106 cmpule $5,n1,qb
107 subq n1,$5,tmp
108 cmovne qb,tmp,n1
109 bis n0,qb,n0
110 cmplt n0,0,tmp
111 addq n1,n1,n1
112 bis n1,tmp,n1
113 addq n0,n0,n0
114 cmpule $5,n1,qb
115 subq n1,$5,tmp
116 cmovne qb,tmp,n1
117 bis n0,qb,n0
118 cmplt n0,0,tmp
119 addq n1,n1,n1
120 bis n1,tmp,n1
121 addq n0,n0,n0
122 cmpule $5,n1,qb
123 subq n1,$5,tmp
124 cmovne qb,tmp,n1
125 bis n0,qb,n0
126 cmplt n0,0,tmp
127 addq n1,n1,n1
128 bis n1,tmp,n1
129 addq n0,n0,n0
130 cmpule $5,n1,qb
131 subq n1,$5,tmp
132 cmovne qb,tmp,n1
133 bis n0,qb,n0
134 subq cnt,1,cnt
135 bgt cnt,$loop2
136
137 addq n1,n1,n1
138 addq $4,n1,n1
139 bne $6,$Odd
140 stq n1,0(rem_ptr)
141 bis $31,n0,$0
142 ret $31,($26),1
143
144$Odd:
145
146 addq n1,n0,n1
147
148 cmpult n1,n0,tmp
149 subq n1,d,AT
150 addq n0,tmp,n0
151 cmovne tmp,AT,n1
152
153 cmpult n1,d,tmp
154 addq n0,1,AT
155 cmoveq tmp,AT,n0
156 subq n1,d,AT
157 cmoveq tmp,AT,n1
158
159 stq n1,0(rem_ptr)
160 bis $31,n0,$0
161 ret $31,($26),1
162
163 .end __udiv_qrnnd
164