logo资料库

如何用汇编语言实现汉字显示编程.doc

第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
资料共4页,全文预览结束
如何用汇编语言实现汉字显示编程 2008 年 05 月 21 日 星期三 15:55 概述: 一般在屏幕上显示汉字的时候需要汉字系统的支持,但需要自己显示 汉字的时候,就需要自己读汉字字库文件,把字符点阵读出来,再用绘图的办法 显示到屏幕上,本文是读 UCDOS 16 点字库文件的示例。 在 UCDOS 的点阵字库 HZK16 中,字符点阵是按照汉字内码排列的,汉 字的内码从一些图形字符开始,起始编码为 A1A1H,汉字内码第一位为区码,每 区为 94 个汉字,第二位为每区内的编码,每个汉字的点阵为 16 点*16 点 共 32 字节,数据按第一行 1-8 点,9-16 点,第二行 1-8 点,9-16 点...排列,每 位数据 1 为要显示点,0 为不显示点。汉字点阵数据在字库中的偏移量为 ((区 码-A1H)*94 + (区内编码-A1H))*32。 本程序为一个简单的例子,要显示的汉字在变量 DISP_DATA 中,且没有 考虑汉字、英文混用的情况。 源程序: .286 LINE_CHAR EQU 210 ;在屏幕上第几行显示 COL_CHAR EQU 230 ;在屏幕上第几列显示 COLOR_CHAR EQU 0EH ;显示颜色 CHARS CODE SEGMENT EQU (offset disp_data_end-offset disp_data)/2 ASSUME CS:CODE,DS:CODE ORG 100H START: jmp install DB 'C:\UCDOS\HZK16',0 ;字库文件名,用 UCDOS 的 16 点阵汉字库 DW ? ;file handle CC_FILE HANDLE DISP_DATA DB '罗云彬' DISP_DATA_END EQU THIS BYTE D_OPEN_ERROR DB 'File C:\UCDOS\HZK16 not found !',0dh,0ah,24h install: ;要显示的汉字 ;打开汉字库 mov ax,3d00h mov dx,offset cc_file int 21h jnb open_ok mov ah,9 mov dx,offset d_open_error int 21h int 20h open_ok: mov handle,ax
mov si,offset disp_data mov di,offset zi_buffer mov cx,chars cld ins2: lodsb mov ah,al lodsb call get_dots ;读出汉字点针 loop ins2 call disp_cc ;显示到屏幕 int 20h GET_DOTS PROC pusha sub ax,0a1a1h ;汉字的内码从 A1 区开始 ;所以绝对开始区是内码-A1 ;点阵在字库中的位置为 ;((汉字码 1-A1)* 94 + 汉字码 2 - A1)* 32 cwd mov dl,al mov al,ah cbw mov bl,94 mul bl add ax,dx mov bx,32 mul bx mov cx,dx mov dx,ax mov ax,4200h ;移动读写指针到点阵数据位置 mov bx,handle int 21h mov ah,3fh mov cx,32 mov dx,di int 21h popa add di,32 ret GET_DOTS ENDP DISP_CC PROC mov ax,12h ;640*480 mode int 10h ;设置 640*480/16 色显示模式 mov cx,chars mov si,offset zi_buffer mov bx,col_char-20 ;BX = column dh_lop0:
add bx,20 push cx mov cx,16 ;every char column+20 ;l6 lines/char mov dx,line_char ;DX = start line dh_lop1: push bx push cx lodsb ;16 dots/line mov ah,al lodsb mov cx,16 dh_lop2: shl ax,1 push ax push bx push cx jc db_color xor al,al jmp short db_draw ;back color is 0 db_color: mov al,color_char db_draw: mov ah,0ch mov cx,bx xor bh,bh int 10h pop cx pop bx pop ax inc bx loop dh_lop2 ;inc column inc dx ;next line pop cx pop bx loop dh_lop1 pop cx loop dh_lop0 xor ah,ah int 16h mov ax,3 int 10h ret DISP_CC ZI_BUFFER EQU THIS BYTE ENDP
ENDS CODE END START
分享到:
收藏