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

📄 98_hzk_gb2312_2004.10.24.asm

📁 汇编语言 参考书 包含作业与答案 从入门到精通 通俗易懂
💻 ASM
字号:
		.model small
		.stack 100h
		.data
				file_cclib		db	'd:\dos\cclib\hzk16',0
				handle_cclib	dw	?							; CCLIB 文件句柄
				buffer_cclib 	db	32	DUP(?),'$'
				file_read		db	'd:\dos\cclib\test.txt',0
				handle_read		dw	?							;读取文件句柄
				buffer_read		dw	?
				char_offset		db	4	DUP(?),'$'
				print_buffer	db	3	DUP(?),'  $'
				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 cx,6h
		
;;;;;;;;;;;;
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
		
		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

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

		mov dx,buffer_read
		mov ah,2h
		INT 21h
		jmp	next
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 + -