a3d0b549 |
1 | #------------------------------------------------------------------------------ |
2 | # |
3 | # Copyright (c) 2006, Intel Corporation |
4 | # All rights reserved. This program and the accompanying materials |
5 | # are licensed and made available under the terms and conditions of the BSD License |
6 | # which accompanies this distribution. The full text of the license may be found at |
7 | # http://opensource.org/licenses/bsd-license.php |
8 | # |
9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
11 | # |
12 | # Module Name: |
13 | # |
14 | # Ia32math.S |
15 | # |
16 | # Abstract: |
17 | # |
18 | # Generic math routines for EBC interpreter running on IA32 processor |
19 | # |
20 | #------------------------------------------------------------------------------ |
1cb5cfc1 |
21 | .globl _LeftShiftU64 |
a3d0b549 |
22 | _LeftShiftU64: |
23 | push %ebp |
24 | mov %esp,%ebp |
25 | push %ecx |
26 | cmpl $0x0,0x14(%ebp) |
27 | jne _LeftShiftU64+0x12 |
28 | mov 0x10(%ebp),%ecx |
29 | cmp $0x3f,%ecx |
30 | jbe _LeftShiftU64+0x18 |
31 | xor %eax,%eax |
32 | xor %edx,%edx |
33 | jmp _LeftShiftU64+0x2c |
34 | mov 0x8(%ebp),%eax |
35 | mov 0xc(%ebp),%edx |
36 | shld %cl,%eax,%edx |
37 | shl %cl,%eax |
38 | cmp $0x20,%ecx |
39 | jb _LeftShiftU64+0x2c |
40 | mov %eax,%edx |
41 | xor %eax,%eax |
42 | pop %ecx |
43 | leave |
44 | ret |
45 | |
1cb5cfc1 |
46 | .globl _RightShiftU64 |
a3d0b549 |
47 | _RightShiftU64: |
48 | push %ebp |
49 | mov %esp,%ebp |
50 | push %ecx |
51 | cmpl $0x0,0x14(%ebp) |
52 | jne _RightShiftU64+0x12 |
53 | mov 0x10(%ebp),%ecx |
54 | cmp $0x3f,%ecx |
55 | jbe _RightShiftU64+0x18 |
56 | xor %eax,%eax |
57 | xor %edx,%edx |
58 | jmp _RightShiftU64+0x2c |
59 | mov 0x8(%ebp),%eax |
60 | mov 0xc(%ebp),%edx |
61 | shrd %cl,%edx,%eax |
62 | shr %cl,%edx |
63 | cmp $0x20,%ecx |
64 | jb _RightShiftU64+0x2c |
65 | mov %edx,%eax |
66 | xor %edx,%edx |
67 | pop %ecx |
68 | leave |
69 | ret |
70 | |
1cb5cfc1 |
71 | .globl _ARightShift64 |
a3d0b549 |
72 | _ARightShift64: |
73 | push %ebp |
74 | mov %esp,%ebp |
75 | push %ecx |
76 | cmpl $0x0,0x14(%ebp) |
77 | jne _ARightShift64+0x12 |
78 | mov 0x10(%ebp),%ecx |
79 | cmp $0x3f,%ecx |
80 | jbe _ARightShift64+0x27 |
81 | btl $0x1f,0xc(%ebp) |
82 | jae _ARightShift64+0x21 |
83 | or $0xffffffff,%eax |
84 | or $0xffffffff,%edx |
85 | jmp _ARightShift64+0x3c |
86 | xor %eax,%eax |
87 | xor %edx,%edx |
88 | jmp _ARightShift64+0x3c |
89 | mov 0x8(%ebp),%eax |
90 | mov 0xc(%ebp),%edx |
91 | shrd %cl,%edx,%eax |
92 | sar %cl,%edx |
93 | cmp $0x20,%ecx |
94 | jb _ARightShift64+0x3c |
95 | mov %edx,%eax |
96 | sar $0x1f,%edx |
97 | pop %ecx |
98 | leave |
99 | ret |
100 | |
1cb5cfc1 |
101 | .globl _MulU64x64 |
a3d0b549 |
102 | _MulU64x64: |
103 | push %ebp |
104 | mov %esp,%ebp |
105 | push %ebx |
106 | push %ecx |
107 | mov 0x18(%ebp),%ebx |
108 | mov 0x8(%ebp),%eax |
109 | mull 0x10(%ebp) |
110 | push %eax |
111 | mov %edx,%ecx |
112 | mov 0xc(%ebp),%eax |
113 | mull 0x10(%ebp) |
114 | add %eax,%ecx |
115 | adc $0x0,%edx |
116 | mov %edx,(%ebx) |
117 | mov 0x8(%ebp),%eax |
118 | mull 0x14(%ebp) |
119 | add %eax,%ecx |
120 | push %ecx |
121 | adc $0x0,%edx |
122 | mov %edx,%ecx |
123 | mov 0xc(%ebp),%eax |
124 | mull 0x14(%ebp) |
125 | add %eax,%ecx |
126 | adc $0x0,%edx |
127 | add %ecx,(%ebx) |
128 | adc $0x0,%edx |
129 | mov %edx,0x4(%ebx) |
130 | pop %edx |
131 | pop %eax |
132 | pop %ecx |
133 | pop %ebx |
134 | leave |
135 | ret |
136 | |
1cb5cfc1 |
137 | .globl _MulS64x64 |
a3d0b549 |
138 | _MulS64x64: |
139 | push %ebp |
140 | mov %esp,%ebp |
141 | push %ebx |
142 | push %ecx |
143 | mov 0x18(%ebp),%ebx |
144 | xor %ecx,%ecx |
145 | mov 0xc(%ebp),%edx |
146 | bt $0x1f,%edx |
147 | jae _MulS64x64+0x2a |
148 | mov 0x8(%ebp),%eax |
149 | not %edx |
150 | not %eax |
151 | add $0x1,%eax |
152 | adc $0x0,%edx |
153 | mov %eax,0x8(%ebp) |
154 | mov %edx,0xc(%ebp) |
155 | btc $0x0,%ecx |
156 | mov 0x14(%ebp),%edx |
157 | bt $0x1f,%edx |
158 | jae _MulS64x64+0x4a |
159 | mov 0x10(%ebp),%eax |
160 | not %edx |
161 | not %eax |
162 | add $0x1,%eax |
163 | adc $0x0,%edx |
164 | mov %eax,0x10(%ebp) |
165 | mov %edx,0x14(%ebp) |
166 | btc $0x0,%ecx |
167 | pushl 0x18(%ebp) |
168 | pushl 0x14(%ebp) |
169 | pushl 0x10(%ebp) |
170 | pushl 0xc(%ebp) |
171 | pushl 0x8(%ebp) |
172 | call _MulU64x64 |
173 | add $0x14,%esp |
174 | bt $0x0,%ecx |
175 | jae _MulS64x64+0x7d |
176 | not %eax |
177 | not %edx |
178 | notl (%ebx) |
179 | notl 0x4(%ebx) |
180 | add $0x1,%eax |
181 | adc $0x0,%edx |
182 | adcl $0x0,(%ebx) |
183 | adcl $0x0,0x4(%ebx) |
184 | pop %ecx |
185 | pop %ebx |
186 | leave |
187 | ret |
188 | |
1cb5cfc1 |
189 | .globl _DivU64x64 |
a3d0b549 |
190 | _DivU64x64: |
191 | push %ebp |
192 | mov %esp,%ebp |
193 | push %ecx |
194 | mov 0x1c(%ebp),%eax |
195 | movl $0x0,(%eax) |
196 | cmpl $0x0,0x10(%ebp) |
197 | jne _DivU64x64+0x3e |
198 | cmpl $0x0,0x14(%ebp) |
199 | jne _DivU64x64+0x3e |
200 | movl $0x1,(%eax) |
201 | cmpl $0x0,0x18(%ebp) |
202 | je _DivU64x64+0x35 |
203 | mov 0x18(%ebp),%eax |
204 | movl $0x0,(%eax) |
205 | movl $0x80000000,0x4(%eax) |
206 | xor %eax,%eax |
207 | mov $0x80000000,%edx |
208 | jmp _DivU64x64+0x7e |
209 | xor %edx,%edx |
210 | xor %eax,%eax |
211 | mov $0x40,%ecx |
212 | shll 0x8(%ebp) |
213 | rcll 0xc(%ebp) |
214 | rcl %eax |
215 | rcl %edx |
216 | cmp 0x14(%ebp),%edx |
217 | ja _DivU64x64+0x5d |
218 | jb _DivU64x64+0x68 |
219 | cmp 0x10(%ebp),%eax |
220 | jb _DivU64x64+0x68 |
221 | btsl $0x0,0x8(%ebp) |
222 | sub 0x10(%ebp),%eax |
223 | sbb 0x14(%ebp),%edx |
224 | loop _DivU64x64+0x47 |
225 | cmpl $0x0,0x18(%ebp) |
226 | je _DivU64x64+0x78 |
227 | mov 0x18(%ebp),%ecx |
228 | mov %eax,(%ecx) |
229 | mov %edx,0x4(%ecx) |
230 | mov 0x8(%ebp),%eax |
231 | mov 0xc(%ebp),%edx |
232 | pop %ecx |
233 | leave |
234 | ret |
235 | |
1cb5cfc1 |
236 | .globl _DivS64x64 |
a3d0b549 |
237 | _DivS64x64: |
238 | push %ebp |
239 | mov %esp,%ebp |
240 | push %ecx |
241 | mov 0x1c(%ebp),%eax |
242 | movl $0x0,(%eax) |
243 | cmpl $0x0,0x10(%ebp) |
244 | jne _DivS64x64+0x41 |
245 | cmpl $0x0,0x14(%ebp) |
246 | jne _DivS64x64+0x41 |
247 | movl $0x1,(%eax) |
248 | cmpl $0x0,0x18(%ebp) |
249 | je _DivS64x64+0x35 |
250 | mov 0x18(%ebp),%eax |
251 | movl $0x0,(%eax) |
252 | movl $0x80000000,0x4(%eax) |
253 | xor %eax,%eax |
254 | mov $0x80000000,%edx |
255 | jmp _DivS64x64+0xc6 |
256 | xor %ecx,%ecx |
257 | mov 0xc(%ebp),%edx |
258 | bt $0x1f,%edx |
259 | jae _DivS64x64+0x67 |
260 | mov 0x8(%ebp),%eax |
261 | not %edx |
262 | not %eax |
263 | add $0x1,%eax |
264 | adc $0x0,%edx |
265 | mov %eax,0x8(%ebp) |
266 | mov %edx,0xc(%ebp) |
267 | btc $0x0,%ecx |
268 | btc $0x1,%ecx |
269 | mov 0x14(%ebp),%edx |
270 | bt $0x1f,%edx |
271 | jae _DivS64x64+0x87 |
272 | mov 0x10(%ebp),%eax |
273 | not %edx |
274 | not %eax |
275 | add $0x1,%eax |
276 | adc $0x0,%edx |
277 | mov %eax,0x10(%ebp) |
278 | mov %edx,0x14(%ebp) |
279 | btc $0x0,%ecx |
280 | pushl 0x1c(%ebp) |
281 | pushl 0x18(%ebp) |
282 | pushl 0x14(%ebp) |
283 | pushl 0x10(%ebp) |
284 | pushl 0xc(%ebp) |
285 | pushl 0x8(%ebp) |
286 | call _DivU64x64 |
287 | add $0x18,%esp |
288 | bt $0x0,%ecx |
289 | jae _DivS64x64+0xb1 |
290 | not %eax |
291 | not %edx |
292 | add $0x1,%eax |
293 | adc $0x0,%edx |
294 | bt $0x1,%ecx |
295 | jae _DivS64x64+0xc6 |
296 | mov 0x18(%ebp),%ecx |
297 | notl (%ecx) |
298 | notl 0x4(%ecx) |
299 | addl $0x1,(%ecx) |
300 | adcl $0x0,0x4(%ecx) |
301 | pop %ecx |
302 | leave |
303 | ret |