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

📄 shiyan.asm

📁 综合实验设计
💻 ASM
字号:
assume cs:code,ss:stack

data segment
	d1	db 'Please input 1--6 decimal numbers:',13,10,'$'
	n1	db 9 dup('*')
	n2	db 9 dup('#')
	b1	db 6 dup(0)
	b2	db 6 dup(0)
	ans	db 7 dup(0),'$'
data ends

stack segment
	db 16 dup(0)
stack ends

code segment
s:	mov ax,data
	mov ds,ax
	mov ax,stack
	mov ss,ax
	mov sp,32
	
	mov ax,offset d1
	push ax
	mov ax,offset n1
	push ax
	call input
	
	mov ax,offset d1
	push ax
	mov ax,offset n2
	push ax
	call input
	
	call plus
	
	call print
	
	mov ax,4c00h
	int 21h
input:
	mov bp,sp
	mov ah,9h
	mov dx,[bp+4]
	int 21h
	
	mov ah,0ah
	mov dx,[bp+2]
	int 21h
	mov bx,dx
	inc bx
	add bx,[bx]
	inc bx
	mov bh,0
	mov byte ptr [bx],'$'
	
	mov ah,2h
	call ctrl
	
	ret
plus:
	mov bx,offset n1
	inc bx
	mov cx,[bx]
	mov ch,0
	lea si,[bx+6]
	add si,cx
	sub si,6
	mov ax,ds
	mov es,ax
	mov di,offset b1
	add di,offset b2 - offset b1 - 1
	std
	rep movsb
	
	mov bx,offset n2
	inc bx
	mov cx,[bx]
	mov ch,0
	lea si,[bx+6]
	add si,cx
	sub si,6
	mov ax,ds
	mov es,ax
	mov di,offset b2
	add di,offset ans - offset b2 - 1
	std
	rep movsb
	
	mov cx,6
	mov bx,offset ans
	add bx,6
	mov si,offset b2 - 1
	mov di,offset ans - 1 
	clc
	mov ah,0
s0:	mov al,[si]
	cmp al,30h
	jnb a1
	add al,30h
a1:	add	al,[di]
	cmp al,60h
	jnb a2
	add al,30h
a2:	add al,ah
	cmp al,6ah
	jb s2
	sub al,10
	mov ah,1
	jmp s3
s2:	mov ah,0	
s3:	mov [bx],al
	sub byte ptr [bx],30h
	dec si
	dec di
	dec bx
	loop s0
	
	mov byte ptr [bx],30h
	add [bx],ah
	ret
print:
	mov ah,2h
	mov dl,20h
	int 21h
	
	mov cx,6
	mov bx,offset b1
s5:	cmp byte ptr [bx],0
	jz s6
	mov dl,[bx]
	int 21h
	jmp s7
s6:	mov dl,20h
	int 21h
s7:	inc bx
	loop s5
	
	call ctrl
	
	mov ah,2h
	mov dl,'+'
	int 21h
	
	mov cx,6
	mov bx,offset b2
s8:	cmp byte ptr [bx],0
	jz s9
	mov dl,[bx]
	int 21h
	jmp s10
s9:	mov dl,20h
	int 21h
s10:inc bx
	loop s8
	
	call ctrl
	
	mov cx,7
s1:	mov dl,'-'
	int 21h
	loop s1
	
	call ctrl
	
	mov cx,7
	mov bx,offset ans
	mov dh,0
s11:cmp byte ptr [bx],'0'
	jz s12
s14:mov dh,1
	mov dl,[bx]
	int 21h
	jmp s13
s12:cmp dh,0
	jnz s14
	mov dl,20h
	int 21h
s13:inc bx
	loop s11
	
	call ctrl
		
	ret
ctrl:
	mov ah,02h
	mov dl,0dh
	int 21h
	mov dl,0ah
	int 21h
	ret
code ends
end s

⌨️ 快捷键说明

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