]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.S
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / DivU64x32.S
1 #---------------------------------------------------------------------------
2 #/*++
3 #
4 #Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
5 #This program and the accompanying materials
6 #are licensed and made available under the terms and conditions of the BSD License
7 #which accompanies this distribution. The full text of the license may be found at
8 #http://opensource.org/licenses/bsd-license.php
9 #
10 #THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 #WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #Module Name:
14 #
15 # DivU64x32.c
16 #
17 #Abstract:
18 #
19 # 64-bit division function for IA-32
20 #
21 #--*/
22
23 #---------------------------------------------------------------------------
24 #include "EfiBind.h" //For ASM_PFX
25 #---------------------------------------------------------------------------
26
27 #---------------------------------------------------------------------------
28 .386:
29 .code:
30
31 #---------------------------------------------------------------------------
32
33 .globl ASM_PFX(DivU64x32)
34
35 #UINT64
36 #DivU64x32 (
37 # IN UINT64 Dividend,
38 # IN UINTN Divisor,
39 # OUT UINTN *Remainder OPTIONAL
40 # )
41 #/*++
42
43 #Routine Description:
44
45 # This routine allows a 64 bit value to be divided with a 32 bit value returns
46 # 64bit result and the Remainder.
47 #
48 #Arguments:
49
50 # Dividend - dividend
51 # Divisor - divisor
52 # Remainder - buffer for remainder
53 #
54 #Returns:
55
56 # Dividend / Divisor
57 # Remainder = Dividend mod Divisor
58 #
59 #N.B. only works for 31bit divisors!!
60 #
61 #--*/
62 #---------------------------------------------------------------------------
63
64 ASM_PFX(DivU64x32):
65 pushl %ebp
66 movl %esp, %ebp
67 xorl %edx, %edx # Clear EDX
68
69 movl 0xC(%ebp), %eax # Put high 32 bits of 64-bit dividend in EAX
70 movl 0x10(%ebp), %ecx # Put 32 bits divisor in ECX
71 divl %ecx # Dividend Divisor Quoitent...Remainder
72 # 0:EAX / ECX = EAX EDX
73
74 pushl %eax # Push quoitent in stack
75
76 movl 8(%ebp), %eax # Put low 32 bits of 64-bit dividend in EAX
77 divl %ecx # Leave the REMAINDER in EDX as High 32-bit of new dividend
78 # Dividend Divisor Quoitent...Remainder
79 # EDX:EAX / ECX = EAX EDX
80
81 movl 0x14(%ebp), %ecx # Put &REMAINDER to ecx
82
83 jecxz Label1 # If ecx == 0, no remainder exist, return with quoitent in EDX directly
84 movl %edx, (%ecx) # Put EDX through REMAINDER pointer in ECX
85
86 Label1:
87 popl %edx # Pop High 32-bit QUOITENT to EDX
88 popl %ebp
89
90 ret
91