Conditional deviation not working - Assembly

Asked

Viewed 13 times

0

I went to write a little program in Assembly with the compiler NASM in Xubuntu, there is the code:

    section .data        ;1
        msg db "Olá"     ;2
        n1 db 10         ;3
        n2 db 1          ;4
        len equ $-msg    ;5
                         ;6
    section .text        ;7
        global _start    ;8
        _start:          ;9
            mov rax, n1  ;10
            cmp rax, n2  ;11
            ja end       ;12
            mov rdx, len ;13
            mov rcx, msg ;14
            mov rbx, 1   ;15
            mov rax, 4   ;16
            int 80h      ;17
         end:            ;18
            mov rbx, 0   ;19
            mov rax, 1   ;20
            int 80h      ;21

Theoretically, when it arrived on line 12 it was for the program to jump to the label "end", since a deviation is being made but for some reason the program continues the normal execution.

  • I don’t know anything about Assembly, but from what I read ja has the condition to jump only if the value of the most recent Cmp is satisfied, in case it has to be greater or equal, if the goal is to jump anyway, regardless of the Cmp would have to use jmp (I am not sure, I do not understand well, it was only what I read in a documentation, I may have misunderstood). Now if the goal is even based on the condition then the problem is in the "value" of the cmp more recent. I’m sorry if I’m wrong about something.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.