I'm here to ask you a question about kernel development (specific to x86 processors), my problem is this: I want to show the hex address of any pointer.
I tried alot of things, figuring out for myself ofc, but Im hitting this wall.
All print functions I implement by myself and they are all working. Remember: Im coding in a freestanding enviroment (GCC stuff).
Here is what I'm doing until now:
void testPrintHex(void* someptr) {
const char* hexDigits = "0123456789ABCDEF";
uint32_t* ptr = (uint32_t*) someptr;
print("0x");
for(size_t i = 0; i < 32; i+=8) {
char c = ptr[i];
char low = c & 0x0F;
char high = (c >> 4) & 0x0F;
for(int j = 0; j <= 16; j++) {
char h = (hexDigits[j] >> 4) & 0x0F;
if(high == h) {
printChar(h);
}
}
for(int j = 0; j <= 16; j++) {
char l = hexDigits[j] & 0x0F;
if(low == l) {
printChar(l);
}
}
}
print("\n");
}
I expected this to print the memory address of this pointer. What I get? This: 0x
Ow, there's 12 (2 spades, 2 happy faces, 6 squares and 2 hearts) strange symbols that Stack Overflow didn't show.