写0xb8000000产生在屏幕上输出没有任何打印语句,如`printf` [英] Writing to 0xb8000000 yields output on screen without any print statements such as `printf`

查看:421
本文介绍了写0xb8000000产生在屏幕上输出没有任何打印语句,如`printf`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>
#include <conio.h>

void main()
{
  char far *v = (char far*)0xb8000000;
  clrscr();

  *v = 'w';
  v += 2;
  *v = 'e';

  getch();
}

输出为:我们

我不明白输出是如何得到打印不带任何的printf 或其它打印报表。

I don't get how the output is getting printed without any printf or other print statements.

推荐答案

这是一个86的实模式 IBM PC假定CGA / EGA / VGA兼容图形适配器在映射彩色文本模式程序默认存储位置(B800:0000);它基本上是从MS-DOS(1980/1990)的时代。在任何情况下,它是很老同学!

This is a x86 real-mode IBM PC program that assumes CGA/EGA/VGA compatible graphics adapter in color text mode mapped at the default memory location (B800:0000); it is basically from the era of MS-DOS (1980s/1990s). In any case it's very old school!

char far *v=(char far*)0xb8000000;

视频缓冲存储器地址(在实模式)(使用 0xb0000000 ,如果你有一个旧的大力神)

Memory address (in real mode) of the video buffer (use 0xb0000000 if you have an old Hercules)

clrscr();

清除屏幕

*v='w';

写在一行 0 ,列 0 字符是W

v+=2;

跳过 2字节(以字符模式缓冲区交错: 1个字节的性格和 1个字节的颜色。 1位的闪烁, 3位为背景的 0-7 4位对于前景的 0-15 的,装在这种方式:前景+ 16 *背景+ 128,如果你想闪烁

Skips 2 bytes (in the character mode the buffer is interleaved: 1 byte for the character and 1 byte for the color. 1 bit for the flashing, 3 bits for the background 0-7 and 4 bits for the foreground 0-15, packed in this way: foreground + 16 * background + 128 if you want flashing)

*v='e';

写在一行 0 ,列 1 字符电子

getch();

等待键

现在一个关于 CGA文本模式格式,对于那些FEEL知道的需要老一代是怎么做到的,视窗来之前(甚至之前所有的Linux来了:-))。啊......和另一个链接(维基这段时间)对于那些仍然不知道什么实模式是。

Now a link about the CGA Text Mode Format, for those that FEEL the need of knowing how the "old generation" did it, before "Windows" came (and even before all that "Linux" came :-) ). Ah... and another link (a wiki this time) for those that still don't know what REAL-MODE is.

这篇关于写0xb8000000产生在屏幕上输出没有任何打印语句,如`printf`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆