Thanks in advance
I'm wondering how in C/C++ I would achieve something such as:
Convert that into a BYTE Array of:
Resulting in a 0x10 array instead of 0x20.
Cheers
Thanks in advance
I'm wondering how in C/C++ I would achieve something such as:
Convert that into a BYTE Array of:
Resulting in a 0x10 array instead of 0x20.
Cheers
Encoding a hex digit
#define HEX2BIN(D) ((('0' <= D) && (D <= '9')) ? D-'0' : (('a' <= D) && (D <= 'f')) ? D-'a'+10 : (('A' <= D) && (D <= 'F')) ? D-'A'+10 : -1)
and place it high or low
#define NIBBLE2BYTE(HI,BYTE,NIBBLE) do { if (HI) { BYTE = ((BYTE & 0xf0) | NIBBLE<<4); HI = 0; } else { BYTE = ((BYTE & 0x0f) | NIBBLE); HI=1; } } while (0)
. Now you can loop over your input and output with HI=1
initially. Test for HEX2BIN(D) > 0
to catch input errors!