Sunday, 8 September 2013

BIOS Video memory interaction position calculation weirdly

BIOS Video memory interaction position calculation weirdly

I have written a very simple kernel that loads inside QEMU with the help
of GRUB. I probably have a problem in pointer calculation, but cannot
really figure out what is wrong.
The following code works as expected, it prints the given character.
char* video = 0xb8000 + 0;
char* color = 'A';
*video++ = c;
*video++ = color;
However when I change the video pointer calculation to this it does not
work, nothing appears on screen:
int pos = 0;
char* video = 0xb8000 + pos;
But when I make the pos variable unsigned int, it works uncorrectly, but
when I make it 1, it works as the first one, but why it needs to be 1?
unsigned int pos = 1;
char* video = 0xb8000 + pos;
My C flags: CFLAGS = -std=c99 -pedantic -Wall -nostdlib -ffreestanding -g

No comments:

Post a Comment