Reputation: 53
Sometimes I need store values in stack and than compare it. So, I do something like this:
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:
...
So, is it correct way to do popping that way (only once):
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:
...
Upvotes: 0
Views: 601
Reputation: 12435
Yes. Pop does not change the flags, so putting the pop after the comparison before the conditional branch is fine.
Upvotes: 4