Page 1 of 1
very strange thing with vidmem
Posted: Thu Oct 16, 2003 1:51 pm
by questionmark
I'm just trying to write a character to the screen but it doesn't seem to work.
Code: Select all
void somefunc()
{
char str[] = "foo";
putch(str[0])
}
void putch(char c)
{
char* vidmem = (char*)0xB8000;
vidmem[0] = c;
vidmem[1] = GREEN_ON_BLUE;
return;
}
That doesn't work. It just prints a blue box with no character in it. It works when I call putch with putch('A').
Why is that ? I need to be able to send single characters from a string to putch()
Re:very strange thing with vidmem
Posted: Thu Oct 16, 2003 1:59 pm
by kaos
How have you defined GREEN_ON_BLUE?
Re:very strange thing with vidmem
Posted: Thu Oct 16, 2003 2:04 pm
by a
yes. it compiles fine but the character doesn't get printed
Re:very strange thing with vidmem
Posted: Thu Oct 16, 2003 4:54 pm
by rdragon
what do you have GREEN_ON_BLUE defined as?
IMO you should simply try:
vidmem[1] = 0x07;
and see if that works. Your problem most likely lies in your GREEN_ON_BLUE definition.
Re:very strange thing with vidmem
Posted: Thu Oct 16, 2003 5:00 pm
by Ozguxxx
Take care of physical address that your 'vidmem' is pointing to. This means that you have to check base of your kernel and then from this, see where this memory is mapped onto... Hope this helps. Good luck.
Re:very strange thing with vidmem
Posted: Fri Oct 17, 2003 1:42 am
by a
rdragon wrote:
what do you have GREEN_ON_BLUE defined as?
IMO you should simply try:
vidmem[1] = 0x07;
and see if that works. Your problem most likely lies in your GREEN_ON_BLUE definition.
GREEN_ON_BLUE is 0x1B and that is not the error because i've tried 0x07 too :-\
Re:very strange thing with vidmem
Posted: Sat Oct 18, 2003 7:41 am
by a
Ozgunh82 wrote:
Take care of physical address that your 'vidmem' is pointing to. This means that you have to check base of your kernel and then from this, see where this memory is mapped onto... Hope this helps. Good luck.
What do you meen ? My kernel is loaded at 0x100000. I have seen that some people have a video segment in their gdt.... do I need that ?
Re:very strange thing with vidmem
Posted: Sat Oct 18, 2003 4:47 pm
by Ozguxxx
You can do that but I think you have to write putch code in asm then, how can you change segment register in c? Well there might be some way in c but at that time of day I cannot think very clearly, so... I meant take care of address translation however if your function is working with argument A then I am most probably wrong...
Re:very strange thing with vidmem
Posted: Sat Oct 18, 2003 6:45 pm
by bkilgore
The fact that it works with putch('A') leads me to believe it has something to do with the varialbe you are declaring... is this your actual code? the use of a function called somefunc and the fact that there is at least one missing semicolong leads me to believe this wasn't just a copy and paste, but doing so may make it easier to find clues that rewriting wouldn't. For instance, I dont know if you are really declaring the variable inside a function and then using index 0 as a parameter, or if you are declaring it as a global variable and then using it inside another function. The latter would raise issues of whether your final binary has all of the sections linked in correctly, while the former doesn't. This is all I can think of righht now, but there are other things we may catch if we see the real code. Of course, this code be the real code with just a missing semicolon, but it may not be.
Re:very strange thing with vidmem
Posted: Sun Oct 19, 2003 10:26 am
by idle
vidmem[0] = c;
Shouldn't the above be:
Re:very strange thing with vidmem
Posted: Sun Oct 19, 2003 10:34 am
by Schol-R-LEA
No; if you look at the code above, you'll see that putch() takes c as an argument of type char.