String defined outside function equals to null
Posted: Sun Jan 11, 2015 2:47 pm
Hello. I've been learning about interrupt descriptor table and when I wanted to define string array which contained all exceptions I've encountered weird problem. If I define string array inside function, so I can print it on the screen, but if I define array outside function it prints only 'S' character. I've checked random string (from the array) length and it was zero. This happens even with simple string, not only with the string array, except with simple string it doesn't prints anything unlike string array.
This way it works (I used simple string in this example to make it shorter):
And this way it's not working, if I print string from array I get only 'S' char, and with this string I get nothing.
Here's how monitor_print looks like:
Why is this happening?
This way it works (I used simple string in this example to make it shorter):
Code: Select all
void kmain()
{
char string[] = "Hello World!";
monitor_print(string);
}
Code: Select all
char string[] = "Hello World!";
void kmain()
{
monitor_print(string);
}
Code: Select all
void monitor_print(unsigned char* message)
{
int i;
for(i = 0; i < strlen(message); i++){
monitor_print_char(message[i]);
}
}
void monitor_print_char(unsigned char c)
{
unsigned short* where;
unsigned attr = attribute << 8;
where = vid_mem_ptr + (cursor_y * 80 + cursor_x); //vid_mem_ptr = (unsigned short*)0xb8000
*where = c | attr;
cursor_x++;
if(cursor_x >= 80){
cursor_x = 0;
cursor_y++;
}
monitor_scroll();
monitor_move_cursor();
}