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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/26/08 20:42
Read: times


 
#152585 - re: OT: shifting 32 bit
Responding to: ???'s previous message
Frieder Ferlemann said:
Maybe try this:
unsigned long f ()
{
  unsigned long t; /* no need to clear */
  unsigned char i = 32;

  do
  {
     t <<= 1;
     if (P0_1)
        t |= 0x00000001;
  } while (--i);

  return t;
}
Funny, that's almost EXACTLY my code for the shift: do the shift first and OR in a new bit only if it tests true. And I also don't bother with initializing the shift register because I shift in all bits.

My main difference is that instead of testing a port bit directly, I test the width of a pulse (time between two dropping edges of a port pin). Same concept though.

-a

List of 7 messages in thread
TopicAuthorDate
24 bit number comparison in a 8 bit mc            01/01/70 00:00      
   assembler or C            01/01/70 00:00      
   How about this? (union, C-compiler, assembler)            01/01/70 00:00      
      helpful!            01/01/70 00:00      
         OT: shifting 32 bit            01/01/70 00:00      
            re: OT: shifting 32 bit            01/01/70 00:00      
   Thanks            01/01/70 00:00      

Back to Subject List