我想从键盘上获取一个数字并进行比较,之后我想打印一条消息。 这是我的代码......
我的问题: 当我从键盘上拿到东西时,我可以按任意键,它仍然会显示'PC:Salut'。该程序运行没有比较。我想按1和程序知道1个corepunds与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
答案 0 :(得分:1)
你没有正确地比较这个角色:
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)和链接进行测试。 .................................................. .................................................. .................................................. ...............
我进行了编辑,所以它符合我对该计划的意图。
谢谢SonOfSun!