Providing C++ Runtime support for Kernel

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.
PlayOS

Re:Providing C++ Runtime support for Kernel

Post by PlayOS »

OK, now I can compile and run but nothing works properly, for instance with your write method all it done was print the first character all over the screen.

So I decided to write my own and well this is no better, this is the code I am using now, all the variables with m_ are defined as members of the Console class:

Code: Select all

int Console::Write( char *str )
{
   unsigned int i = ((m_ScreenX * 2) + (m_ScreenY * 160));
   unsigned int j = 0;

   while (str[j] != 0)
   {
      m_Video[i] = str[j];
      m_Video[i + 1] = m_Attribute;

      j++;  // j will not increment, not even with j += 1 or j = j + 1
      i += 2;
      m_ScreenX++;

      if (m_ScreenX >= 80) // should only start a new line after 80 chars
      {
         m_ScreenX = 0;
         m_ScreenY++;

         if (m_ScreenY > 20)
         {
            m_ScreenY = 0;
         }

         i = (m_ScreenY * 160);
      }
   }

   return 0;
}
For some reason none of this works, this function just prints H down the screen (I am still passing "Hello, World!") until I get to line 20 where I force it to stop, this works but not much else as it is supposed to.

Do you know what the problem is?

thanks.
whyme_t

Re:Providing C++ Runtime support for Kernel

Post by whyme_t »

ok, I'ved uploaded a zip. just for you :)

It contains all source for part 1, the kernel.bin (with added GRUB support), and an image file ready for use with rawrite.

This works perfectly for me. I tested on both virtual hardware (Bochs 1.4.1), and real hardware (pIII 600).

http://www.invalidsoftware.net/os/files/part1code.zip

:)
PlayOS

Re:Providing C++ Runtime support for Kernel

Post by PlayOS »

Well gee, now I feel special. :)

Yep, the compiled binary ran beautifully, but you wont believe it, when I compile the source and run it, all I get is the H across the screen, for some reason the variables will not increment in the loops, so the loop never ends.

Thanks for all of your help, but you are probably better to just give up on me and continue your tutorials.
Post Reply