kprint ouput issue.[solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

kprint ouput issue.[solved]

Post by nekros »

So I started writing my kernel with the help of the bare bones tutorial. As a start I started to implement a basic kprint function, when I tested the "kernel" on my computer all it did was output a bunch of female symbols in lots of different colors but it was the same length of the string I had it print.
I am completely oblivious to what is wrong with my code, probably something obvious.

Code: Select all

char *texmem = (char *) 0xB8000;
char *cline = (char *) 0xB8000;
unsigned char color = 0x0C;

Code: Select all

void kprint(char *text)//prints a string to the screen
{
while(*text != '\0')
{
*texmem = color;
texmem++;
*texmem = *text;
texmem++;
text++;
}
}
I really don't get it. :?
Last edited by nekros on Sat Mar 08, 2008 8:46 pm, edited 1 time in total.
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

Sorry for not searching the forum earlier. I should have put the char first and the color next.
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

Code: Select all

unsigned short *texmem = (unsigned short *) 0xB8000;
unsigned short color = 0x0C;

void kprint(char *text)//prints a string to the screen
{
while(*text)
{
*texmem++ = *text++ | (color << 8);
}
}
Edit: You solved it while I was posting. :-P
Post Reply