/* GXEmul Utilities Packages */ #define PUTCHAR_ADDRESS ((signed int)0xb0000000) #define HALT_ADDRESS ((signed int)0xb0000010) const char dec_digits[] = "0123456789"; const char hex_digits[] = "0123456789abcdef"; void printchar(char ch) { *((volatile unsigned char *) PUTCHAR_ADDRESS) = ch; } void halt(void) { *((volatile unsigned char *) HALT_ADDRESS) = 0; } void printstr(char * s){ while(*s) printchar(*s++); } void print_uint(unsigned int v){ char s[15]; unsigned int i = 0, j; if(!v) { s[0] = dec_digits[0]; return; } for(j = v; j != 0; i++, j /= 10); s[i] = '\0'; for(j = 0; v != 0; j++, v /= 10) s[i - 1 - j] = dec_digits[v % 10]; printstr((char *)&s); } void print_int(int v){ char s[15]; unsigned int i = 0, j; if(!v) { s[0] = dec_digits[0]; return; } if(v < 0) { v = -v; s[i++] = '-'; } for(j = v; j != 0; i++, j /= 10); s[i] = '\0'; for(j = 0; v != 0; j++, v /= 10) s[i - 1 - j] = dec_digits[v % 10]; printstr((char *)&s); }