9 Include file for sample Large Integer Arithmetic routines.
10 This file includes all of the prototypes for the routines found in
11 largeint.lib. For complete descriptions of these functions, see the
12 largeint.s source file for MIPS, or the divlarge.c and largeint.asm
24 //Large integer arithmetic routines.
28 // Large integer add - 64-bits + 64-bits -> 64-bits
33 LARGE_INTEGER Addend1
,
38 // Enlarged integer multiply - 32-bits * 32-bits -> 64-bits
42 EnlargedIntegerMultiply (
48 // Unsigned enlarged integer multiply - 32-bits * 32-bits -> 64-bits
52 EnlargedUnsignedMultiply (
58 // Enlarged integer divide - 64-bits / 32-bits > 32-bits
62 EnlargedUnsignedDivide (
63 IN ULARGE_INTEGER Dividend
,
69 // Extended large integer magic divide - 64-bits / 32-bits -> 64-bits
74 LARGE_INTEGER Dividend
,
75 LARGE_INTEGER MagicDivisor
,
80 // Large Integer divide - 64-bits / 32-bits -> 64-bits
84 ExtendedLargeIntegerDivide (
85 LARGE_INTEGER Dividend
,
91 // Large Integer divide - 64-bits / 32-bits -> 64-bits
96 LARGE_INTEGER Dividend
,
97 LARGE_INTEGER Divisor
,
98 PLARGE_INTEGER Remainder
102 // Extended integer multiply - 32-bits * 64-bits -> 64-bits
106 ExtendedIntegerMultiply (
107 LARGE_INTEGER Multiplicand
,
112 // Large integer negation - -(64-bits)
117 LARGE_INTEGER Subtrahend
121 // Large integer subtract - 64-bits - 64-bits -> 64-bits.
125 LargeIntegerSubtract (
126 LARGE_INTEGER Minuend
,
127 LARGE_INTEGER Subtrahend
131 // Large integer and - 64-bite & 64-bits -> 64-bits.
134 #define LargeIntegerAnd(Result, Source, Mask) \
136 Result.HighPart = Source.HighPart & Mask.HighPart; \
137 Result.LowPart = Source.LowPart & Mask.LowPart; \
142 // Large integer conversion routines.
146 // Convert signed integer to large integer.
150 ConvertLongToLargeInteger (
155 // Convert unsigned integer to large integer.
159 ConvertUlongToLargeInteger (
160 ULONG UnsignedInteger
165 // Large integer shift routines.
169 LargeIntegerShiftLeft (
170 LARGE_INTEGER LargeInteger
,
175 LargeIntegerShiftRight (
176 LARGE_INTEGER LargeInteger
,
181 LargeIntegerArithmeticShift (
182 LARGE_INTEGER LargeInteger
,
186 #define LargeIntegerGreaterThan(X,Y) ( \
187 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
188 ((X).HighPart > (Y).HighPart) \
191 #define LargeIntegerGreaterThanOrEqualTo(X,Y) ( \
192 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
193 ((X).HighPart > (Y).HighPart) \
196 #define LargeIntegerEqualTo(X,Y) ( \
197 !(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
200 #define LargeIntegerNotEqualTo(X,Y) ( \
201 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
204 #define LargeIntegerLessThan(X,Y) ( \
205 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
206 ((X).HighPart < (Y).HighPart) \
209 #define LargeIntegerLessThanOrEqualTo(X,Y) ( \
210 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
211 ((X).HighPart < (Y).HighPart) \
214 #define LargeIntegerGreaterThanZero(X) ( \
215 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
216 ((X).HighPart > 0 ) \
219 #define LargeIntegerGreaterOrEqualToZero(X) ( \
223 #define LargeIntegerEqualToZero(X) ( \
224 !((X).LowPart | (X).HighPart) \
227 #define LargeIntegerNotEqualToZero(X) ( \
228 ((X).LowPart | (X).HighPart) \
231 #define LargeIntegerLessThanZero(X) ( \
235 #define LargeIntegerLessOrEqualToZero(X) ( \
236 ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) \