shifting can be handled with multiplication or division by 2. You can also do it with addition and subtraction (demonstrated below) if you know what the values of the bits are that you are working with.
For example:
Code:
/* Prototypes */
int main(void);
/* Tables */
unsigned byte bits[] = {128,64,32,16,8,4,2,1};
char alphaBinary[9];
/* Functions */
int main(void)
{
int i;
unsigned byte byteBinary;
byteBinary = 113; /* this could be any 0-255 value */
for(i=0;i<8;i++) /* loop through value */
{
if((byteBinary - bits[i]) < 0) /* If subtracting highest bit goes negative, then bit is zero */
alphaBinary[i] = '0';
else
{
alphaBinary[i] = '1'; /* otherwise it is set */
byteBinary -= bits[i]; /* effectively shift right */
};
};
alphaBinary[9] = 0x00; /* plug in c-style terminating byte */
printf("Original Decimal Value: %i Binary Equivalent: %s.",byteBinary,alphaBinary);
return(0);
}
Not tested, but this should give you the right idea.