printhex now a thing in stlio
This commit is contained in:
parent
a11c3c84bf
commit
d5baae3734
19
stlio.c
19
stlio.c
@ -30,12 +30,6 @@ u32 write(const char* buffer, const u32 size) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 read(char* buf, u32 n) {
|
|
||||||
// read n bytes from keyboard
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void printf(const char* fmt) {
|
void printf(const char* fmt) {
|
||||||
// Variadic fuller version of print on seperate branch but its nowhere near stable/ready/working
|
// Variadic fuller version of print on seperate branch but its nowhere near stable/ready/working
|
||||||
u32 size = strlen(fmt);
|
u32 size = strlen(fmt);
|
||||||
@ -49,9 +43,16 @@ void printf(const char* fmt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printHex(u32 num) {
|
void printhex(u32 num) {
|
||||||
u8 nibble = 0;
|
// Prints our hex version of whatever is given
|
||||||
char map[15] = "0123456789abcdef";
|
const char _chars[] = "0123456789abcdef";
|
||||||
|
u32 idx = 0; // used as hash into the _chars mapping
|
||||||
|
// iterate over each nibble
|
||||||
|
for(u32 i = 0 ;i < 8;i++) {
|
||||||
|
idx = (ptr << (i * 4)) & 0xf0000000;
|
||||||
|
idx = idx >> 28;
|
||||||
|
putch(_chars[idx]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void putch(const char c) {
|
void putch(const char c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user