要求是输入两个十进制数的四则运算式,然后连同式子一起输出结果.
结果大小在-65535到65535之间,结果精确到小数点后两位
我已经有个程序在附件里,但是就是不能实现即时输入式子显示和结果小于0,范围也不在-65535到65535
真的希望斑竹和高手能救下我,做不出就不能毕业了.下面是我的原程序,高手们帮我修改一下可以吗
STACK1 SEGMENT PARA STACK 'stack' ;Copyright by Lau Heng,2002145013
dw 100h dup(0)
stack1 ends
data segment
lau1 db 'This is a program for sums.Please input the number 1:$ '
fuhao db 'Please select the character(+,-,*,/):$'
lau2 db 'Then input the number 2:$'
answer db 'Lauheng says:The answer is $'
data ends
code segment
assume cs:code, ds:data,ss:stack1
main:
mov ax, data
mov ds, ax
mov dx,offset lau1
mov ah,9
int 21H
mov bx,0
qushu1: mov cx,10
mov ah,1
int 21h
sub al,30h
cmp al,0
jl lau
cmp al,09h
jg lau
mov ah,0
xchg ax,bx
mov cx,0ah
mul cx
xchg ax,bx
add bx,ax
jmp qushu1
lau: push bx
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2h
int 21h
lea dx,fuhao
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,0
push ax
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
lea dx,lau2
mov ah,9
int 21h
mov bx,0
qushu2:
mov ah,1
int 21h
sub al,30h
cmp al,0
jl next
cmp al,09h
jg next
mov ah,0
xchg ax,bx
mov cx,0ah
mul cx
xchg ax,bx
add bx,ax
jmp qushu2
next: push bx
pop cx
pop ax
pop bx
mov dl,al
mov ah,2
int 21h
cmp al,'+'
je jia
cmp al,'-'
je jian
cmp al,'*'
je cheng
cmp al,'/'
je chu
jmp error
jia: add bx,cx
push bx
jmp other
jian: sub bx,cx
push bx
jmp other
cheng: mov ax,bx
xor dx,dx
mul cx
push ax
jmp other
chu: mov ah,0
mov al,bl
div cl
mov bh,0
mov bl,al
push bx
other:
pop bx
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
mov dx,offset answer
mov ah,9
int 21h
push bx
cmp bx,10000
jae xunhuan1
cmp bx,1000
jae xunhuan2
cmp bx,100
jae xunhuan3
cmp bx,10
jae xunhuan4
jmp xunhuan5
xunhuan1:
pop ax
xor dx,dx
mov bx,10000
div bx
push dx
add al,30h
mov dl,al
mov ah,2
int 21h
xunhuan2:
pop ax
xor dx,dx
mov bx,1000
div bx
push dx
add al,30h
mov dl,al
mov ah,2
int 21h
xunhuan3:
pop ax
xor dx,dx
mov bx,100
div bx
push dx
add al,30h
mov dl,al
mov ah,2
int 21h
xunhuan4:
pop ax
xor dx,dx
mov bx,10
div bx
push dx
add al,30h
mov dl,al
mov ah,2
int 21h
xunhuan5:
pop dx
add dl,30h
mov ah,2
int 21h
pass:
mov ah,4ch
int 21h
error: mov ah,4ch
int 21h
code ends
end main
高手们帮我修改一下可以吗
[此贴子已经被作者于2005-12-11 13:20:43编辑过]