80*25彩色字符模式显示缓冲区结构:
1.B8000H~BFFFFH共32KB空间,分8页,每页(4KB),一般情况下显示第0页内容
2.每行80字符,占160B空间,共25行。(共计4000B)
3.每个字单元的高位放字符属性,低位放ASCII 码值,共一字(2B)
字的属性的格式:
7 6 5 4 3 2 1 0 (bit) 含义 BL R G B I R G B 闪烁 背景 高亮 字体颜色 R:红色 G:绿色 B:蓝色
在屏幕每行前12字符位置打印hello world
ASSUME CS:T17,DS:DATA DATA SEGMENT DB 'HELLO WORLD!' DATA ENDS T17 SEGMENT START: MOV AX,DATA MOV DS,AX ;字符放入ds MOV CX,25 MOV AX,0B800H MOV ES,AX ;显示缓冲区段地址放入es MOV BP,0H S: MOV DX,CX MOV CX,12 MOV SI,0 MOV BX,0 S0: ;打印hellow world MOV AL,DS:[BX] MOV AH,02H MOV ES:[SI+00H+BP],AX ADD SI,2 INC BX LOOP S0 MOV CX,68 MOV SI,0 S1: ;其余部分黑色清屏 MOV AX,0 MOV ES:[SI+17H+BP],AX ADD SI,2 LOOP S1 ADD BP,0A0H MOV CX,DX LOOP S MOV AX,4C00H ;退出 INT 21H T17 ENDS END START
略微更改,实现清屏效果
ASSUME CS:T17 T17 SEGMENT START: MOV CX,25 MOV AX,0B800H MOV ES,AX MOV BP,0H S: MOV DX,CX MOV CX,80 MOV SI,0 S1: MOV AX,0 MOV ES:[SI+00H+BP],AX ADD SI,2 LOOP S1 ADD BP,0A0H MOV CX,DX LOOP S MOV AX,4C00H INT 21H T17 ENDS END START