如果我计算标签的地址并将其存储在eax寄存器中,我如何有条件地跳转(使用JE)到eax
jmp eax编译,但我没有检查它是否有效。
je eax不编译(操作码和操作数的无效组合)。为什么会有区别?如果我和eax相等,我怎么跳?
发布于 2015-06-13 07:25:25
根本就没有这种形式的je。您可以做的是根据相反的条件放置一个相对条件跳转,然后是一个无条件的寄存器--间接跳转:
jne skip
jmp eax
skip:你可以用它做一个宏来防止你一遍又一遍地写同样的东西。例如,在NASM语法中,该宏可能如下所示:
%macro je_reg 1
jne %%skip
jmp %1
%%skip:
%endmacro可以像这样使用:
je_reg eax
je_reg ebx宏可以泛化为使用任何条件代码:
%macro jcc_reg 2
j%-1 %%skip ; %-1 expands to the inverse of the condition in the first macro argument
jmp %2
%%skip:
%endmacro
; Example usage
jcc_reg e,eax
jcc_reg no,ebxhttps://stackoverflow.com/questions/30816084
复制相似问题