]>
Commit | Line | Data |
---|---|---|
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 with a 64-bit signed value and returns\r | |
22 | * a 64-bit signed result.\r | |
23 | */\r | |
24 | __declspec(naked) void __cdecl _alldiv (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 UINT64 Dividend,\r | |
32 | // IN UINT64 Divisor,\r | |
33 | // OUT UINT64 *Remainder OPTIONAL\r | |
34 | // )\r | |
35 | //\r | |
36 | _asm {\r | |
37 | \r | |
38 | ;Entry:\r | |
39 | ; Arguments are passed on the stack:\r | |
40 | ; 1st pushed: divisor (QWORD)\r | |
41 | ; 2nd pushed: dividend (QWORD)\r | |
42 | ;\r | |
43 | ;Exit:\r | |
44 | ; EDX:EAX contains the quotient (dividend/divisor)\r | |
45 | ; NOTE: this routine removes the parameters from the stack.\r | |
46 | ;\r | |
47 | ; Original local stack when calling _alldiv\r | |
48 | ; -----------------\r | |
49 | ; | |\r | |
50 | ; |---------------|\r | |
51 | ; | |\r | |
52 | ; |-- Divisor --|\r | |
53 | ; | |\r | |
54 | ; |---------------|\r | |
55 | ; | |\r | |
56 | ; |-- Dividend --|\r | |
57 | ; | |\r | |
58 | ; |---------------|\r | |
59 | ; | ReturnAddr** |\r | |
60 | ; ESP---->|---------------|\r | |
61 | ;\r | |
62 | \r | |
63 | ;\r | |
64 | ; Set up the local stack for NULL Reminder pointer\r | |
65 | ;\r | |
66 | xor eax, eax\r | |
67 | push eax\r | |
68 | \r | |
69 | ;\r | |
70 | ; Set up the local stack for Divisor parameter\r | |
71 | ;\r | |
72 | mov eax, [esp + 20]\r | |
73 | push eax\r | |
74 | mov eax, [esp + 20]\r | |
75 | push eax\r | |
76 | \r | |
77 | ;\r | |
78 | ; Set up the local stack for Dividend parameter\r | |
79 | ;\r | |
80 | mov eax, [esp + 20]\r | |
81 | push eax\r | |
82 | mov eax, [esp + 20]\r | |
83 | push eax\r | |
84 | \r | |
85 | ;\r | |
86 | ; Call native DivS64x64Remainder of BaseLib\r | |
87 | ;\r | |
88 | call DivS64x64Remainder\r | |
89 | \r | |
90 | ;\r | |
91 | ; Adjust stack\r | |
92 | ;\r | |
93 | add esp, 20\r | |
94 | \r | |
95 | ret 16\r | |
96 | }\r | |
97 | }\r |