title: C kernel- printing string not working
body: <p>I am making a C kernel from scratch, and I literally just copied this code off of a website because my code wasn't working so I was confused.</p>
  
  <pre><code>void kmain(void)
  {
      const char *str = "my first kernel";
      char *vidptr = (char*)0xb8000;  //video mem begins here.
      unsigned int i = 0;
      unsigned int j = 0;
  
      /* this loops clears the screen
      * there are 25 lines each of 80 columns; each element takes 2 bytes */
      while(j &lt; 80 * 25 * 2) {
          /* blank character */
          vidptr[j] = ' ';
          /* attribute-byte - light grey on black screen */
          vidptr[j+1] = 0x07;         
          j = j + 2;
      }
  
      j = 0;
  
      /* this loop writes the string to video memory */
      while(str[j] != '\0') {
          /* the character's ascii */
          vidptr[i] = str[j];
          /* attribute-byte: give character black bg and light grey fg */
          vidptr[i+1] = 0x07;
          ++j;
          i = i + 2;
      }
      return;
  }
  </code></pre>
  
  <p>When I run my kernel, it prints an S to the screen and nothing else. I know my kernel is booting, because if I do</p>
  
  <pre><code>vidptr[0] = 'h';
  vidptr[2] = 'e';
  vidptr[4] = 'l';
  vidptr[6] = 'l';
  vidptr[8] = 'o';
  </code></pre>
  
  <p>it works as expected. What is happening?</p>
  
  <p>EDIT: It might be something with my code that loads the kernel (might not have set up some of the registers) so I will just look into grub and other things.</p>