very strange thing with vidmem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
questionmark

very strange thing with vidmem

Post 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()
kaos

Re:very strange thing with vidmem

Post by kaos »

How have you defined GREEN_ON_BLUE?
a

Re:very strange thing with vidmem

Post by a »

yes. it compiles fine but the character doesn't get printed
rdragon

Re:very strange thing with vidmem

Post 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.
Ozguxxx

Re:very strange thing with vidmem

Post 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.
a

Re:very strange thing with vidmem

Post 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 :-\
a

Re:very strange thing with vidmem

Post 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 ?
Ozguxxx

Re:very strange thing with vidmem

Post 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...
bkilgore

Re:very strange thing with vidmem

Post 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.
idle

Re:very strange thing with vidmem

Post by idle »

vidmem[0] = c;
Shouldn't the above be:

Code: Select all

vidmem[0] = 'c';
Schol-R-LEA

Re:very strange thing with vidmem

Post 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.
Post Reply