ASM x86 在 cmp 之后立即弹出是否正确?

ASM x86 is it correct pop immediately after cmp?

有时我需要在堆栈中存储值而不是比较它。所以,我做这样的事情:

Check:
  push eax          ; save
  mov eax, edx      ; calc edx+esi+8
  add eax, esi
  add eax, 8
  cmp eax, [SomeVar]
  jne Code          ; if not goto Code
  pop eax           ; restore stack
  jmp Exit          ; quit

Code:
  pop eax           ; restore stack if no

Exit:
...

那么,以这种方式弹出是否正确(仅一次):

Check:
  push eax          ; save
  mov eax, edx      ; calc edx+esi+8
  add eax, esi
  add eax, 8
  cmp eax, [SomeVar]
  pop eax           ; <-- pop after cmp
  jne Code          ; <-- jump after pop
  jmp Exit          ; quit

Code:
  ; pop eax         ; no pop needs here

Exit:
...

是的。 Pop 不会更改标志,因此将 pop 放在条件分支之前的比较之后就可以了。