Help with porting code part from 32 to 64bit
HI
I ams truggling with conversion of source part to comply with 64bit C++ compiler, unfortunatelly the part is written in assembler language. I get these errors during compiling:
error: Operand size mismatch in asm instruction mov.
error: Illegal gp reg in address (must be 64-bit) in asm instruction mov.
error: Illegal gp reg in address (must be 64-bit) in asm instruction mov.
The concerned part of 32bit source looks following:
Code:
static void local_swap32_block_(unsigned __int32 *start, unsigned __int32 len)
{
__asm {
mov edx, start
mov ecx, len
test ecx, ecx
loop1:
jz done1
mov eax, dword ptr [edx]
bswap eax
mov [edx], eax
add edx, 4
dec ecx
jmp short loop1
done1:
}
}
#endif
Anybody can tell how can I adjust the instructions to comply 64bit compiler and retain it's functionality? Thanks.
Btw. the function parameters are 32bit integers regardless on target machine so they should be handled as 32bit integers in this function also.
Re: Help with porting code part from 32 to 64bit
Quote:
Originally Posted by
Anakunda
HI
I ams truggling with conversion of source part to comply with 64bit C++ compiler, unfortunatelly the part is written in assembler language. I get these errors during compiling:
error: Operand size mismatch in asm instruction mov.
error: Illegal gp reg in address (must be 64-bit) in asm instruction mov.
error: Illegal gp reg in address (must be 64-bit) in asm instruction mov.
The 64-bit registers are named rax, rbx, rcx, rdx, etc.
Regards,
Paul McKenzie
Re: Help with porting code part from 32 to 64bit
So should I rename all registers to rax, rbx etc..?
Re: Help with porting code part from 32 to 64bit
Quote:
Originally Posted by
Anakunda
So should I rename all registers to rax, rbx etc..?
Why not try and see what happens? Or tell us what that code is supposed to do and then attempt to rewrite it in 'C' or C++.
Also, exactly what compiler are you using? Is inline assembly language supported in 64-bit compilation for Visual C++? As far as I know, x64 builds do not support inline assembly language, and instead, uses something called intrinsics.
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
Regards,
Paul McKenzie
Re: Help with porting code part from 32 to 64bit
Check out SIMD instruction PSHUFB.
It will process four 32-bit values at once.