Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/05/04 08:59
Read: times


 
#75454 - RE: Help with intrins function Keil V7.09
Responding to: ???'s previous message

If all you want to do is rotate the byte, try this:

char rotate_r(char val)
{
char a;
a= val>>1;
if (val & 0x01) // is the lsb ==1
{
a |= 0x80; //yep, pop it into the msb
}
return a;
}

Assembler handles rotating much easier than 'C'!

In the case where you may want to test a bit:

//
// returns non zero if the bit 'bit' is set in 'val'
//
char bit_test(char val,char bit)
{
const char bit_mask[8]={0,1,2,4,8,16,32,64,128};

return (val & bit_mask[bit]);
}



List of 9 messages in thread
TopicAuthorDate
Help with intrins function Keil V7.09            01/01/70 00:00      
   RE:Help with intrins function Keil V7.09            01/01/70 00:00      
   RE: Help with intrins function Keil V7.09            01/01/70 00:00      
      RE: Help with intrins function Keil V7.09            01/01/70 00:00      
         RE: Help with intrins function Keil V7.09            01/01/70 00:00      
            RE: Help with intrins function Keil V7.09            01/01/70 00:00      
               RE: Help with intrins function Keil V7.09            01/01/70 00:00      
            RE: Help with intrins function Keil V7.09            01/01/70 00:00      
   RE: Help with intrins function Keil V7.09            01/01/70 00:00      

Back to Subject List