繁体   English   中英

如何在部件x86中使用cmp参数

[英]How to work with the cmp parameter in assembly x86

我的cmp命令有问题。 无论我传递什么结果,程序都会忽略cmp结果并运行代码的所有部分。 谁能帮我吗?

     ;tipo de bandeira
    mov ah, 40h
    mov bx, 1
    mov cx, 24
    mov dx, bandeira
    int 21h

    ;linha
    mov ah, 40h
    mov bx, 1
    mov cx, 1
    mov dx, linha
    int 21h

    ;input e confirmação do tipo de bandeira
    mov ah, 3Fh
    mov bx, 00
    mov cx, 1
    mov dx, tipoBandeira
    int 21h

    ;clear feed
    mov ah, 3Fh
    mov bx, 00
    mov cx, 2
    mov dx, crlf
    int 21h

    cmp[tipoBandeira],01
    je T1
    cmp[tipoBandeira],02
    je T2


    T1:
    mov ah, 40h
    mov bx, 1
    mov cx, 08
    mov dx, quad
    int 21h

    T2:
    mov ah, 40h
    mov bx, 1
    mov cx, 11
    mov dx, rect
    int 21h

我对汇编语言很陌生,我有一个很烂的老师,用“使用google”来回答我们所有的问题,而忽略了许多汇编类型,而这确实不是一种直截了当的语言。

问题所在

cmp [tipoBandeira],01
je T1
cmp [tipoBandeira],02
je T2

T1:
mov ah, 40h
mov bx, 1
mov cx, 08
mov dx, quad
int 21h

T2:
mov ah, 40h
mov bx, 1
mov cx, 11
mov dx, rect
int 21h

是以下内容:

  • 如果[tipoBandeira] = 1,则执行T1,然后执行T2
  • 如果[tipoBandeira] = 2,则执行T2
  • 如果[tipoBandeira]其他,则执行T1,然后执行T2

您缺少来自compare和T1块的退出。 您想要的可能是这样的:

cmp [tipoBandeira],02  ;if tipoBandeira = 2
je T2                  ;  go to T2
cmp [tipoBandeira],01  ;else if tipoBandeira = 1
jne EXIT               ;  go to T1
                       ;else go to EXIT
T1:
mov ah, 40h
mov bx, 1
mov cx, 08
mov dx, quad
int 21h
jmp EXIT                ;end if

T2:
mov ah, 40h
mov bx, 1
mov cx, 11
mov dx, rect
int 21h

EXIT:                   ;end if
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM