求一个用汇编语言编写的“最简单的”从键盘输入两个数相加,得出结果,,我要完整的程序步骤,,,3Q

如题所述

data segment
op1 dw ?
op2 dw ?
str1 db 'Please Input The 1st Number ',13,10, '$ '
str2 db 'Please Input The 2st Number ',13,10, '$ '
str3 db 'The Answer Is: ', '$ '
data ends

code segment
assume cs:code,ds:data
start:
main proc far
push ds
sub ax,ax
push ax

mov ax,data
mov ds,ax

lea dx,str1
mov ah,9
int 21h
call dec2bin
mov op1,bx
lea dx,str2
mov ah,9
int 21h
call dec2bin
mov op2,bx
add bx,op1
lea dx,str3
mov ah,9
int 21h
call bin2dec

retf
main endp

dec2bin proc near
mov bx,0
newchar:
mov ah,1
int 21h
sub al,30h
jl exit
cmp al,9d
jg exit
cbw
xchg ax,bx
mov cx,10d
mul cx
xchg ax,bx
add bx,ax
jmp newchar
exit:
ret
dec2bin endp

bin2dec proc near
mov cx,10000d
call decdiv
mov cx,1000d
call decdiv
mov cx,100d
call decdiv
mov cx,10d
call decdiv
mov cx,1d
call decdiv
ret
bin2dec endp

decdiv proc near
mov ax,bx
mov dx,0
div cx
mov bx,dx
mov dl,al
add dl,30h
mov ah,2
int 21h
ret
decdiv endp
code ends
end start
要善用百度,google呀。
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-12-12
mov ax,01h
int 21h
mov bx,dx
mov ax,01h
int 21h
add bx,dx
第2个回答  2011-12-12
我只会c语言
相似回答