void PrintInt(int val) { if (!val) { sys_putc('0'); return; } if (val < 0) { sys_putc('-'); val = -val; } static char buf[20]; char *ptr = buf + 19; while (val) { int div = __divu10(val), mod = val - __mulu10(div); *(-- ptr) = mod + '0'; val = div; } PrintString(ptr); }
/* * * cputch - writes a single character @c to stdout, and it will * increace the value of counter pointed by @cnt. * */ static void cputch(int c, int *cnt) { sys_putc(c); (*cnt) ++; }
void PrintString(const char *str) { while (*str) sys_putc(*(str ++)); }