Changeset 32 for trunk/hal/x86_64/x86_printf.c
- Timestamp:
- Jun 21, 2017, 11:34:09 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/x86_printf.c
r31 r32 75 75 } 76 76 77 static void x86_ztoa(char *buf, uint64_t n, uint64_t base) 78 { 79 uint64_t tmp; 80 int i, j; 81 82 tmp = n; 83 i = 0; 84 85 do { 86 tmp = n % base; 87 buf[i++] = (tmp < 10) ? (tmp + '0') : (tmp + 'a' - 10); 88 } while (n /= base); 89 buf[i--] = 0; 90 91 for (j = 0; j < i; j++, i--) { 92 tmp = buf[j]; 93 buf[j] = buf[i]; 94 buf[i] = tmp; 95 } 96 } 97 77 98 void x86_printf(char *s, ...) 78 99 { … … 85 106 int ival; 86 107 unsigned int uival; 108 uint64_t zval; 87 109 88 110 va_start(ap, s); … … 101 123 } 102 124 103 if (c == 'd') { 125 if (c == 'z') { 126 zval = va_arg(ap, uint64_t); 127 x86_ztoa(buf, zval, 10); 128 129 buflen = strlen(buf); 130 if (buflen < size) 131 for (i = size, j = buflen; i >= 0; i--, j--) 132 buf[i] = (j >= 0) ? buf[j] : '0'; 133 134 x86_printf(buf); 135 } else if (c == 'Z') { 136 zval = va_arg(ap, uint64_t); 137 x86_ztoa(buf, zval, 16); 138 139 buflen = strlen(buf); 140 if (buflen < size) 141 for (i = size, j = buflen; i >= 0; i--, j--) 142 buf[i] = (j >= 0) ? buf[j] : '0'; 143 144 x86_printf("0x%s", buf); 145 } else if (c == 'd') { 104 146 ival = va_arg(ap, int); 105 147 if (ival < 0) {
Note: See TracChangeset
for help on using the changeset viewer.