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:
...
pop
does not modify flags), but obviously the second way is more compact. I also note that you could reducejne Code; jmp Exit
toje Exit
, but I guess this is just sample code.lea
does