|  3DSoftware.com > Programming > Integers > Page 4 |
|
Integers
Page 4
Wide Integers Simd Addition To add two WideInteger numbers, A and B, each number having 8 digit packets, begin by loading the digits into two sets of simd registers: |
|||||||||||||||
|
|||||||||||||||
|
The digit packets are indexed with n = 0 for the least significant digit. In this example they increase in significance from right to left. Invoke the PADDD instruction on both sets of registers to add B |
|||||||||||||||
|
|||||||||||||||
|
After invoking PADDD, the new digit packets of A have carries that need to be propagated. Now put a copy of this new A into the other simd registers with MOVDQU invoked for each set of registers: |
|||||||||||||||
|
|||||||||||||||
|
Right shift the bits of each digit of the copy of A, |
|||||||||||||||
|
|||||||||||||||
|
Clear bit 30 of each A digit by ANDing each digit packet with 3FFFFFFFh (using PAND), then store (save) A0 to the first Then shift the digit packets, overwriting A0 which did not have any carries added to it and has already been |
|||||||||||||||
|
|||||||||||||||
|
A temporary digit packet A8 will recieve possible overflow: |
|||||||||||||||
|
|||||||||||||||
|
Add the carries into these digits of A with PADDD. Repeat these operations to perform all possible carries. When finished, invoke MFENCE and then extract the new A digits from the output stream memory buffer. Note: In assembly language, AMD uses Microsoft (backwards) packet ordering to be compatible with Microsoft Windows. |
|||||||||||||||
| Page 4 | ||||||
|
|
Copyright © 2008 by 3D Software. All rights reserved. 3D Software, P.O. Box 221190, Sacramento CA 95822 USA www.3DSoftware.com Contact us |
| Thursday, 20-Nov-2008 12:11:29 GMT |