cmp 指令什么时候修改 zf 标志? [x86 多线程]

When does the cmp instruction modify the zf flag? [x86 MASM]

鉴于“...当算术或逻辑运算的结果生成零结果时设置零标志 (ZF)”,cmp 指令如何与 ZF 交互?

给定以下代码片段,

mov eax, 0
mov edx, 1
cmp eax, edx

cmp 如何计算两个操作数以及 ZF 设置为什么?如果操作数被反转 (cmp edx, eax),那么 ZF 是否设置为与原始语句中相同的值?

如果我要比较两个相同的值,cmp 如何计算操作数以及 ZF 设置为什么?

cmp eax, eax

how does cmp evaluate the two operands?

直接来自the manual

The comparison is performed by subtracting the second operand from the first operand and then setting the status flags in the same manner as the SUB instruction.


If the operands were reversed (cmp edx, eax), then is ZF set to the same value as in the original statement?

对于 ZF,是的。对于其他标志,不一定,因为减法是不可交换的。