-
March 6th, 2012, 10:33 AM
#1
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.
-
March 6th, 2012, 10:59 AM
#2
Re: Help with porting code part from 32 to 64bit
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
-
March 6th, 2012, 11:03 AM
#3
Re: Help with porting code part from 32 to 64bit
So should I rename all registers to rax, rbx etc..?
-
March 6th, 2012, 11:43 AM
#4
Re: Help with porting code part from 32 to 64bit
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
-
March 6th, 2012, 04:46 PM
#5
Re: Help with porting code part from 32 to 64bit
Check out SIMD instruction PSHUFB.
It will process four 32-bit values at once.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|