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

📄 match.asm

📁 本程序用汇编语言实现
💻 ASM
字号:
.model small
.386
.stack 200h
.data
	string db 1024 dup(0)
	creat db 'Please input an article:',0ah,0dh,0ah,0dh,'$'
	result db 'The number of string(computer) is:',20h,'$'
	nothing db 'The string(computer) is not found!','$'
.code
main proc far
start:
	push ds
	sub ax,ax
	push ax
	mov ax,@data
	mov ds,ax
	call input
	call crlf
	call output
	call crlf
	call print
	ret
main endp

input proc near
	mov dx,offset creat
	mov ah,9
	int 21h
	mov bx,0
	lea si,string
newchar:	;输入字符串
	mov ah,1
	int 21h
	mov [si],al
	cmp al,24h
	je exit
	inc si
	inc bx		;使用寄存器BX传送参数
	jmp newchar
exit:
	ret
input endp

output proc near
	mov dx,bx
	mov bx,0
	lea si,string
a1:	
	cmp dx,7h
	jbe exit1		;所剩字符串长度小于8,比较结束
	mov al,[si]
	inc si	
	dec dx
	cmp al,63h
	je a2			
	jmp a1
a2:
	mov al,[si]
	inc si
	dec dx
	cmp al,6fh
	je a3
	dec si
	inc dx
	jmp a1
a3:
	mov al,[si]
	inc si
	dec dx
	cmp al,6dh
	je a4
	dec si
	inc dx
	jmp a1
a4:
	mov al,[si]
	inc si
	dec dx
	cmp al,70h
	je a5
	dec si
	inc dx
	jmp a1
a5:
	mov al,[si]
	inc si
	dec dx
	cmp al,75h
	je a6
	dec si
	inc dx
	jmp a1
a6:
	mov al,[si]
	inc si
	dec dx
	cmp al,74h
	je a7
	dec si
	inc dx
	jmp a1
a7:
	mov al,[si]
	inc si
	dec dx
	cmp al,65h
	je a8
	dec si
	inc dx
	jmp a1
a8:
	mov al,[si]
	inc si
	dec dx
	cmp al,72h
	je count
	dec si
	inc dx
	jmp a1
count:
	inc	bx		;找到一个相匹配的,计数器加1
	jmp a1
exit1:
	ret
output endp

print proc near
	cmp bx,0
	je exit2
	mov dx,offset result
	mov ah,9
	int 21h
	call binidec
	jmp exit3
exit2:
	mov dx,offset nothing
	mov ah,9
	int 21h
exit3:
	ret
print endp

binidec proc near
	mov  cx,10000d
	call dec_div
	mov  cx,1000d
	call dec_div
	mov  cx,100d
	call dec_div
	mov  cx,10d
	call dec_div
	mov  cx,1d
	call dec_div
	ret
	
dec_div 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
dec_div endp

binidec endp

crlf proc near
	mov dl,0dh
	mov ah,2
	int 21h
	mov dl,0ah
	mov ah,2
	int 21h
	ret
crlf endp

end start

⌨️ 快捷键说明

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