]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/CRT/Ia32/ullrem.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / CRT / Ia32 / ullrem.c
CommitLineData
2aa62f2b 1/** @file\r
2 64-bit Math Worker Function.\r
3 The 32-bit versions of C compiler generate calls to library routines\r
4 to handle 64-bit math. These functions use non-standard calling conventions.\r
5\r
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
7 This program and the accompanying materials are licensed and made available\r
8 under the terms and conditions of the BSD License which accompanies this\r
9 distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <Library/BaseLib.h>\r
18\r
19\r
20/*\r
21 * Divides a 64-bit unsigned value by another 64-bit unsigned value and returns\r
22 * the 64-bit unsigned remainder.\r
23 */\r
24__declspec(naked) void __cdecl _aullrem(void)\r
25{\r
26 //\r
27 // Wrapper Implementation over EDKII DivU64x64Remainder() routine\r
28 // UINT64\r
29 // EFIAPI\r
30 // DivU64x64Remainder (\r
31 // IN UINT64 Dividend,\r
32 // IN UINT64 Divisor,\r
33 // OUT UINT64 *Remainder OPTIONAL\r
34 // )\r
35 //\r
36 _asm {\r
37 ; Original local stack when calling _aullrem\r
38 ; -----------------\r
39 ; | |\r
40 ; |---------------|\r
41 ; | |\r
42 ; |-- Divisor --|\r
43 ; | |\r
44 ; |---------------|\r
45 ; | |\r
46 ; |-- Dividend --|\r
47 ; | |\r
48 ; |---------------|\r
49 ; | ReturnAddr** |\r
50 ; ESP---->|---------------|\r
51 ;\r
52\r
53 ;\r
54 ; Set up the local stack for Reminder pointer\r
55 ;\r
56 sub esp, 8\r
57 push esp\r
58\r
59 ;\r
60 ; Set up the local stack for Divisor parameter\r
61 ;\r
62 mov eax, [esp + 28]\r
63 push eax\r
64 mov eax, [esp + 28]\r
65 push eax\r
66\r
67 ;\r
68 ; Set up the local stack for Dividend parameter\r
69 ;\r
70 mov eax, [esp + 28]\r
71 push eax\r
72 mov eax, [esp + 28]\r
73 push eax\r
74\r
75 ;\r
76 ; Call native DivU64x64Remainder of BaseLib\r
77 ;\r
78 call DivU64x64Remainder\r
79\r
80 ;\r
81 ; Put the Reminder in EDX:EAX as return value\r
82 ;\r
83 mov eax, [esp + 20]\r
84 mov edx, [esp + 24]\r
85\r
86 ;\r
87 ; Adjust stack\r
88 ;\r
89 add esp, 28\r
90\r
91 ret 16\r
92 }\r
93}\r