So I have kind of hit a road block in my project.
What I am trying to do is figure out a way to take four individual binary characters which are representing flags. Now my last task was to take these four flags and put them in a char which wasn't difficult at all. But now, I want to take the four and convert it to a hex.
So for example:
O = 1;
C = 1;
Z = 0;
N = 0;
flags = O;
flags = C;
flags = Z;
flags = N;
int flags; flags = (O << 3) | (C << 2) | (Z << 1) | N; sprintf(buffer, "0x%02X", 0xff & flags);
flags is defined a single
int-variable containing all your flags.
buffer is a char array of sufficient size.
0xff & .. is not needed in this case, but might be some day if your flags variable can get negative and you still only want to have a one byte output (2 hex digits).