程序代码:
DATA SEGMENT
STR1 DB 'Please input X',0DH,0AH,'$'
STR2 DB 0DH,0AH,'Please input Y',0DH,0AH,'$'
F0 DB 0dh,0ah,'K is 0',0DH,0AH,'$'
F1 DB 0DH,0AH,'K is 1',0DH,0AH,'$'
F2 DB 0DH,0AH,'K is 2',0DH,0AH,'$'
F3 DB 0DH,0AH,'K is 3',0DH,0AH,'$'
F4 DB 0DH,0AH,'K is 4',0DH,0AH,'$'
X DB 20
DB ?
DB 20 DUP(?)
Y DB 20
DB ?
DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA DX,STR1
MOV AH,9
INT 21H
LEA DX,X
MOV AH,0AH
INT 21H
LEA DX,STR2
MOV AH,9
INT 21H
LEA DX,Y
MOV AH,0AH
INT 21H
MOV BX,offset x
MOV SI,offset y
CMP BYTE PTR [BX+2],'-'
JZ K23
CMP BYTE PTR [BX+2],'0'
JZ K0
K14: CMP BYTE PTR [SI+2],'-'
JZ K4
CMP BYTE PTR [SI+2],'0'
JZ K0
LEA DX,F1
MOV AH,9
INT 21H
JMP EXIT
K23: CMP BYTE PTR [SI+2],'-'
JZ K3
CMP BYTE PTR [SI+2],'0'
JZ K0
LEA DX,F2
MOV AH,9
INT 21H
JMP EXIT
K0: LEA DX,F0
MOV AH,9
INT 21H
JMP EXIT
K3: LEA DX,F3
MOV AH,9
INT 21H
JMP EXIT
K4: LEA DX,F4
MOV AH,9
INT 21H
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END START
DATA SEGMENT
STR1 DB 0DH,0AH,'Please input X',0DH,0AH,'$'
STR2 DB 0DH,0AH,'Please input Y',0DH,0AH,'$'
str3 db 0DH,0AH,'$'
X DB 20
DB ?
DB 20 DUP(?)
Y DB 20
DB ?
DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA DX,STR1
MOV AH,9
INT 21H
LEA DX,X
MOV AH,0AH
INT 21H
MOV BX,DX
LEA DX,STR2
MOV AH,9
INT 21H
LEA DX,Y
MOV AH,0AH
INT 21H
MOV SI,DX
mov dx,offset str3
mov ah,9
int 21h
MOV DX,0
CMP BYTE PTR [BX+2],'-'
JZ K23
CMP BYTE PTR [BX+2],'0'
JZ K0
K14: CMP BYTE PTR [SI+2],'-'
JZ K4
CMP BYTE PTR [SI+2],'0'
JZ K0
MOV AH,2
MOV DL,'1'
INT 21H
JMP EXIT
K23: CMP BYTE PTR [SI+2],'-'
JZ K3
CMP BYTE PTR [SI+2],'0'
JZ K0
MOV AH,2
MOV DL,'2'
int 21h
JMP EXIT
K0:
MOV AH,2
MOV DL,'0'
INT 21H
JMP EXIT
K3:
MOV AH,2
MOV DL,'3'
INT 21H
JMP EXIT
K4:
MOV AH,2
MOV DL,'4'
INT 21H
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END START
[
本帖最后由 xiaomarn 于 2010-12-14 17:28 编辑 ]