]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/ia32/DivU64x64Remainder.asm
Remove .exe so that the name will work on Linux.
[mirror_edk2.git] / MdePkg / Library / BaseLib / ia32 / DivU64x64Remainder.asm
CommitLineData
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 .386\r
24 .model flat,C\r
25 .code\r
26\r
27EXTERN InternalMathDivRemU64x32:PROC\r
28\r
29InternalMathDivRemU64x64 PROC\r
30 mov ecx, [esp + 16]\r
31 test ecx, ecx\r
32 jnz _@DivRemU64x64\r
33 mov ecx, [esp + 20]\r
34 jecxz @F\r
35 and dword ptr [ecx + 4], 0\r
36 mov [esp + 16], ecx\r
37@@:\r
38 jmp InternalMathDivRemU64x32\r
39InternalMathDivRemU64x64 ENDP\r
40\r
41_@DivRemU64x64 PROC USES ebx esi edi\r
42 mov edx, dword ptr [esp + 20]\r
43 mov eax, dword ptr [esp + 16]\r
44 mov edi, edx\r
45 mov esi, eax\r
46 mov ebx, dword ptr [esp + 24]\r
47@@:\r
48 shr edx, 1\r
49 rcr eax, 1\r
50 shrd ebx, ecx, 1\r
51 shr ecx, 1\r
52 jnz @B\r
53 div ebx\r
54 mov ebx, eax\r
55 mov ecx, [esp + 28]\r
56 mul dword ptr [esp + 24]\r
57 imul ecx, ebx\r
58 add edx, ecx\r
59 mov ecx, dword ptr [esp + 32]\r
60 jc @TooLarge\r
61 cmp edi, edx\r
62 ja @Correct\r
63 jb @TooLarge\r
64 cmp esi, eax\r
65 jae @Correct\r
66@TooLarge:\r
67 dec ebx\r
68 jecxz @Return\r
69 sub eax, dword ptr [esp + 24]\r
70 sbb edx, dword ptr [esp + 28]\r
71@Correct:\r
72 jecxz @Return\r
73 sub esi, eax\r
74 sbb edi, edx\r
75 mov [ecx], esi\r
76 mov [ecx + 4], edi\r
77@Return:\r
78 mov eax, ebx\r
79 xor edx, edx\r
80 ret\r
81_@DivRemU64x64 ENDP\r
82\r
83 END\r