⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 键盘输入两数求和并输出.asm

📁 该软件包中包括了比较经典了几个汇编程序
💻 ASM
字号:
data segment
Msg1 db "please input two separate numbers :",0ah,0dh,'$'
Msg2 db 0ah,0dh,"the sum is : ",0ah,0dh,'$'
Msg3 db 0ah,0dh,'$'
num1 dw ?
num2 dw ?
sum dw ?
data ends

stack segment para stack
db 20h dup(?)
stack ends

code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
lea dx,Msg1
mov ah,09h
int 21h
call input
mov num1,bx
lea dx,Msg3
mov ah,09h
int 21h
call input
mov num2,bx
mov ax,num1
add ax,num2
mov sum,ax
lea dx,Msg2
mov ah,09h
int 21h
mov ax,sum
call output
exit:
mov ah,4ch
int 21h

;----------------------------input
input proc
push cx
push ax
push dx
xor bx,bx
xor cx,cx
execute:
mov ah,01h
int 21h
mov cl,10
cmp al,0dh
jz exit1
sub al,30h
mov dl,al
mov ax,bx
mul cl
mov bx,ax
add bx,dx
jmp execute
exit1:
pop dx
pop ax
pop cx
ret 
input endp
;-----------------------------output
output proc
push ax
push dx
push si
;mov ax,Binnum
mov dx,0
mov si,10   ;si为16位
push si      ;显示结束标志为10
div si
.while ax!=0	      ;求出二进制数对应的十进制数各位的代码
add dl,30H
push dx
mov dx,0
div si
.endw
add dl,30h
push dx
pop dx
.while dx!=10	 ;显示十进制数的所有位
mov ah,2
int 21h
pop dx
.endw
pop si
pop dx
pop ax
ret
output endp


code ends
end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -