主题:[讨论]作业,急求回复
两个任意长十进制数相加并输出,编译通过,但结果 示对,望 各位大哥大姐帮小弟,代码 如下data segment
in_msg1 db "please input first number :","$"
in_data1 db 30,0,30 dup(?)
in_msg2 db 0ah,0dh,"please input second number:","$"
in_data2 db 30,0,30 dup(?)
out_msg db 0ah,0dh,"the sum is:",20h
out_data db 100 dup(?),"$"
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov dx,offset in_msg1
mov ah,9
int 21h
mov dx,offset in_data1
mov ah,0ah
int 21h
mov dx,offset in_msg2
mov ah,9
int 21h
mov dx,offset in_data2
mov ah,0ah
int 21h
mov si,offset in_data1
mov di,offset in_data2
mov bx,offset out_data
add si,11
add di,11
add bx,9
clc
mov cx,10
lop1: mov al,[si]
adc al,[di]
aaa
mov [bx],al
dec si
dec di
dec bx
loop lop1
mov cx,10
mov bx,offset out_data
lop2: mov al,[bx]
and al,0fh
add al,30h
mov [bx],al
inc bx
loop lop2
mov dx,offset out_msg
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
:
in_msg1 db "please input first number :","$"
in_data1 db 30,0,30 dup(?)
in_msg2 db 0ah,0dh,"please input second number:","$"
in_data2 db 30,0,30 dup(?)
out_msg db 0ah,0dh,"the sum is:",20h
out_data db 100 dup(?),"$"
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov dx,offset in_msg1
mov ah,9
int 21h
mov dx,offset in_data1
mov ah,0ah
int 21h
mov dx,offset in_msg2
mov ah,9
int 21h
mov dx,offset in_data2
mov ah,0ah
int 21h
mov si,offset in_data1
mov di,offset in_data2
mov bx,offset out_data
add si,11
add di,11
add bx,9
clc
mov cx,10
lop1: mov al,[si]
adc al,[di]
aaa
mov [bx],al
dec si
dec di
dec bx
loop lop1
mov cx,10
mov bx,offset out_data
lop2: mov al,[bx]
and al,0fh
add al,30h
mov [bx],al
inc bx
loop lop2
mov dx,offset out_msg
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
: