Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio inline assembly direct jump

I want to use inline assembly in visual studio to jump to a specific address. I tried this:

_asm {
    jmp 0x12345678
}

But the compiler says: "The opcode does not use operands of this type."

How can I do a direct jump?

like image 334
user2252343 Avatar asked Feb 17 '26 19:02

user2252343


1 Answers

As far as I understand it, MASM does not support this type of jump. You have a few options :

mov eax, 12345678h
jmp eax

or

push 12345678h 
ret

The first uses a register, the second incurs a performance hit because it rattles the CALL/RET pairing optimizations in the CPU. You could also use a typed constant or local variable, I think - this also consumes a few extra bytes. I don't think there's any other way, nor any direct, one-line means of performing a direct jump like this in MASM.

caveat : this assumes you are working in x86 code. Your OP suggests as much from the size of the jmp argument but if this is x64 then the answer will obviously be different.

like image 91
J... Avatar answered Feb 20 '26 09:02

J...



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!