我对比较和跳跃装配很困惑

时间:2013-12-07 19:05:14

标签: assembly x86 masm

我想输入

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.

我该怎么做?我试过了,但只有前两个cmp正在休息工作。

    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

1 个答案:

答案 0 :(得分:1)

  1. 您确定'jmp'吗?不应该是'je'吗?
  2. 据我所知,只存储了最后一个cmp结果。因此,如果您编写两个顺序cmp命令,第一个命令将没有任何效果。你应该在任何cmp命令之后检查结果。
  3. 如果你在检查了10个案子后立即跳过,你将永远不会检查11个案例。