]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.S
fd7f43d6ed6afc0902debe4201e5fff3718d19ad
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / MultU64x32.S
1 #/*++
2 #
3 #Copyright (c) 2006, Intel Corporation
4 #All rights reserved. This program and the accompanying materials
5 #are licensed and made available under the terms and conditions of the BSD License
6 #which accompanies this distribution. The full text of the license may be found at
7 #http://opensource.org/licenses/bsd-license.php
8 #
9 #THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 #WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 #
12 #Module Name:
13 #
14 # MultU64x32.c
15 #
16 #Abstract:
17 #
18 # 64-bit Multiplication function for IA-32
19 #
20 #--*/
21 #include "EfiBind.h"
22 #---------------------------------------------------------------------------
23 .686:
24 #.MODEL flat,C
25 .code:
26
27 #---------------------------------------------------------------------------
28 .globl ASM_PFX(MultU64x32)
29 #UINT64
30 #MultU64x32 (
31 # IN UINT64 Multiplicand,
32 # IN UINTN Multiplier
33 # )
34 #/*++
35 #
36 #Routine Description:
37 #
38 # This routine allows a 64 bit value to be multiplied with a 32 bit
39 # value returns 64bit result.
40 # No checking if the result is greater than 64bits
41 #
42 #Arguments:
43 #
44 # Multiplicand - multiplicand
45 # Multiplier - multiplier
46 #
47 #Returns:
48 #
49 # Multiplicand * Multiplier
50 #
51 #--*/
52 ASM_PFX(MultU64x32):
53
54 movl 4(%esp), %eax # dword ptr Multiplicand[0]
55 mull 0xC(%esp) # Multiplier
56 pushl %eax
57 pushl %edx
58 movl 0x10(%esp), %eax # dword ptr Multiplicand[4]
59 mull 0x14(%esp) # Multiplier
60 #
61 # The value in edx stored by second multiplication overflows
62 # the output and should be discarded. So here we overwrite it
63 # with the edx value of first multiplication.
64 #
65 popl %edx
66 addl %eax, %edx
67 popl %eax
68
69 ret
70 #MultU64x32 ENDP
71