I am very new to C, this is my second high level programming language after Java. I have lost most of the basics, but for some reason I cannot write a single character to display memory.
This program was compiled using Turbo C for DOS on the Am486-DX4-100 with a frequency of 120 MHz. The graphics card is a standard VLB Diamond Multimedia Stealth SE using the Trio32 chip.
For OS, I run PC-DOS 2000 with the ISO codepage loaded. I work in standard text mode in MDA / CGA / EGA / VGA 80 format with color.
Here is the program as I wrote it:
#include <stdio.h> int main(void) { unsigned short int *Video = (unsigned short int *)0xB8000; *Video = 0x0402; getchar(); return 0; }
As I said, I am very new to C, so I apologize if my mistake seems obvious, I could not find a reliable source of how to do this, that I could understand.
As far as I know, in real mode on x86 platform, screen memory for text mode starts with 0xB8000. Each character is stored in two bytes, one for the character and one for the background / foreground. The idea is to write the value 0x0402 (which should be a red smiling face) to 0xB8000. This should put it in the upper left corner of the screen.
I took into account the possibility of scrolling the screen and thus immediately deleting my character when performing in two ways. To solve this problem, I tried:
- Record this value with a loop
- Write a little further.
I can read and print the value that I wrote in memory, so it is obviously still somewhere in the memory, but for some reason I am not getting anything on the screen. I'm obviously doing something wrong, but I don't know what the problem is. If you need any other information, please ask. Thanks for any help you can give.
c x86 real-mode turbo-c
Ampera Dec 01 '17 at 7:23 2017-12-01 07:23
source share