Search code examples
assemblyx86masm

I am confused with comparing and jumping in assembly


I want to input

11,00,01,10 in ebx and eax register.

Every time I input 01 or 10 I need to jump at l1.

And if I input 11 or 00 I want to quit from the procedure.

How can I do that? I tried it but only first two cmp's are working rest is not working.

    cmp ebx,0
    cmp eax,0
    je l1

    cmp ebx,1
    cmp eax,0
        jmp quit

    cmp ebx,1
    cmp eax,1
    jmp quit2

l1: mov edx,offset num3
    call writestring
    call crlf
    mov edx,offset num2
    call writestring
    call calf

Solution

    1. Are you sure about 'jmp'? shouldn't it be 'je'?
    2. As far as I know, only the last cmp result is stored. So if you write two sequential cmp commands, the first one will not have any effect. You should check the result right after any cmp command.
    3. If you jump right after checking the 10 case you'll never get to check the 11 case.