I assume that you are using an int to store your "string" of bits, so I've written
this small example to demonstrate how you might extract your data.
Code:
#include <stdio.h>
/*some definitions of values*/
#define BITMASK 0xF
#define NIBBLE 4
int main (void)
{
int a_byte = 0xA8; /*some generic value*/
int temp_var1 = 0;
int temp_var2 = 0;
temp_var1 = a_byte & BITMASK; /*this line uses the & operator to isolate the lower bits*/
temp_var2 = (a_byte >> NIBBLE) & BITMASK; /*this then shifts the upper bits and isolates them */
printf ("Our byte was %x in hex\n\n", a_byte, a_byte, a_byte);
printf ("The lower nibble was %x\n\n", temp_var1, temp_var1);
printf ("The upper nibble was %x\n\n", temp_var2, temp_var2);
/*now we could use the values in temp_var1 and temp_var2 in switch statements, function parameters etc*/
getchar ();
}
So considering your date format, you can use the upper nibble in a switch
statement (temp_var2), and the lower nibble will always be your data parameter
(temp_var1). Hope this helps.