kprint won't dereference strings properly
Posted: Sun May 30, 2010 11:43 am
I just finished making a bootloader that loads up a simple kernel with a kprint function. However, the kprint function doesn't print the string I feed to it in any predictable manner. Sometimes it prints the same thing no matter what I load and sometimes it prints different things. It tries printing a random collection of symbols and characters.
I've tested everything else, including passing ascii integer pointers to a function and those work fine. The problem seems to be with the char*. Any help would be greatly appreciated because this is going to make me explode.
I find it hard to believe that the problem is in the C since it's so simple, but everything else works. Thanks.
Link to the very simple bootloader, just in case the problem is in there: http://codepad.org/uq7fHlvm
And the start.asm is the one on the wiki nearly verbatim: http://codepad.org/x0rtZnsm
I've tested everything else, including passing ascii integer pointers to a function and those work fine. The problem seems to be with the char*. Any help would be greatly appreciated because this is going to make me explode.
Code: Select all
//Simplified into kmain for clear testing
void kmain()
{
char* str = "test";
unsigned char* vmem = (unsigned char*)0xb8000;
int i=0;
while(i < 8)
{
vmem[i] = *str;
vmem[i+1] = 0x07;
str++;
i+=2;
}
}
Link to the very simple bootloader, just in case the problem is in there: http://codepad.org/uq7fHlvm
And the start.asm is the one on the wiki nearly verbatim: http://codepad.org/x0rtZnsm