我写的汇编程序,哪里有错

来源:百度知道 编辑:UC知道 时间:2024/05/13 15:46:29
问题:加减乘除四则运算
对用户输入的一个包含两个十进制的操作数的加减乘除表达式求出其结果并输出,对用户的输入需要进行有效性的判断

data segment
inpt db 'Please input the expression:$'
err db 'Input Error!$'
prin db 'The consequence is$'
temp1 db 8 dup('$')
temp2 db 8 dup('$')
data ends
stack segment STACK
db 256 dup(0)
tos label word
stack ends
code segment
assume cs:code,ds:data,es:data
start:
xor ax,ax
mov ax,data
mov ds,ax
mov es,ax

inp:
mov ah,02h
mov dl,13
int 21h
mov dl,10
int 21h
mov ah,09h
lea dx,inpt
int 21h
deter1:
lea si,temp1
mov ah,01h
int 21h
cmp al,45h
jz ddd
cmp al,30h
jnb next1
jmp exit1
next1: cmp al,39h
jna next2
jmp exit1
next2: mov [si],al
inc si
deter2:
mov ah,01h
int 21h
cmp al,45h
jnz ttt
ddd: jmp exit
t

我为你重写了一次,查收。

DATAS SEGMENT
pgmMsg db "This program will accept 2 number inputs then calculate them(+-x/) with HEX output.",13,10,"$" ;程序介绍
firstNumberMsg db 13,10, "Please input your 1st number(1-200):$"
secondNumberMsg db 13,10,"Please input your 2nd number(1-200):$"
erMsg db "Nice try, but invalid, try again ...",13,10,"$"
kybuf db 4,?,7 dup(?) ;键盘输入(两个输入都在这里取数)

;=======================================================
;计算出结果后,会以 ah=9,int 21h,输出结果,dx 指向这里
addresult db "Sum of the 2 numbers = "
addans db 5 dup("h"),13,10
subresult db "Difference of the 2 numbers(1st num-2nd num) = "
subans db 5 dup("h"),13,10
mulresult db "Product of the 2 numbers = "
mulans db 5 dup("h"),13,10
divresult db "Quotient of the 2 numbers(