| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1122 人关注过本帖
标题:实现至简单print函数.
只看楼主 加入收藏
取消关键字高亮
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
结帖率:78.95%
收藏
 问题点数:0 回复次数:7 
实现至简单print函数.
编译环境:borland c++ 3.1
图片附件: 游客没有浏览图片的权限,请 登录注册

运行效果:
图片附件: 游客没有浏览图片的权限,请 登录注册

原理:视频缓冲区从0xB8000000开始,每个缓冲区占两个字节.第一个字节单元存储是ascii码,第二个则存储颜色值.
程序代码:
#define BLACK        0  //黑色
#define BLUE         1  //蓝色
#define GREEN        2  //绿色
#define CYAN         3  //青色
#define Red          4  //红色
#define MAGENTA      5  //洋红色
#define BROWN        6  //褐色
#define LIGHTGRAY    7  //高亮灰色
#define DARKGRAY     8  //灰色
#define LIGHTBLUE    9  //高亮蓝色
#define LIGHTGREEN   10 //高亮绿色
#define LIGHTCYAN    11 //高亮青色
#define LIGHTRED     12 //高亮红色
#define LIGHTMAGENTA 13 //高亮洋红色
#define YELLOW       14 //黄色
#define WHITE        15 //白色
#define BLINK        16 
void print(char* String,int Color)
{
    char far* screen_address=(char far*)0xB8000000;
    while(*String)
    {
        *screen_address=*String;
        screen_address++;
        *screen_address=Color;
        String++;
        screen_address++
    }
}
int main(void)
{
    print("hello world",GREEN);
    return 0;
}
搜索更多相关主题的帖子: print 函数 
2008-06-21 15:13
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
用int 0x10也可以实现的 不需要用直接写内存的。。。

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-06-21 15:21
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
就是不想用中断调用...

/images/2011/147787/2011051411021524.jpg" border="0" />
2008-06-21 15:23
爱喝牛奶的猫咪
Rank: 1
来 自:QQ群46520219
等 级:禁止访问
帖 子:513
专家分:0
注 册:2008-6-16
收藏
得分:0 
居然是BC



" border="0" />[color=white]
2008-06-21 15:33
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
BC有问题么...

/images/2011/147787/2011051411021524.jpg" border="0" />
2008-06-21 16:51
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
far指针。。有点搞不清楚的样子啊。。

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-06-21 21:42
lingluoz
Rank: 2
来 自:苏州科技学院
等 级:新手上路
威 望:4
帖 子:749
专家分:0
注 册:2008-2-2
收藏
得分:0 
far指针应该是20位的啊。。为什么这里是32位呢。。

Murphy's Law :
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
2008-06-21 22:30
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:0 
32位。16位段内偏移,后面紧跟16位段地址、

专心编程………
飞燕算法初级群:3996098
我的Blog
2008-06-22 00:03
快速回复:实现至简单print函数.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017243 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved