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

📄 match.asm

📁 试编写一程序
💻 ASM
字号:
;程序模板

SSEG SEGMENT PARA STACK 'stack'
	dw 100h dup(0) ;初始化堆栈大小为100
SSEG ENDS

DSEG SEGMENT
	;数据段:在此处添加程序所需的数据
	string1 db 20,?,20 dup(?)
	string2 db 20,?,20 dup(?)
	output  db 'input a string:$'
	mat      db 'Match$'
	nomat  db 'No match$'
	quit db "press any key to exit......",13,10,'$'
DSEG ENDS

ESEG SEGMENT
	;附加段:在此处添加程序所需的数据
ESEG ENDS

CSEG SEGMENT
	assume  cs:CSEG, ds:DSEG, es:ESEG, ss:SSEG


	
MAIN PROC   	;主程序入口

	mov ax, dseg
	mov ds, ax
	mov es, ax

	
	;此处添加主程序代码
	;提示输入
	mov dx,offset output
	mov ah,09h
	int 21h

	call p
	;接受字符串
	mov dx,offset string1
	mov ah,0ah
	int 21h
	mov di,dx

	call p
	;提示输入
	mov dx,offset output
	mov ah,09h
	int 21h

	call p
	;接受字符串
	mov dx,offset string2
	mov ah,0ah
	int 21h
	mov si,dx

	call p
	;进行比较
	cld
	mov cx,22
	repe cmpsb
	;test cx,80
	jz   match	

	;不相等输出
	mov dx,offset nomat
	mov ah,09h
	int 21h
	mov ah,07h
	int 21h
	jmp next
	;相等输出
match:     mov dx,offset mat
	mov ah,09h
	int 21h

next:       	call p
	;提示按任意键退出
	 mov ah,9
    	lea dx,quit
    	int 21h
	mov ah,01h
	int 21h

	mov ax, 4c00h  ;程序结束,返回到操作系统系统
	int 21h

MAIN ENDP

p	proc		;输出回车换行的子程序
	mov dl,0dh
	mov ah,2
	int 21h
	mov dl,0ah
	mov ah,2
	int 21h
	ret
p	endp
CSEG ENDS

END MAIN

⌨️ 快捷键说明

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