这是第二个,对于第一个与这一个的思路是一样的
你自己看吧,程序很简单,思路是:
以字符串的形式输入,然后转换成字符,对位进行相加,祝你好运
;功能:进行三个大数的相加 最多可以输入(1——80位)
.model small
.386
.stack 400h
.data
first_add db 80,0,80 dup(0)
second_add db 80,0,80 dup(0)
third_add db 80,0,80 dup(0)
shuchu db 'The add result is:','$'
tishi db 'Please input the add1 number:','$'
tishi1 db 'Please input the add2 number:','$'
tishi2 db 'Please input the add3 number:','$'
;宏操作
input macro do
mov ah,2 ;置光标
mov bh,0
mov dl,12 ;列号
int 10h
mov dx,si
mov ah,9 ;显示字符串
int 21h
lea dx,do ;存放加数
mov ah,0ah ;暂停,任意键关闭
int 21h
pop si
endm
.CODE
START:
mov ax,@data
mov ds,ax
mov es,ax
lea si,tishi2
push si
lea si,tishi1
push si
lea si,tishi
push si
pop si
;进行屏幕的显示控制和提示进行输入的操作
mov dh,2 ;行号 控制行 在第 3 行显示
input first_add
mov dh,4
input second_add
mov dh,6
input third_add
;输出结果的提示信息
lea si,shuchu
mov ah,2 ;置光标
mov bh,0
mov dh,12 ;行号
mov dl,20 ;列号
int 10h
mov dx,si
mov ah,9 ;显示字符串
int 21h
;进行加法运算
;把第一个加数转换成字符
lea si,first_add
mov cx,[si+1]
and cx,000ffh
s1: mov al,[si+2]
sub al,30h
mov [si+2],al
inc si
loop s1
;把第二个加数转换成字符
lea di,second_add
mov cx,[di+1]
and cx,000ffh
s2: mov al,[di+2]
sub al,30h
mov [di+2],al
inc di
loop s2
;把第三个加数转换成字符
lea di,third_add
mov cx,[di+1]
and cx,000ffh
s3: mov al,[di+2]
sub al,30h
mov [di+2],al
inc di
loop s3
lea si,first_add
lea di,second_add
call jiashu ;函数调用进行相加
lea di,third_add
call jiashu ;函数调用进行相加
;把十进制数转换成ASICC码显示
mov cl,[si+1]
and cx,000ffh
ok2: mov dl,[si+2]
add dl,30h
mov ah,2
int 21h
inc si
loop ok2
mov ah,1 ;暂停,任意键关闭
int 21h
mov ah,4ch
int 21h
;函数调用进行加法运算
jiashu:
mov al,[si+1]
mov ah,[di+1]
cmp al,ah
ja ok1
mov ax,si
mov bx,di
xchg ax,bx
mov si,ax
mov di,bx
ok1: mov bx,[si+1]
and bx,000ffh ;屏蔽高8位
mov bp,[di+1]
and bp,000ffh ;屏蔽高8位
mov cx,[di+1]
and cx,000ffh ;屏蔽高8位
jia: mov al,[si+bx+1]
mov ah,ds:[di+bp+1]
add al,ah
cmp al,10
jb cf
dec bx
mov ah,[si+bx+1]
inc ah
mov [si+bx+1],ah
sub al,10
inc bx
cf: mov [si+bx+1],al
dec bx
dec bp
loop jia
ret
end start
不说话的都是高手!