Code: Select all
#define WHITE_TEXT 0x07 /* White text on a black screen */
#define VIDMEMPTR 0xb8000;
#define TXTWIDTH 80
#define TXTHEIGHT 25
#define BYTESPERCHAR 2
/* Define functions */
void clearScreen();
unsigned int printf(char *message, unsigned int line);
int main()
{
clearScreen();
printf("Hello, World", 1);
for(;;)
;
}
void clearScreen() /* Clear the screen of text */
{
/* We set a pointer to the video memory; we declare it char so we can write to it a byte at a time */
char *vidmem = (char *) VIDMEMPTR;
unsigned int i = 0;
/* Write to the video memory to clear the screen */
while( i < ( TXTWIDTH * TXTHEIGHT * BYTESPERCHAR ) )
{
vidmem[i] = ' '; /* Set character to blank space */
i++;
vidmem[i] = WHITE_TEXT; /* Set style to WHITE_TEXT */
i++;
}
} /* (End clear screen function) */
unsigned int printf(char *message, unsigned int line) /* Prints a message at the given line */
{
/* We set a pointer to the video memory; we declare it char so we can write to it a byte at a time */
char *vidmem = (char *) VIDMEMPTR;
unsigned int i = 0;
i = ( line * TXTWIDTH * BYTESPERCHAR );
while( *message != 0 )
{
vidmem[i] = *message;
i++;
vidmem[i] = WHITE_TEXT;
i++;
++message;
}
return 1;
} /* End printf function */
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kernel.o kernel.c
I don't know if I'm just being an idiot or what, so any help would be much appreciated.