]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/DivU64x32.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / DivU64x32.c
1 /** @file
2 Calculate the quotient of a 64-bit integer by a 32-bit integer
3
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10
11
12 /**
13 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
14 generates a 64-bit unsigned result.
15
16 This function divides the 64-bit unsigned value Dividend by the 32-bit
17 unsigned value Divisor and generates a 64-bit unsigned quotient. This
18 function returns the 64-bit unsigned quotient.
19
20 @param Dividend A 64-bit unsigned value.
21 @param Divisor A 32-bit unsigned value.
22
23 @return Dividend / Divisor
24
25 **/
26 UINT64
27 EFIAPI
28 InternalMathDivU64x32 (
29 IN UINT64 Dividend,
30 IN UINT32 Divisor
31 )
32 {
33 _asm {
34 mov eax, dword ptr [Dividend + 4]
35 mov ecx, Divisor
36 xor edx, edx
37 div ecx
38 push eax ; save quotient on stack
39 mov eax, dword ptr [Dividend]
40 div ecx
41 pop edx ; restore high-order dword of the quotient
42 }
43 }
44