Untitled_Kernel/src/main.c

44 lines
963 B
C
Raw Normal View History

//Our own code, at this point...
//#include <stddef.h>
#include <stdint.h>
#include "kernio.h"
//convert digits from int num to buffer buf. in hex. This is 32 bit only for now!
//WARN: integer is written from right to left into the buffer, and will halt if the buffer is too small.
void i_to_str(uint32_t num, char* buf, int size) {
//null terminate the string
buf[--size] = '\0';
while(size > 0 && (num) != 0){
int isolated_num = num % 0x10;
if(isolated_num > 9){
isolated_num+=7;
}
buf[--size] = '0' + isolated_num;
num/=0x10;
}
//now shift the whole thing to the left
if(size != 0) {
while(buf[size]!='\0') {
*buf = buf[size];
buf++;
}
*buf = '\0';
}
}
//finally, main.
void kern_main()
{
//wipe the screen
vga_clear();
//IT IS TIME. TO PRINT.
char lol[5];
i_to_str(0xCAFEBABE, lol, 5);
vga_println(lol);
}