How to translate this inline assembly code to x64 assembly

0

I have following C++ function with inline assembly:

void getMemAddrFromBIOSbySMI(int& bResult, unsigned long& addr,unsigned long& dataLength){
    __asm {              
        mov eax, 0x000000E3               
        mov ebx, 0x00000001               
        mov ecx, 0xFAFAFAFA               
        mov edx, 0x000000B2              
        out dx,al               
        mov bResult, eax              
        mov addr,  ebx            
        mov dataLength, ecx        
    }

    if((bResult & 0x000000FF) == 0){
        bReSult = 1;        
    } 
    else { 
        bResult = 0;       
    }
}

I want to let this code can support x64, but VC++ x64 have no support inline assembly, I have no idea how to translate this code to x64 assembly format...

Have anybody can help me?

c++
assembly
asked on Stack Overflow Oct 20, 2014 by Hsu Wan • edited Oct 20, 2014 by Cory Kramer

2 Answers

1

You can use the compiler intrinsic __outbyte to write to a port.

answered on Stack Overflow Oct 20, 2014 by Sean
0

You can use __asm _emit to encode x64 instructions. Additionally, since on x64 the parameters come via registers RCX and RDX need to be saved before the MOVs, then restored when accessing the parameters.

answered on Stack Overflow Oct 21, 2014 by Attila

User contributions licensed under CC BY-SA 3.0