]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Set error flag for all division functions\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | /**\r | |
10 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
11 | generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
12 | \r | |
13 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
14 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
15 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
16 | This function returns the 64-bit unsigned quotient.\r | |
17 | \r | |
18 | @param Dividend A 64-bit unsigned value.\r | |
19 | @param Divisor A 32-bit unsigned value.\r | |
20 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
21 | optional and may be NULL.\r | |
22 | \r | |
23 | @return Dividend / Divisor\r | |
24 | \r | |
25 | **/\r | |
26 | UINT64\r | |
27 | EFIAPI\r | |
28 | InternalMathDivRemU64x32 (\r | |
29 | IN UINT64 Dividend,\r | |
30 | IN UINT32 Divisor,\r | |
31 | OUT UINT32 *Remainder\r | |
32 | )\r | |
33 | {\r | |
34 | _asm {\r | |
35 | mov ecx, Divisor\r | |
36 | mov eax, dword ptr [Dividend + 4]\r | |
37 | xor edx, edx\r | |
38 | div ecx\r | |
39 | push eax\r | |
40 | mov eax, dword ptr [Dividend + 0]\r | |
41 | div ecx\r | |
42 | mov ecx, Remainder\r | |
43 | jecxz RemainderNull // abandon remainder if Remainder == NULL\r | |
44 | mov [ecx], edx\r | |
45 | RemainderNull:\r | |
46 | pop edx\r | |
47 | }\r | |
48 | }\r |