Re: Question about jumps



Markus Pitha wrote:
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

"suclen" includes both strings. Try it like this:

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

Best,
Frank
.



Relevant Pages

  • Re: Question about jumps
    ... Markus Pitha wrote: ... Frank already gave you the answer, ... Which assembler sets the data segment executable? ... succlen equ $-successmsg ...
    (alt.lang.asm)
  • Re: Question about jumps
    ... succlen equ $-successmsg ... errlen equ $-errmsg ... If it *did* terminate on the zero, you wouldn't get the linefeed. ...
    (alt.lang.asm)
  • Re: Question about jumps
    ... Frank Kotler wrote: ... succlen equ $-successmsg ... errlen equ $-errmsg ... order to do with the program execution? ...
    (alt.lang.asm)