(汇编)键盘输入两个5位数,将其相加并显示结果

两个5位数加法
输入的数字x,0

11111+11111=22222
两个5位数加法
99999+99999=199998
在这里插入图片描述

code segment
     assume cs:code
main proc far
start:
     mov ax,cs
     mov ds,ax
	 
     mov bx,0
     mov cx,10
	 
   s:mov ah,1
	 int 21h
	 sub al,30h
	 mov [bx],al
	 inc bx
	 loop s
	 
	 mov cx,4
	 mov bx,4
	 mov dx,0
  s1:mov ax,0
     mov dh,[bx+5]
     add [bx],dh
	 mov dh,[bx]
	 cmp dh,10
	 jb  aws
	 sub dh,0ah
	 mov [bx],dh
	 mov ax,1

aws: sub bx,1
     add [bx],ax
     loop s1
	 
bws: mov dh,[bx+5]
     add [bx],dh
	 mov dh,[bx]
	 cmp dh,10
	 jb dws
	 
cws: mov dl,'1'
     mov ah,2
	 int 21h
	 sub dh,0ah
     mov [bx],dh	 
	 
dws: mov cx,5
     mov bx,0
	 mov dx,0
 s2: mov dl,ds:[bx]
     add dl,30h
	 mov ah,2
	 int 21h
	 inc bx
	 loop s2
	  
exit:mov ah,4ch
     int 21h
main endp
code ends
     end start  

最近开始学习汇编,做做笔记.

如有错误,欢迎指正!(有帮助的话,点个赞哟!)

你可能感兴趣的:(汇编与接口技术)