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;
Memory address (in real mode) of the video buffer (use 0xb0000000
if you have an old Hercules)
clrscr();
Clears the screen
*v='w';
Writes at row 0
, column 0
the character w
v+=2;
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';
Writes at row 0
, column 1
the character e
getch();
Waits for a key
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…