3 Copyright (c) 1998 Intel Corporation
22 // Declare runtime functions
27 #pragma RUNTIME_CODE(LShiftU64)
28 #pragma RUNTIME_CODE(RShiftU64)
29 #pragma RUNTIME_CODE(MultU64x32)
30 #pragma RUNTIME_CODE(DivU64x32)
43 // Left shift 64bit by 32bit and get a 64bit result
46 return Operand << Count;
50 mov eax, dword ptr Operand[0]
51 mov edx, dword ptr Operand[4]
65 mov dword ptr Result[0], eax
66 mov dword ptr Result[4], edx
78 // Right shift 64bit by 32bit and get a 64bit result
81 return Operand >> Count;
85 mov eax, dword ptr Operand[0]
86 mov edx, dword ptr Operand[4]
100 mov dword ptr Result[0], eax
101 mov dword ptr Result[4], edx
111 IN UINT64 Multiplicand,
114 // Multiple 64bit by 32bit and get a 64bit result
117 return Multiplicand * Multiplier;
121 mov eax, dword ptr Multiplicand[0]
123 mov dword ptr Result[0], eax
124 mov dword ptr Result[4], edx
125 mov eax, dword ptr Multiplicand[4]
127 add dword ptr Result[4], eax
138 OUT UINTN *Remainder OPTIONAL
140 // divide 64bit by 32bit and get a 64bit result
141 // N.B. only works for 31bit divisors!!
145 *Remainder = Dividend % Divisor;
146 return Dividend / Divisor;
151 ASSERT (Divisor != 0);
152 ASSERT ((Divisor >> 31) == 0);
155 // For each bit in the dividend
159 for (bit=0; bit < 64; bit++) {
161 shl dword ptr Dividend[0], 1 ; shift rem:dividend left one
162 rcl dword ptr Dividend[4], 1
166 cmp eax, Divisor ; Is Rem >= Divisor?
167 cmc ; No - do nothing
169 sub dword ptr Dividend[0], eax ; set low bit in dividen
170 and eax, Divisor ; and
171 sub Rem, eax ; subtract divisor