views:

36

answers:

1
__asm
{
  mov bl, byte [0x0068F51C]
  call 0x004523C0
}

This code gives this error:

main.cpp(57): error C2400: inline assembler syntax error in 'second operand'; found '['
main.cpp(58): error C2415: improper operand type

Line 57 is the line with the mov instruction. I don't see what I'm doing wrong here, especially the call instruction. Can somebody tell me how to remove this error?

+1  A: 

The obvious question would be why you think you want to do this. For the first instruction, the problem is purely syntactical, and trivial to fix:

mov bl, byte ptr [0x0068F51C]

There are a few ways of fixing the second instruction. One possibility would be like this:

mov eax, 0x004523C0
call [eax]

The cleaner/more direct methods of calling an arbitrary address use assembler directives that I don't think are supported by the inline assembler, so at least offhand I'm not sure of a cleaner way to handle this particular one.

Jerry Coffin
I don't see why it's illegal to use the call instruction with a constant in the inline assembler because I've seen it while debugging. Oh well, I guess your method will do for now.
kaykun