【12】操作系统编写一 の dos环境下,显示彩色字体

/*  Hello.c  */

/***************************************
*  向视频缓冲区显示字符                *
***************************************/
#define VIDEO_BUF_ADDR 0xB8000000
#define RED_COLOR      4

void ShowString(char *pstr,int color)
{
    /*视频缓冲区首地址B800:0000 =>0B8000h  20位地址*/
    char  far *pVideoBuf = VIDEO_BUF_ADDR;
    while ( *pstr ){
        *pVideoBuf = *pstr;   // 十六位下 通过两个自己显示字符,第一个是字符,第二个负责颜色
*(pVideoBuf+1) = color; pstr++; pVideoBuf++; pVideoBuf++; } } void main(){ ShowString("Hello World!", RED_COLOR); }

先通过winTC编译一下,放置到dos下。

在dos环境下,运行hello.exe,将会看到红色的字体

 

ps:关于该功能,可以参考王爽《汇编语言》第9章 实验9

 

 

posted @ 2013-01-16 16:05  xiaolongxia  阅读(186)  评论(0)    收藏  举报