CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    48

    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help with porting code part from 32 to 64bit

    Quote Originally Posted by Anakunda View Post
    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

  3. #3
    Join Date
    Feb 2009
    Posts
    48

    Re: Help with porting code part from 32 to 64bit

    So should I rename all registers to rax, rbx etc..?

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help with porting code part from 32 to 64bit

    Quote Originally Posted by Anakunda View Post
    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

  5. #5
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    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
  •  





Click Here to Expand Forum to Full Width

Featured