]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | MultU64x32.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | 64-bit Multiplication function for IA-32\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | \r | |
24 | UINT64\r | |
25 | MultU64x32 (\r | |
26 | IN UINT64 Multiplicand,\r | |
27 | IN UINTN Multiplier\r | |
28 | )\r | |
29 | /*++\r | |
30 | \r | |
31 | Routine Description:\r | |
32 | \r | |
33 | This routine allows a 64 bit value to be multiplied with a 32 bit \r | |
34 | value returns 64bit result.\r | |
35 | No checking if the result is greater than 64bits\r | |
36 | \r | |
37 | Arguments:\r | |
38 | \r | |
39 | Multiplicand - multiplicand\r | |
40 | Multiplier - multiplier\r | |
41 | \r | |
42 | Returns:\r | |
43 | \r | |
44 | Multiplicand * Multiplier\r | |
45 | \r | |
46 | --*/\r | |
47 | {\r | |
48 | __asm {\r | |
49 | mov eax, dword ptr Multiplicand[0]\r | |
50 | mul Multiplier\r | |
51 | push eax\r | |
52 | push edx\r | |
53 | mov eax, dword ptr Multiplicand[4]\r | |
54 | mul Multiplier\r | |
55 | ;\r | |
56 | ; The value in edx stored by second multiplication overflows\r | |
57 | ; the output and should be discarded. So here we overwrite it\r | |
58 | ; with the edx value of first multiplication.\r | |
59 | ;\r | |
60 | pop edx\r | |
61 | add edx, eax\r | |
62 | pop eax\r | |
63 | }\r | |
64 | }\r |