]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.S
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / Ia32 / DivU64x64Remainder.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 # 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 # DivU64x64Remainder.asm
15 #
16 # Abstract:
17 #
18 # Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
19 # both the quotient and the remainder
20 #
21 #------------------------------------------------------------------------------
22
23 #include <EdkIIGlueBase.h>
24
25 .globl ASM_PFX(InternalMathDivRemU64x32), ASM_PFX(InternalMathDivRemU64x64)
26
27 #------------------------------------------------------------------------------
28 # UINT64
29 # EFIAPI
30 # InternalMathDivRemU64x64 (
31 # IN UINT64 Dividend,
32 # IN UINT64 Divisor,
33 # OUT UINT64 *Remainder OPTIONAL
34 # );
35 #------------------------------------------------------------------------------
36 ASM_PFX(InternalMathDivRemU64x64):
37 movl 16(%esp), %ecx
38 testl %ecx, %ecx
39 jnz Hard
40 movl 20(%esp), %ecx
41 jecxz L1
42 and $0, 4(%ecx)
43 movl %ecx, 16(%esp)
44 L1:
45 jmp ASM_PFX(InternalMathDivRemU64x32)
46 Hard:
47 push %ebx
48 push %esi
49 push %edi
50 mov 20(%esp), %edx
51 mov 16(%esp), %eax
52 movl %edx, %edi
53 movl %eax, %esi
54 mov 24(%esp), %ebx
55 L2:
56 shrl %edx
57 rcrl $1, %eax
58 shrdl $1, %ecx, %ebx
59 shrl %ecx
60 jnz L2
61 divl %ebx
62 movl %eax, %ebx
63 movl 28(%esp), %ecx
64 mull 24(%esp)
65 imull %ebx, %ecx
66 addl %ecx, %edx
67 mov 32(%esp), %ecx
68 jc TooLarge
69 cmpl %edx, %edi
70 ja Correct
71 jb TooLarge
72 cmpl %eax, %esi
73 jae Correct
74 TooLarge:
75 decl %ebx
76 jecxz Return
77 sub 24(%esp), %eax
78 sbb 28(%esp), %edx
79 Correct:
80 jecxz Return
81 subl %eax, %esi
82 sbbl %edx, %edi
83 movl %esi, (%ecx)
84 movl %edi, 4(%ecx)
85 Return:
86 movl %ebx, %eax
87 xorl %edx, %edx
88 pop %edi
89 pop %esi
90 pop %ebx
91 ret