X86 Assembly 我想从我的键盘上获取一个数字并进行比较,之后我想打印一条消息

X86 Assembly I want to get a number from my keyboard and compare it, after that I want to print a message

我想从我的键盘上获取一个数字并比较它,之后我想打印一条消息。 这是我的代码...

我的问题: 当我从键盘上得到东西时,我可以按任意键,它仍然显示 'PC:Salut'。程序运行时不进行比较。我想按 1,程序会知道 1 与 Romana_Salut.

相关
DATA SEGMENT

    m1 DB 'Chose one of the numbers',10,'
m2 DB '1.Romana',10,' m3 DB '2.Engleza',10,' m4 DB '3.Germana',10,' m5 DB '4.Spaniola',10,' STR1 DB "ME:->$" STR3 DB 'PC:Salut',10,' STR4 DB 'PC:Hi',10,' STR5 DB 'PC:Bonjour',10,' STR6 DB 'PC:Guten Tag',10,' STR7 DB 'PC:Hola',10,' STR8 DB 'End',10,' LinieNoua DB 10,13,"$" alg DB 0 DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: ;intializez segmentul de date MOV AX,DATA MOV DS,AX mov ah,9h mov dx,offset m1 int 21h mov ah,9h mov dx,offset m2 int 21h mov ah,9h mov dx,offset m3 int 21h mov ah,9h mov dx,offset m4 int 21h mov ah,9h mov dx,offset m5 int 21h Alegerea: mov dx,offset STR1 mov ah,1 int 21h mov ch,ah Romana_Salut: cmp ch, 1 je Algromana Algromana: MOV AH,09H LEA DX,LinieNoua INT 21H mov ah,9h mov dx,offset STR3 int 21h jmp Final Final: mov ah,4ch int 21h CODE ENDS END START

你没有正确比较字符:

DATA SEGMENT

    m1 DB 'Alege unul dintre numere pentru a afla cum se spune Salut in urmatoarele limbi',10,'$'
    m2 DB '1.Romana',10,'$'
    m3 DB '2.Engleza',10,'$'
    m4 DB '3.Germana',10,'$'
    m5 DB '4.Spaniola',10,'$'

    STR1 DB "ME:->$"
    STR3 DB 'PC:Salut',10,'$'
    STR4 DB 'PC:Hi',10,'$'
    STR5 DB 'PC:Bonjour',10,'$'
    STR6 DB 'PC:Guten Tag',10,'$'
    STR7 DB 'PC:Hola',10,'$'
    STR8 DB 'End',10,'$'
    LinieNoua DB 10,13,"$"
    alg DB 0

DATA ENDS

CODE SEGMENT

    ASSUME DS:DATA,CS:CODE
START:

    mov ax, DATA
    mov ds, ax

    mov ah,9h
    mov dx,offset m1
    int 21h

    mov ah,9h
    mov dx,offset m2
    int 21h

    mov ah,9h
    mov dx,offset m3
    int 21h

    mov ah,9h
    mov dx,offset m4
    int 21h

    mov ah,9h
    mov dx,offset m5
    int 21h

Alegerea:

    mov dx,offset STR1; introdu alegerea...
    int 21h
    mov ah,1h ;citesc alegerea
    int 21h

    cmp al, '1'
    je  Romana_label

    cmp al, '2'
    je  Engleza_label

    cmp al, '3'
    je  Germana_label

    cmp al, '4'
    je  Spaniola_label

Romana_label:

    MOV AH,09H
    LEA DX,LinieNoua
    INT 21H

    mov ah,9h
    mov dx,offset STR3
    int 21h
    jmp Final

Engleza_label:

    MOV AH,09H
    LEA DX,LinieNoua
    INT 21H

    mov ah,9h
    mov dx,offset STR4
    int 21h
    jmp Final

Germana_label:

    MOV AH,09H
    LEA DX,LinieNoua
    INT 21H

    mov ah,9h
    mov dx,offset STR5
    int 21h
    jmp Final

Spaniola_label:

    MOV AH,09H
    LEA DX,LinieNoua
    INT 21H

    mov ah,9h
    mov dx,offset STR6
    int 21h
    jmp Final


Final:

    mov ah,4ch
    mov al,0
    int 21h

CODE ENDS
END START

在 DOSBox 中使用 tasm(masm) 和 link 进行测试。 ..................................................... ..................................................... ..................................................... ...............

我进行了编辑,使其符合我对程序的预期。

谢谢 SonOfSun!