I colleague of mine has extoled the virtues of using lookup tables as a means of improving speed for as long as I can remember. Just about every time I have ever asked him, "How can I make this faster", he usually replies: "use a table". Ever wonder how they got so many of those video games on the 1Mhz "pre-Nintendo-era" game units to animate smoothly? I tend to agree that this technique is often underused. But, Of course, there are plenty of situations where the use of a table may not be practical. Just my $.02 Dan On Fri, 29 Oct 1999 17:12:13 +0200, Douglas Burkett wrote: >If I'm not mistaken you could use a 16 byte lookup for the nybbles and then >use the efficency of the swap instruction, quicker I believe than rotating >all 8 bits and less code space than the full lookup table. > >Doug > >----- Original Message ----- >From: Adam Bryant >To: >Sent: Friday, October 29, 1999 3:54 PM >Subject: Re: Efficient way to reverse a byte? > > >> Jim, >> Your choices are likely to be fast execution and big code usage OR slow >> execution and small code usage. >> >> As Wagner suggested, fastest would be a 256 byte lookup table (but it >> uses up 256 bytes for the lookup table). >> >> A small, slower approach is to rotate the source byte right one bit >> (putting the rightmost bit in the carry flag), then rotate the >> destination byte left one bit (putting the carry flag in the rightmost >> bit of your destination register). Repeat this cycle 8 times. Your >> destination byte will have to be a temp register, then when done move the >> temp register back to the original source register. I would estimate >> this could be done in 10 to 15 bytes of code and 50 to 70 instruction >> cycles. >> >> Obviously I am thinking like the C programmer I am and someone like >> Dimitry could probably give you a method for accomplishing the same thing >> in 5 bytes of code and 10 cycles. :-) >> >> Hope this helps, >> Adam >> >> On Fri, 29 Oct 1999 14:48:54 +0100 Jim Main writes: >> > I'm sure I saw an easy way to reverse a byte some time ago in this >> > list, but >> > I've forgotten it.. >> > >> > I want to change b7 b6 b5 b4 b3 b2 b1 b0 to b0 b1 b2 b3 b4 b5 >> > b6 b7. >> > >> > Quickest & most code efficient?? >> > >> > Jim >> > --- >> >> Adam Bryant (age 0x23) >> abryant@peaktech.com (work) >> adamdb@juno.com (home) >> Parker, CO, USA >> Robotics, RC Airplanes, anything using a PIC >> >> ___________________________________________________________________ >> Get the Internet just the way you want it. >> Free software, free e-mail, and free Internet access for a month! >> Try Juno Web: http://dl.www.juno.com/dynoget/tagj. >