/* * hex_out.c * * Created on: 2016/11/24 * Author: takayun */ #include "hex_out.h" #include "hex_encoder.h" #include "system.h" void print_block(char * str, unsigned int size, enum BLOCK_N block_i) { int i; if (block_i == HEX0_3) { if (size > 4) panic(); for (i = 0; i < size; i++) { encodeLatHex(i,str[size-1-i]); } } else if (block_i == HEX4_5) { if (size > 2) panic(); for (i = 0; i < size; i++) { encodeLatHex(i+4,str[size-1-i]); } } else if (block_i == HEX6_7) { if (size > 2) panic(); for (i = 0; i < size; i++) { encodeLatHex(i+6,str[size-1-i]); } } } void clear_block(enum BLOCK_N block_i) { if (block_i == HEX0_3) { print_block(" ", 4, HEX0_3); } else if (block_i == HEX4_5) { print_block(" ", 2, HEX4_5); } else if (block_i == HEX6_7) { print_block(" ", 2, HEX6_7); } } void print_number(char num) { int i; char buf[5]; char val; for (i = 0; i < 4; i++) { if (num < 0) { buf[0] = '-'; val = -num; } else { buf[0] = ' '; val = num; } buf[1] = val/100%10 + '0'; buf[2] = val/10%10 + '0'; buf[3] = val%10 + '0'; } clear_block(HEX0_3); print_block(buf, 4, HEX0_3); }