Question about jumps



Hello,

I tried to program a simple if...else, but when the expression is TRUE,
the program executes both the if branch and the else branch, so it jumps
back to the jz call and executes the else branch too? Why is this so and
how can I solve this?

segment .data

successmsg db "eax is set to 1.", 0, 10
errmsg db "eax is not 1.", 0, 10
succlen equ $-successmsg
errlen equ $-errmsg

global _start

_start:
mov eax, 1
cmp eax, 1
jz thenblock ;if ZF is set -> thenblock
mov eax, 4
mov ebx, 1
mov ecx, errmsg
mov edx, errlen
int 0x80
jmp next

thenblock:
mov eax, 4
mov ebx, 1
mov ecx, successmsg
mov edx, succlen
int 0x80

next:
mov eax, 1
int 0x80

.



Relevant Pages