DATA SEGMENT
X DB ?
Y DB ?
S DB ?,?
mess1 db "Input x=(0 quit)","$"
mess3 db 'Input y=','$'
mess2 db 'x+y=$'
DATA ENDS
stack segment para stack 'stack'
dw 100 dup(?)
stack ends
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ss:stack
START: MOV AX,DATA
MOV DS,AX
l1: lea dx,mess1
mov ah,9
int 21h
MOV AH,1
INT 21H
cmp al,'0'
jl exit
cmp al,'9'
ja exit ;当输入的不是数字时
je l2
MOV X,AL
call cr_lf
lea dx,mess3
mov ah,9
int 21h
MOV AH,1
INT 21H
MOV Y,AL
MOV AL,X
AND AL,0FH
MOV BL,Y
AND BL,0FH
ADD AL,BL
cbw
mov bl,10
div bl
or al,30h
mov s,al
or ah,30h
mov [s+1],ah
call cr_lf
mov dx,offset mess2
mov ah,9
int 21h
MOV AH,2
MOV DL,s
INT 21H
mov ah,2
mov dl,[s+1]
int 21h
call cr_lf
jmp l1
exit : mov ah,61h
int 21h
goto l1 ; 发出警报 转移到l1重新输入
l2: MOV AH,4CH
INT 21H
cr_lf proc
push ax
push dx
mov ah,2
mov dl,0ah
int 21h
mov ah,2
mov dl,0dh
int 21h
pop dx
pop ax
ret
cr_lf endp
CODE ENDS
END START
好象就这样