Dear terageek,
I have been working a while with your suggestions. I think that my question was not clear. In addition, I would like to start with something a bit easier for me. Let's just examine the simple unsigned multiplication of unsigned 32-bit a * unsigned 32-bit b = unsigned 64-bit c.
I have coded this in a mixed C++ / ASM project using VC6, SP5 in the dialect of 386 assembler below.
Can this be done faster using something from the Pentium IV or higher? I was mistaken since I thought the newer stuff with SSE2 was in PIII as well. Let's look at the PIV architecture.
Let's start with this simple example. After mastering the 32 * 32 = 64 stuff, I would like to study the next level (64 bit * 64 bit = 128 bit).
Can you or anyone else please look at the sample and try to get this more modern that the 386 stuff?
Thanks once again for any help.
Sincerely, Chris.
int main(int argc, char* argv[])
{
unsigned __int32 a = 0x33333333;
unsigned __int32 b = 0x66666666;
unsigned __int32 aa = 0xBBBBBBBB;
unsigned __int32 bb = 0xEEEEEEEE;
unsigned __int64 c, cc;
// Multiply c = a * b
// Multiply cc = aa * bb
__asm
{
mov eax, dword ptr [a]
imul dword ptr [b]
mov dword ptr [c], eax
mov dword ptr [c + 4], edx
mov eax, dword ptr [aa]
mul dword ptr [bb]
mov dword ptr [cc], eax
mov dword ptr [cc + 4], edx
}
// Test c = a * b
unsigned __int64 t = static_cast<unsigned __int64>( a) * b;
// Test cc = aa * bb
unsigned __int64 tt = static_cast<unsigned __int64>(aa) * bb;
// Final check.
const bool ok = t == c && tt == cc;
return ok ? 0 : 1;
}
Main Topics
Browse All Topics





by: terageekPosted on 2003-12-11 at 18:14:59ID: 9925362
The PIII only supports SSE, not SSE2.
MXPrimer.h tml
If you want to work with integers, then you want MMX (SSE works on floats, and each 128 bit register is treated as 4 parallel 32 bit floats).
You can use MMX instructions to manipulate some 64 bit values for addition and subtraction. I believe that you can multiply 2 64-bit numbers, but you will need to specifiy if you want the low 64-bits of the result or the high 64-bits of the result. I don't believe you can divide 128 bits by 64 bits however.
http://www.tommesani.com/M