//type casting macros 
#define cast_uchar(x) ((unsigned char) (x))
#define cast_ucharp(x) ((unsigned char*) (x))
#define cast_char(x) ((char) (x))
#define cast_charp(x) ((char*) (x))
#define WHITE 0x0F
#define GREEN 0x0A
#define BLUE  0x01
#define RED   0x0C
#define YELLOW 0x0E
void newline();//go to the next line
void kputc(char c);//put a character on the screen
void kprint(char *s);//put a string on the screen
void set_color(unsigned char c);
void clear_screen();
char *texmem = cast_charp(0xB8000);
char *cline = cast_charp(0xB8000);
unsigned char color = 0x07;//white
void kmain()
{
    clear_screen();
	kprint("hai\n");
}

void kprint(char *s)
{
	while(*s != '\0')
	{
		if(*s == '\n') newline();
		if(texmem>= cast_charp(0xB8FFF))clear_screen();
		kputc(*s);
		s++;
	}
}

void kputc(char c)
{

	*texmem = c;
	texmem++;
	*texmem = color;
	texmem++;



}

void newline()
{
	cline += 0xA0;
	texmem = cline;


}

     

void set_color(unsigned char c)
{
	color = c;
}

void clear_screen()
{
	texmem = cast_charp(0xB8000);
	for(int i=1;i<(80*25);i++)
	{
		kputc(' ');

	}
	texmem = cast_charp(0xB8000);
}








