1 /** @file
2   64-bit Math Worker Function.
3   The 32-bit versions of C compiler generate calls to library routines
4   to handle 64-bit math. These functions use non-standard calling conventions.
5 
6   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7   This program and the accompanying materials are licensed and made available
8   under the terms and conditions of the BSD License which accompanies this
9   distribution.  The full text of the license may be found at
10   http://opensource.org/licenses/bsd-license.php.
11 
12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15 **/
16 
17 #include <Library/BaseLib.h>
18 
19 /*
20  * Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value
21  * and returns a 64-bit result.
22  */
_allmul(void)23 __declspec(naked) void __cdecl _allmul (void)
24 {
25   //
26   // Wrapper Implementation over EDKII MultS64x64() routine
27   //    INT64
28   //    EFIAPI
29   //    MultS64x64 (
30   //      IN      INT64      Multiplicand,
31   //      IN      INT64      Multiplier
32   //      )
33   //
34   _asm {
35     ; Original local stack when calling _allmul
36     ;               -----------------
37     ;               |               |
38     ;               |---------------|
39     ;               |               |
40     ;               |--Multiplier --|
41     ;               |               |
42     ;               |---------------|
43     ;               |               |
44     ;               |--Multiplicand-|
45     ;               |               |
46     ;               |---------------|
47     ;               |  ReturnAddr** |
48     ;       ESP---->|---------------|
49     ;
50 
51     ;
52     ; Set up the local stack for Multiplicand parameter
53     ;
54     mov  eax, [esp + 16]
55     push eax
56     mov  eax, [esp + 16]
57     push eax
58 
59     ;
60     ; Set up the local stack for Multiplier parameter
61     ;
62     mov  eax, [esp + 16]
63     push eax
64     mov  eax, [esp + 16]
65     push eax
66 
67     ;
68     ; Call native MulS64x64 of BaseLib
69     ;
70     call MultS64x64
71 
72     ;
73     ; Adjust stack
74     ;
75     add  esp, 16
76 
77     ret  16
78   }
79 }
80