]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/CRT/Ia32/ulldiv.c
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / StdLib / LibC / CRT / Ia32 / ulldiv.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 with a 64-bit unsigned value and returns\r
22 * a 64-bit unsigned result.\r
23 */\r
24__declspec(naked) void __cdecl _aulldiv (void)\r
25{\r
26 //\r
27 // Wrapper Implementation over EDKII DivU64x64Reminder() 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\r
38 ; Original local stack when calling _aulldiv\r
39 ; -----------------\r
40 ; | |\r
41 ; |---------------|\r
42 ; | |\r
43 ; |-- Divisor --|\r
44 ; | |\r
45 ; |---------------|\r
46 ; | |\r
47 ; |-- Dividend --|\r
48 ; | |\r
49 ; |---------------|\r
50 ; | ReturnAddr** |\r
51 ; ESP---->|---------------|\r
52 ;\r
53\r
54 ;\r
55 ; Set up the local stack for NULL Reminder pointer\r
56 ;\r
57 xor eax, eax\r
58 push eax\r
59\r
60 ;\r
61 ; Set up the local stack for Divisor parameter\r
62 ;\r
63 mov eax, [esp + 20]\r
64 push eax\r
65 mov eax, [esp + 20]\r
66 push eax\r
67\r
68 ;\r
69 ; Set up the local stack for Dividend parameter\r
70 ;\r
71 mov eax, [esp + 20]\r
72 push eax\r
73 mov eax, [esp + 20]\r
74 push eax\r
75\r
76 ;\r
77 ; Call native DivU64x64Remainder of BaseLib\r
78 ;\r
79 call DivU64x64Remainder\r
80\r
81 ;\r
82 ; Adjust stack\r
83 ;\r
84 add esp, 20\r
85\r
86 ret 16\r
87 }\r
88}\r