The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

1996 Application note Reversing bits within data byte A


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



AN709 Reversing bits within data byte
1996
Application note
Reversing bits within data byte
AN709
Author: Greg Goodhue, Microcontroller Product Planning, Philips Semiconductors, Sunnyvale,
Implementing algorithm reverse bits within data byte notorious producing inefficient code most processors. This function serve case study trade code size performance shows some methods that might employed similar types data conversion situations. Here four solutions shown implement byte reverse function. first version (Listing uses very simple approach. result produced shifting initial data value shifting same back into result value. This repeated loop each bit. Since shift operations done opposite directions, result value reversal initial value. This version smallest size, using only bytes. However, takes clock periods complete. Listing uses same method first, "unfolds" loop eliminate counting branching overhead. What left instructions from inside loop repeated eight times. Unfolding loop gives faster execution, clocks this case. code size grows somewhat bytes. third method (Listing uses partial lookup table reverse nibble time assemble complete byte from lookup values. reversed byte, upper nibble result consists reversed bits lower nibble initial value, while lower nibble result consists reversed bits upper nibble initial value. code example uses each nibble initial value index into lookup table, which provides nibble result data. partial results then combined produce complete result. This version uses bytes both code lookup table, requires only clock periods complete. final method shown (Listing uses full lookup table produce entire result very quickly. initial data byte used index into lookup table value from table complete result byte. This method produces result only clocks. However, code plus lookup table occupies fairly large amount code space: bytes.
CONCLUSION
These examples show code size often traded execution speed, execution speed code size, depending application's requirements. This summarized Figure Other solutions this particular algorithm certainly possible other algorithms will likely have different types solutions with different resulting tradeoffs.
CODE BYTES CLOCKS
LISTING LISTING LISTING LISTING
SU00819
Figure Tradeoff code size performance.
1996
Application note
Reversing bits within data byte
AN709
LISTING
Listing Smallest solution terms code space: Enter with value reversed R0L, result R0H. This works shifting register direction back other. count,#8 clks loop: r0l,#1 clks r0h,#1 clks djnz count,loop clks total time 8*(4+4) clocks
LISTING
Listing Solution with loop "unfolded". Enter with value reversed R0L, result R0H. This works shifting register direction back other. r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks r0l,#1 clks r0h,#1 clks total time 8*(4+4) clocks
1996
Application note
Reversing bits within data byte
AN709
LISTING
Listing Fastest solution (without using byte lookup table): Enter with value reverse R4L, result returned R0L. This works reversing each nibble using look table reversing nibbles separately part procedure. r6,#LUT1 clks push clks r4l,#$0f clks movc a,[a+dptr] clks r0l,r4l clks r0l,#4 clks clks r4l,#$f0 clks r4l,#4 clks movc a,[a+dptr] clks r0l,r4l clks this nibble reverse lookup table: LUT1: total time clocks
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
0000 1000 0100 1100 0010 1010 0110 1110 0001 1001 0101 1101 0011 1011 0111 1111
LISTING
Listing Fastest solution (using byte lookup table): Enter with value reverse R4L, result returned R0L. r6,#LUT2 clks movc a,[a+dptr] clks r0l,r4l clks this byte reverse lookup table: LUT2: 00000000 00000000 00000001 10000000 00000010 01000000 00000011 11000000 total clocks
1996
Application note
Reversing bits within data byte
AN709
NOTES
1996
Application note
Reversing bits within data byte
AN709
Philips Semiconductors Philips Electronics North America Corporation reserve right make changes, without notice, products, including circuits, standard cells, and/or software, described contained herein order improve design and/or performance. Philips Semiconductors assumes responsibility liability these products, conveys license title under patent, copyright, mask work right these products, makes representations warranties that these products free from patent, copyright, mask work right infringement, unless otherwise specified. Applications that described herein these products illustrative purposes only. Philips Semiconductors makes representation warranty that such applications will suitable specified without further testing modification. LIFE SUPPORT APPLICATIONS Philips Semiconductors Philips Electronics North America Corporation Products designed life support appliances, devices, systems where malfunction Philips Semiconductors Philips Electronics North America Corporation Product reasonably expected result personal injury. Philips Semiconductors Philips Electronics North America Corporation customers using selling Philips Semiconductors Philips Electronics North America Corporation Products such applications their risk agree fully indemnify Philips Semiconductors Philips Electronics North America Corporation damages resulting from such improper sale. Philips Semiconductors East Arques Avenue P.O. 3409 Sunnyvale, California 94088-3409 Telephone 800-234-7381 Philips Semiconductors Philips Electronics North America Corporation register eligible circuits under Semiconductor Chip Protection Act. Copyright Philips Electronics North America Corporation 1996 rights reserved. Printed U.S.A.
1996

Other recent searches


UQC-300 - UQC-300   UQC-300 Datasheet
uPD78F0361 - uPD78F0361   uPD78F0361 Datasheet
REJ03D0117-0900 - REJ03D0117-0900   REJ03D0117-0900 Datasheet
PI5C3244 - PI5C3244   PI5C3244 Datasheet
NNCD3 - NNCD3   NNCD3 Datasheet
NNCD12C - NNCD12C   NNCD12C Datasheet
MMBTSB1198KLT1 - MMBTSB1198KLT1   MMBTSB1198KLT1 Datasheet
MCH3109 - MCH3109   MCH3109 Datasheet
MCH3209 - MCH3209   MCH3209 Datasheet
EN5476 - EN5476   EN5476 Datasheet
LC78711E - LC78711E   LC78711E Datasheet
E1950 - E1950   E1950 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive