jnz 检查哪个寄存器 [英] Which register does jnz check
问题描述
我有以下汇编代码的玩具示例,说明了 jnz
的用法.我的问题是:在下面的代码中,jnz 检查什么来决定它是否为 0
?我运行了代码,在我看来它检查了 cx
寄存器.从这一点上我不确定.例如,如果我有一个 cmp
和 cx
,jnz
检查什么?cx
还是 cmp
结果?
I have the following toy example of assembly code that illustrates the use of jnz
. My question is: In the code below, what does jnz checks to decides if it is 0
or not ? I ran the code and it appears to me it checks cx
register. I am not sure from this point. For example, if I have a cmp
and cx
, what does jnz
checks? cx
or cmp
result?
mov cx, 5
mov ax, 0
mov bx, 200
add ax, bx
inc bx
dec cx
jnz 0109
int 3
推荐答案
它检查状态 (FLAGS) 寄存器中的零标志.要查看哪些说明修改了此标志,请参阅 x86 软件开发人员手册.
It checks zero flag in status (FLAGS) register. To see which instructions modify this flag, see x86 software developers manual.
它是关于 DEC 的:
It says this about DEC:
受影响的标志
CF 标志不受影响.设置了 OF、SF、ZF、AF 和 PF 标志根据结果.
The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result.
因此,JNZ 检查由之前修改它的指令设置的标志,在您的情况下是 dec.
So, JNZ checks flag set by previous instruction that happens to modify it and in your case it's dec.
这篇关于jnz 检查哪个寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!