简体   繁体   中英

Using ASM in C++

I am using the following code:

int _tmain(int argc, _TCHAR* argv[])
{
    __asm{ 
           "MOV EAX, DMSN[0]";
           "LEA EBX, DMSN[0]";
           "CALL EBX";
         };
    return 0;
}

MOV EAX and LEA EBX , will later contain two different arrays. But as for the example they will contain the same.

I am using the following:

const BYTE DMSN[694]={blah, blah, blah};

But i am turning up with these erros:

1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(49): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'
1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(50): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'
1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(51): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'**strong text**

What is wrong?

Your syntax is faulty, use it like this:-

 int _tmain(int argc, _TCHAR* argv[])
    {
      _asm{ 
           mov eax, DMSN[0]
           lea ebx, DMSN[0]
           call ebx
          }
        return 0;
    }

for VS based compiler.

if dmsn is array, you dont have to put [0] to access first element

int _tmain(int argc, _TCHAR* argv[])
{
    __asm{ 
           mov eax, DMSN
           lea ebx, DMSN
           call ebx
         };
    return 0;
}

mov instruction will automatically check for the operand sizes and will take first 32 bits into register(eax) and 32 bit effective address to register(ebx)

VC++ 2010 express

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM