从键盘输入两个十进制的数相加并计算结果
这个是两个从键盘输入任意两个十进制数相加的程序,但是我看不出哪里出了错,哪位大神能不能帮忙改一下·······DATAS SEGMENT
x db 20 dup(0)
y db 20 dup (0)
f db 'error','$'
k dw 0
t dw 0 ;此处输入数据段代码
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov si,0
x1:
mov ah,07h
int 21h
mov dl,al
cmp dl,'+'
jz x2
cmp dl,'='
jz x3
cmp dl,30h
jb xi
cmp dl,39h
ja xi
x4:
mov ah,02h
int 21h
mov x[si],dl
inc si
jmp x1
x2:
cmp si,0
jz xi
mov k,si
mov bx,0
mov cx,k
xa:
mov al,x[bx]
mov y[bx],al
inc bx
loop xa
add bx,1
mov t,bx
jmp x4
x3:
cmp si,0
jz xi
mov ah,02h
int 21h
mov bx,k
mov di,0
sub si,bx
mov cx,si
xb:
mov al,x[bx+1]
mov x[di],al
inc bx
inc di
loop xb
clc
pushf
mov k,di
cmp t,di
jnb x5
mov cx,k
jmp x6
x5:
mov cx,t
;jmp x6
x6:
mov dl,y[di]
mov al,x[si]
sub al,30h
sub dl,30h
dec si
dec di
popf
adc al,dl
aaa
pushf
add al,30h
mov dl,al
mov ah,02h
int 21h
loop x6
jmp xj
xi:
mov dx,OFFSET f
mov ah,09h
int 21h
MOV DL,0ah
MOV AH,02H
INT 21H
MOV DL,0dh
MOV AH,02H
INT 21H
jmp start ;此处输入代码段代码
xj:
MOV AH,4CH
INT 21H
CODES ENDS
END START
DATAS SEGMENT
x db 20 dup(0)
y db 20 dup (0)
f db 'error','$'
k dw 0
t dw 0 ;此处输入数据段代码
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov si,0
x1:
mov ah,07h
int 21h
mov dl,al
cmp dl,'+'
jz x2
cmp dl,'='
jz x3
cmp dl,30h
jb xi
cmp dl,39h
ja xi
x4:
mov ah,02h
int 21h
mov x[si],dl
inc si
jmp x1
x2:
cmp si,0
jz xi
mov k,si
mov bx,0
mov cx,k
xa:
mov al,x[bx]
mov y[bx],al
inc bx
loop xa
add bx,1
mov t,bx
jmp x4
x3:
cmp si,0
jz xi
mov ah,02h
int 21h
mov bx,k
mov di,0
sub si,bx
mov cx,si
xb:
mov al,x[bx+1]
mov x[di],al
inc bx
inc di
loop xb
clc
pushf
mov k,di
cmp t,di
jnb x5
mov cx,k
jmp x6
x5:
mov cx,t
;jmp x6
x6:
mov dl,y[di]
mov al,x[si]
sub al,30h
sub dl,30h
dec si
dec di
popf
adc al,dl
aaa
pushf
add al,30h
mov dl,al
mov ah,02h
int 21h
loop x6
jmp xj
xi:
mov dx,OFFSET f
mov ah,09h
int 21h
MOV DL,0ah
MOV AH,02H
INT 21H
MOV DL,0dh
MOV AH,02H
INT 21H
jmp start ;此处输入代码段代码
xj:
MOV AH,4CH
INT 21H
CODES ENDS
END START