2022-09-14 21:54:59 -05:00
|
|
|
#include "print.h"
|
|
|
|
|
|
|
|
char nibbleToHex(uint8_t n) {
|
|
|
|
return n > 9 ? (n - 10) + 'A' : n + '0';
|
|
|
|
}
|
2022-09-21 17:14:11 -05:00
|
|
|
uintptr_t printByte(uint8_t v, uint16_t *buff) {
|
2022-09-14 21:54:59 -05:00
|
|
|
*(char *)&buff[0] = nibbleToHex((v >> 4) & 0xF);
|
|
|
|
*(char *)&buff[1] = nibbleToHex(v & 0xF);
|
2022-09-21 17:14:11 -05:00
|
|
|
return 2;
|
2022-09-14 21:54:59 -05:00
|
|
|
}
|
2022-09-21 17:14:11 -05:00
|
|
|
uintptr_t printWord(uint16_t v, uint16_t *buff) {
|
2022-09-14 21:54:59 -05:00
|
|
|
printByte(v >> 8, buff);
|
|
|
|
printByte(v, &buff[2]);
|
2022-09-21 17:14:11 -05:00
|
|
|
return 4;
|
2022-09-14 21:54:59 -05:00
|
|
|
}
|
2022-09-21 17:14:11 -05:00
|
|
|
uintptr_t printDword(uint32_t v, uint16_t *buff) {
|
2022-09-14 21:54:59 -05:00
|
|
|
printWord(v >> 16, buff);
|
|
|
|
printWord(v, &buff[4]);
|
2022-09-21 17:14:11 -05:00
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
uintptr_t printStr(char *v, uint16_t *buff) {
|
|
|
|
char *s;
|
|
|
|
for (s = v;*s;s++,buff++)
|
|
|
|
*(char*)buff = *s;
|
|
|
|
return s - v;
|
2022-09-14 21:54:59 -05:00
|
|
|
}
|