2025-05-29 03:19:50 +00:00
|
|
|
//Our own code, at this point...
|
|
|
|
|
//#include <stddef.h>
|
2025-05-23 05:18:12 +00:00
|
|
|
#include <stdint.h>
|
2025-05-29 03:19:50 +00:00
|
|
|
#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';
|
|
|
|
|
}
|
2025-05-23 05:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//finally, main.
|
|
|
|
|
void kern_main()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//wipe the screen
|
2025-05-29 03:19:50 +00:00
|
|
|
vga_clear();
|
2025-05-23 05:18:12 +00:00
|
|
|
|
|
|
|
|
//IT IS TIME. TO PRINT.
|
2025-05-29 03:19:50 +00:00
|
|
|
char lol[5];
|
|
|
|
|
i_to_str(0xCAFEBABE, lol, 5);
|
|
|
|
|
vga_println(lol);
|
2025-05-23 05:18:12 +00:00
|
|
|
}
|
|
|
|
|
|