some thing about printing string
Posted: Thu Jan 12, 2012 7:57 pm
I'm the beginner or OSdev
but i having a problem in kernel in C language.
while my kernel is type as above, it will show this output
but while i add the same code with copying kprint("First prototype - Sebastian Ko \n\nDate: 12/01/2012\n"); twice next to the same sentence.
the output will becomes this Can any people help me ??
the Method of kprint and kprintc
but i having a problem in kernel in C language.
Code: Select all
int k_main(void)
{
kclrscr();
kprint("Protected Mode process ...\n");
kprint("First prototype - Sebastian Ko \n\nDate: 12/01/2012\n");
kprintc("\nNO \\t or value type \n",GRAY_TXT);
kprint("Register checking ... ");
if(reg() == 0)kprintc("OK\n",GRAY_TXT);
else kprintc("Fail\n",GRAY_TXT);
return 0;
}
the output will becomes this Can any people help me ??
the Method of kprint and kprintc
Code: Select all
unsigned int line = 0; //Line in screen (Text)
unsigned int text_pos = 0; //Text position
//Easiest print method
void kprint(char *message){kprintc(message,0x0B);};
void kprintc(char *message,double text_color) //Print with change default color
{
char *vidmem = (char *) 0xb8000; //define video memory
unsigned int i = 0; //define memory position
i=((line*80*2)+(text_pos*2)); //Memory MUST be line * colume * TxtSpace (160 Means Over Screen of line,line++)
while(*message!=0)
{
if(line > CONSOLE_MAX_LINE)line = 0;
//\n \r \t is 1 char
if(*message == '\n') //Check for a new line
{
text_pos = 0; //reset text position
line++;
i=(line*80*2);
*message++;
}else if(*message == '\r'){ //Return to head from line
text_pos = 0; //reset text position
i = (line*80*2);
*message++;
}else{ //print Message (Char)
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=text_color;
i++;
text_pos++;
}
}
};