]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/CRT/Ia32/lldvrm.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / CRT / Ia32 / lldvrm.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 signed value by another 64-bit signed value and returns\r
22 * the 64-bit signed result and the 64-bit signed remainder.\r
23 */\r
24__declspec(naked) void __cdecl _alldvrm(void)\r
25{\r
26 //\r
27 // Wrapper Implementation over EDKII DivS64x64Remainder() routine\r
28 // INT64\r
29 // EFIAPI\r
30 // DivS64x64Remainder (\r
31 // IN INT64 Dividend,\r
32 // IN INT64 Divisor,\r
33 // OUT INT64 *Remainder\r
34 // )\r
35 //\r
36 _asm {\r
37 ; Original local stack when calling _alldvrm\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 ; On Exit:\r
54 ; EDX:EAX contains the quotient (dividend/divisor)\r
55 ; EBX:ECX contains the remainder (divided % divisor)\r
56 ; NOTE: this routine removes the parameters from the stack.\r
57 ;\r
58\r
59 ;\r
60 ; Set up the local stack for Reminder pointer\r
61 ;\r
62 sub esp, 8\r
63 push esp\r
64\r
65 ;\r
66 ; Set up the local stack for Divisor parameter\r
67 ;\r
68 mov eax, [esp + 28]\r
69 push eax\r
70 mov eax, [esp + 28]\r
71 push eax\r
72\r
73 ;\r
74 ; Set up the local stack for Dividend parameter\r
75 ;\r
76 mov eax, [esp + 28]\r
77 push eax\r
78 mov eax, [esp + 28]\r
79 push eax\r
80\r
81 ;\r
82 ; Call native DivS64x64Remainder of BaseLib\r
83 ;\r
84 call DivS64x64Remainder\r
85\r
86 ;\r
87 ; EDX:EAX contains the quotient (dividend/divisor)\r
88 ; Put the Remainder in EBX:ECX\r
89 ;\r
90 mov ecx, [esp + 20]\r
91 mov ebx, [esp + 24]\r
92\r
93 ;\r
94 ; Adjust stack\r
95 ;\r
96 add esp, 28\r
97\r
98 ret 16\r
99 }\r
100}\r