> -----Original Message----- > From: Jim Robertson [SMTP:"jim Pl"@NEWFOUNDELECTRONICS.COM] > Sent: Tuesday, June 10, 2003 11:17 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: brain teaser > > > > > > -----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 > > > >Regards > > > >Mike > > Now to the real world. The above example assumes that: > > 1) The Addwf PCL,f is one address location before a Mod 256 address. > 2) That PCLATH is "magically" addressing the right 256 byte page > 3) That the PIC involved is not a PIC18 core type. > > Regards, > > Jim > Indeed. I ignored these as this was a "best case" scenario. A "bit reverser" would be trivial to implement in silicon, I wonder if MChip have ever considered including one as this topic has come up quite a few times. Mike 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