]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / DivU64x32Remainder.nasm
CommitLineData
fb79aa01
JJ
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
9344f092 4; SPDX-License-Identifier: BSD-2-Clause-Patent\r
fb79aa01
JJ
5;\r
6; Module Name:\r
7;\r
8; DivError.asm\r
9;\r
10; Abstract:\r
11;\r
12; Set error flag for all division functions\r
13;\r
14;------------------------------------------------------------------------------\r
15\r
16 SECTION .text\r
17\r
18;------------------------------------------------------------------------------\r
19; UINT64\r
20; EFIAPI\r
21; InternalMathDivRemU64x32 (\r
22; IN UINT64 Dividend,\r
23; IN UINT32 Divisor,\r
24; OUT UINT32 *Remainder\r
25; );\r
26;------------------------------------------------------------------------------\r
27global ASM_PFX(InternalMathDivRemU64x32)\r
28ASM_PFX(InternalMathDivRemU64x32):\r
29 mov ecx, [esp + 12] ; ecx <- divisor\r
30 mov eax, [esp + 8] ; eax <- dividend[32..63]\r
31 xor edx, edx\r
32 div ecx ; eax <- quotient[32..63], edx <- remainder\r
33 push eax\r
34 mov eax, [esp + 8] ; eax <- dividend[0..31]\r
35 div ecx ; eax <- quotient[0..31]\r
36 mov ecx, [esp + 20] ; ecx <- Remainder\r
37 jecxz .0 ; abandon remainder if Remainder == NULL\r
38 mov [ecx], edx\r
39.0:\r
40 pop edx ; edx <- quotient[32..63]\r
41 ret\r
42\r