]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | #------------------------------------------------------------------------------\r |
2 | #\r | |
3 | # Copyright (c) 2006, Intel Corporation\r | |
4 | # All rights reserved. This program and the accompanying materials\r | |
5 | # are licensed and made available under the terms and conditions of the BSD License\r | |
6 | # which accompanies this distribution. The full text of the license may be found at\r | |
7 | # http://opensource.org/licenses/bsd-license.php\r | |
8 | #\r | |
9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | #\r | |
12 | # Module Name:\r | |
13 | #\r | |
14 | # DivU64x64Remainder.asm\r | |
15 | #\r | |
16 | # Abstract:\r | |
17 | #\r | |
18 | # Calculate the quotient of a 64-bit integer by a 64-bit integer and returns\r | |
19 | # both the quotient and the remainder\r | |
20 | #\r | |
21 | #------------------------------------------------------------------------------\r | |
22 | \r | |
23 | \r | |
24 | \r | |
25 | \r | |
26 | \r | |
27 | .extern _InternalMathDivRemU64x32\r | |
28 | \r | |
29 | .global _InternalMathDivRemU64x64\r | |
30 | _InternalMathDivRemU64x64: \r | |
31 | movl 16(%esp),%ecx\r | |
32 | testl %ecx,%ecx\r | |
33 | jnz _DivRemU64x64\r | |
34 | movl 20(%esp),%ecx\r | |
35 | jecxz L1\r | |
36 | and $0,4(%ecx)\r | |
37 | movl %ecx,16(%esp)\r | |
38 | L1: \r | |
39 | jmp _InternalMathDivRemU64x32\r | |
40 | \r | |
41 | \r | |
42 | .global DivRemU64x64\r | |
43 | DivRemU64x64:\r | |
44 | # MISMATCH: "DivRemU64x64: USES ebx esi edi"\r | |
45 | push %ebx \r | |
46 | push %esi \r | |
47 | push %edi \r | |
48 | mov 20(%esp), %edx\r | |
49 | mov 16(%esp), %eax\r | |
50 | movl %edx,%edi\r | |
51 | movl %eax,%esi\r | |
52 | mov 24(%esp), %ebx\r | |
53 | L2: \r | |
54 | shrl %edx\r | |
55 | rcrl $1,%eax\r | |
56 | shrdl $1,%ecx,%ebx\r | |
57 | shrl %ecx\r | |
58 | jnz L2\r | |
59 | divl %ebx\r | |
60 | movl %eax,%ebx\r | |
61 | movl 28(%esp),%ecx\r | |
62 | mull 24(%esp)\r | |
63 | imull %ebx,%ecx\r | |
64 | addl %ecx,%edx\r | |
65 | mov 32(%esp), %ecx\r | |
66 | jc TooLarge\r | |
67 | cmpl %edx,%edi\r | |
68 | ja Correct\r | |
69 | jb TooLarge\r | |
70 | cmpl %eax,%esi\r | |
71 | jae Correct\r | |
72 | TooLarge: \r | |
73 | decl %ebx\r | |
74 | jecxz Return\r | |
75 | sub 24(%esp), %eax\r | |
76 | sbb 28(%esp), %edx\r | |
77 | Correct: \r | |
78 | jecxz Return\r | |
79 | subl %eax,%esi\r | |
80 | sbbl %edx,%edi\r | |
81 | movl %esi,(%ecx)\r | |
82 | movl %edi,4(%ecx)\r | |
83 | Return: \r | |
84 | movl %ebx,%eax\r | |
85 | xorl %edx,%edx\r | |
86 | push %edi \r | |
87 | push %esi \r | |
88 | push %ebx \r | |
89 | ret\r |