I'm getting started to OSDev'ing, so I read some articles on the wiki and followed the Barebones for C. So I wrote a function to print a character:
Code: Select all
uint16_t _attrib = 0x09;
void kwrite_char(char ch, uint16_t offset)
{
volatile uint16_t *where;
where = (uint16_t*)(0xB8000 + offset*2);
*where = ch | (_attrib << 8);
}
Everything ok, it prints anything I want, so I also wrote a function to print strings:
Code: Select all
void kwrite_string(char* st, uint16_t offset) //newlines wont work
{
while((*st)!=0) {
kwrite_char((*st), offset++);
st++;
}
}
So I used it. Now if I use this function, everything I printed gets blank, even if i printed it with the first function, before or after this. So:
Code: Select all
kwrite_char('H',81);
kwrite_char('e',82);
kwrite_char('l',83);
//kwrite_string("This is an OS. Or not", 320);
kwrite_char('l',84);
kwrite_char('o',85);
When I leave that as a comment, I see a normal purple 'Hello' on my screen. If I uncomment it, I see black (background color) space where it should be the two messages, whether before ('Hel') or after it ('lo'), or even itself ('This is an OS. Or not').
I'm not sure if I was clear (sorry for the bad English, I'm brazilian), but that scares me.