This question already has an answer here:
say I calculated an address of a label and stored it in eax register, how can I JMP(specifically JE) to eax?
compiles, but I didn't check if it works.
doesn't compile(invalid combination of opcode and operands). Why the difference? and how can I jmp if equal to eax?
Best How To :
There simply is no such form of
je. What you can do is put a relative conditional jump based on the opposite condition, followed by an unconditional register-indirect jump:
You could make a macro out of this to save you from writing the same thing over and over. For example, in NASM syntax that macro could look like this:
%macro je_reg 1
And could be used like this:
The macro could be generalized to work with any condition code:
%macro jcc_reg 2
j%-1 %%skip ; %-1 expands to the inverse of the condition in the first macro argument
; Example usage