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

📄 98_hzk_gb2312_v0.2.asm

📁 汇编语言 参考书 包含作业与答案 从入门到精通 通俗易懂
💻 ASM
字号:
		.model small
		.stack 100h
		.data
				file_cclib	db	'hzk16',0
				handle_cclib	dw	?							; CCLIB 文件句柄
				buffer_cclib 	db	32	DUP(?),'$'
				file_read	db	'test.txt',0
				handle_read	dw	?							;读取文件句柄
				buffer_read	dw	?
				char_offset	db	4	DUP(?),'$'
				print_buffer	db	3	DUP(?),'  $'
				linex		dw	?
				linex_pre	db	?
				liney		dw	?
				liney_pre	db	?
				msg_open_error	db	'File open wrong!','$'
				msg_read_error	db	'File read wrong!','$'
				
		.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main	proc	far

		mov	ax,@data
		mov	ds,ax
;;;;;;;;;;;;;;		
open_file:

		lea	dx,file_read		;打开所读文件
		mov	al,0
		mov ah,3dh
		INT 21h
		jc	open_error
		mov	handle_read,ax
		
		lea dx,file_cclib		;打开CCLIB
		mov al,0
		mov ah,3dh
		INT 21h
		jc	open_error
		mov handle_cclib,ax
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
	mov	bh,0h		;读当前光标的位置
	mov	ah,3h
	INT	10h
	
	mov	ax,16
	;inc	dh
	mul	dh
	mov	linex,ax		
	mov	ax,16
	mul	dl
	mov	liney,ax
	
	;mov	ah,0fh
	;INT	10h
	mov	al,12h
	mov	ah,0h
	INT	10h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   用来循环

		;mov cx,0eeeh
		
;;;;;;;;;;;;
getword_file:						;从文件中读取两个字节

		;push cx
		
		mov	bx,handle_read
		mov	cx,0
		mov	dx,0h
		mov	al,1
		mov ah,42h
		INT 21h
		
		mov bx,handle_read
		mov cx,1
		lea dx,buffer_read
		mov ah,3fh
		INT 21h
		jc	read_error
		test	ax,0ffffh		;测试文件是否结束
		jz	done
		
		mov ax,buffer_read
		cmp	al,0a0h
		jb	print_ansi_char
		
		mov	bx,handle_read
		mov cx,1
		lea	dx,buffer_read+1
		mov ah,3fh
		INT 21h
		jc	read_error
		
;;;;;;;;;;;
count_offset:						;计算在CCLIB中的偏移量   qh=c1-0xa0 wh=c2-0xa0 
									;该汉字在字库中离起点的位置是: offset=(94*(qh-1)+(wh-1))*32L

		mov bx,buffer_read
		sub	bh,0a0h
		sub bl,0a0h
		dec bh
		dec bl
		
		xor ax,ax
		mov	al,bl
		mov cl,94					;此时不会溢出
		mul	cl
		
		xor cx,cx
		mov	cl,bh
		add ax,cx
		mov cx,32
		mul cx
		;mov buffer_read,ax				;结果保存在DX+AX中,可再写入buffer_read
		
;;;;;;;;;;		
read_cclib:							;从CCLIB中读入16*16的点阵,32个字节

		mov	bx,handle_cclib
		mov	cx,dx
		mov	dx,ax
		mov	al,0
		mov ah,42h
		INT 21h
		
		mov	bx,handle_cclib
		mov cx,32
		lea	dx,buffer_cclib
		mov ah,3fh
		INT 21h		
		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printall:

		lea		si,offset buffer_cclib
		mov		cx,32
		
printone:


	
		inc	si
		loop	printone

;;;;;;;;;;;;;;;;;;;					;输出汉字
				
		
	
	mov	dx,linex		;设置X轴的坐标
	mov	cx,16
	lea	si,buffer_cclib
writex:
	push	cx
	mov	bx,liney		;设置Y轴的坐标
	
	mov	cx,8
	mov	ah,[si]
writey:
	shl	ah,1
	jc	iszero
	xor	al,al
	jmp	goon
iszero:
	mov	al,7h
goon:
	push	ax
	mov	ah,0ch
	xchg	cx,bx
	push	bx
	xor	bx,bx
	INT	10h
	pop	bx
	xchg	cx,bx	
	pop	ax
	
	inc	bx
	loop	writey
	



inc	si
	mov	cx,8
	mov	ah,[si]
writey2:
	shl	ah,1
	jc	iszero2
	xor	al,al
	jmp	goon2
iszero2:
	mov	al,7h
goon2:
	push	ax
	mov	ah,0ch
	xchg	cx,bx
	push	bx
	xor	bx,bx
	INT	10h
	pop	bx
	xchg	cx,bx	
	pop	ax
	
	inc	bx
	loop	writey2
	;;;;;;;;;;;;;;;;


	pop	cx
	inc	dx
	inc	si
	loop	writex	


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		上滚行
change:
	cmp	linex,480
	jz	reset_x
	jmp	changerow
	
reset_x:
	mov	al,1
	mov	ah,6h
	xor	cx,cx
	mov	dh,30
	mov	dl,80
	mov	bh,0
	INT	10h
	
	sub	linex,16
	
	

	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;换行
changerow:
	cmp	liney,624
	jz	reset_y
	add	liney,16
	jmp	next
		
reset_y:
	mov	liney,0h
	add	linex,16
	



;;;;;;;;;;;;;;;;;;;;;;;;;				;开始读第二个字
next:
		jmp getword_file
;		loop	getword_file			;为什么用LOOP提示超出NEAR的范围,如何解决???

		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
		
print_ansi_char:

		mov dx,buffer_read
		cmp	dl,10
		jz	needchangeline
		jmp	gogogo
needchangeline:
		mov	liney,0
		add	linex,16
		jmp	change
		
gogogo:
	mov	bl,16
	mov	ax,linex
	cmp	ax,0
	jz	cannotdiv_x
	div	bl
	mov	dh,al
	jmp	get_y
cannotdiv_x:
	mov	dh,0

get_y:
	mov	ax,liney
	cmp	ax,0
	jz	cannotdiv_y
	mov	bl,8
	div	bl
	mov	dl,al
	jmp	positionisok
cannotdiv_y:
	mov	dl,0
	
positionisok:
	mov	ah,2h
	INT	10h
	;mov	ax,buffer_read
	;mov	ah,0eh
	;mov	bl,0
	;int	10h

		mov dx,buffer_read
		mov ah,2h
		INT 21h
	;sub	liney,8
	;mov dx,20h
	;mov ah,2h
	;INT 21h
		jmp	change
open_error:
		lea	dx,msg_open_error
		mov	ah,9h
		INT	21h
		jmp	done
read_error:
		lea	dx,msg_read_error
		mov ah,9h
		INT 21h
		jmp done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
done:
		mov ah,4ch
		INT 21h
		
main	ENDP
END	main					

⌨️ 快捷键说明

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