Advertisement
Guest User

kernel and linker

a guest
May 1st, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1. Kernel.c:
  2.  
  3. /*
  4. *  kernel.c
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. void kmain(void)
  11. {
  12.     FILE * pFile;
  13.     char c;
  14.  
  15.     const char *str = "DoorsOS v0.3";
  16.     printf("Hello World!\n");
  17.     char *vidptr = (char*)0xb8000;  //video mem begins here.
  18.     unsigned int i = 0;
  19.     unsigned int j = 0;
  20.  
  21.     /* this loops clears the screen
  22.     * there are 25 lines each of 80 columns; each element takes 2 bytes */
  23.     while(j < 80 * 25 * 2) {
  24.         /* blank character */
  25.         vidptr[j] = ' ';
  26.         /* attribute-byte - light grey on black screen */
  27.         vidptr[j+1] = 0x07;        
  28.         j = j + 2;
  29.     }
  30.  
  31.     j = 0;
  32.  
  33.     /* this loop writes the string to video memory */
  34.     while(str[j] != '\0') {
  35.         /* the character's ascii */
  36.         vidptr[i] = str[j];
  37.         /* attribute-byte: give character black bg and light grey fg */
  38.         vidptr[i+1] = 0x07;
  39.         ++j;
  40.         i = i + 2;
  41.     }
  42.     return;
  43. }
  44.  
  45. linker.ld:
  46.  
  47. /*
  48. *  link.ld
  49. */
  50. OUTPUT_FORMAT(elf32-i386)
  51. ENTRY(start)
  52. SECTIONS
  53.  {
  54.    . = 0x100000;
  55.    .text : { *(.text) }
  56.    .data : { *(.data) }
  57.    .bss  : { *(.bss)  }
  58.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement