putchar problem
Posted: Fri Jan 10, 2003 7:20 am
I've wrote a printf function and it works really strange. On Bochs it prints everything nice and on my 486sx it prints nice, but on my duron 650 mhz when it wants to print the computer resets. I think that the problem is with the putchar function. Here is the code:
void putchar(char c)
{
unsigned att;
att= 0x02 << 8;
if ( c == 0x08 )
{
if ( curX != 0 )
curX--;
else if ( curX == 0 && curY > 0 )
{
curY--;
curX = scrwidth - 1;
update_cursor();
return;
}
}
else if ( c == 0x09 )
{
curX += 4;
}
else if ( c == '\r' )
{
curX = 0;
}
else if ( c == '\n' )
{
curX = 0;
curY++;
}
else if ( c >= ' ' )
{
unsigned short *where;
where = vgaadr + ( curY * scrwidth + curX );
*where = c | att;
curX++;
}
if ( curX >= scrwidth )
{
curX = 0;
curY++;
}
update_cursor();
}
void putchar(char c)
{
unsigned att;
att= 0x02 << 8;
if ( c == 0x08 )
{
if ( curX != 0 )
curX--;
else if ( curX == 0 && curY > 0 )
{
curY--;
curX = scrwidth - 1;
update_cursor();
return;
}
}
else if ( c == 0x09 )
{
curX += 4;
}
else if ( c == '\r' )
{
curX = 0;
}
else if ( c == '\n' )
{
curX = 0;
curY++;
}
else if ( c >= ' ' )
{
unsigned short *where;
where = vgaadr + ( curY * scrwidth + curX );
*where = c | att;
curX++;
}
if ( curX >= scrwidth )
{
curX = 0;
curY++;
}
update_cursor();
}