ROSE/print.c

18 lines
452 B
C
Raw Normal View History

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