k_printf - not work

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
Logic

k_printf - not work

Post by Logic »

Hello,

I'm writing wery simple OS. Compiled is very nice, but not print strings of k_printf() function.

putch() function work.

Help me...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:k_printf - not work

Post by Solar »

Have you tested and verified your stdargs.h to work? (Like, receiving variable parameter lists from various test functions, and printing test results to screen with the known-to-be-good putch()?
Every good solution is obvious once you've found it.
Logic

Re:k_printf - not work

Post by Logic »

stdarg.h is not use, but "*message" is empty...

putch(*message,0) it does not it char on-screen
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:k_printf - not work

Post by Solar »

Erm... excuse me?

I can't really make sense out of your last posting. Your k_printf() is using variable argument lists, no?
Every good solution is obvious once you've found it.
Logic

Re:k_printf - not work

Post by Logic »

this is new function. I removed unnecessary parts.

Code: Select all


void k_printf(char *message, unsigned X, unsigned Y)
{
   int i;
   char screen_x,screen_y;
   screen_x = X;
   screen_y = Y;

   while(*message != 0)
   {
      i = 160 * screen_y + screen_x * 2;
      putch(*message, i);
      screen_x++;

      if (screen_x > 80)   //check for the need to wrap the text.
      {
         screen_x = 0;
         screen_y++;
      }
      message++;
   }
}
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:k_printf - not work

Post by Pype.Clicker »

could that be another case of "missing .rodata section" disease ?
Can you see the message you'd like to post in the binary file you're loading ?
Can you print some constant character like "putch('h',0); putch('i',1);" ?
Logic

Re:k_printf - not work

Post by Logic »

could that be another case of "missing .rodata section" disease ?
I'm setting .rodata section...

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
  .text 0x100000 : 
  {
   *(.text .rodata)
  }
  .data  : 
  {
    *(.data)
  }
  .bss  :
  {                
    *(.bss)
  }
} 
Can you see the message you'd like to post in the binary file you're loading ?
Yes.
Can you print some constant character like "putch('h',0); putch('i',1);" ?
Yes, I can.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:k_printf - not work

Post by Pype.Clicker »

hmm ... i might be wrong, but i get the feeling that you linked your code so that it should be at 0x100000 (1Meg) while the loader puts it at 0x0000:0x1000 (4K).

This will not be a problem for the code (which mainly uses relative call/jumps) nor for the local data (which are stackpointer-relatives) but it will certainly fail to access any static data. You're lucky enough that the video pointer worked :P

I suggest you fix both the loader and the linker script to work at 0x10000 = 0x1000:0 which should offer you enough extension possibilities without overwriting the bootloader ...
Post Reply