> -----Original Message----- > From: M. Adam Davis [SMTP:adampic@UBASICS.COM] > Sent: Tuesday, June 10, 2003 3:59 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: brain teaser > > Does it beat all of the options here: > http://www.piclist.com/techref/microchip/math/bit/revbits.htm > > The fastest one takes 4 instruction cycles (lookup table). > I make that 8 cycles (REG being the randomly chosen register): movf REG,w ; one cycle call reverse ; two cycles movwf REG ; one cycle reverse: addwf PCL,f ; two cycles retlw 0x00 ; two cycles retlw 0x80 retlw 0x40 Cross-wiring two ports gives a 4 cycle solution: movf REG,w ; one cycle movwf PORTB ; one cycle movf PORTC,w ; one cycle movwf REG ; one cycle Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu