For your examples it's easy. ABCDEFG corresponds to hex 0x41, 0x42, 0x43 ect. If you simply mask the high nibble (AND with 0xF0) then pack 0x30 (OR with 0x30), then 0x41 will be converted to 0x31 ( this is ASCII code for digit "1". To use letters of the alphabet past an index of 9, you will need to utilize a lookup table. In this case I would recommend masking the highest 3 bits and using the results as the index in the table.