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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/01/05 16:11
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#90818 - Re: Byte Bit Reversal
Responding to: ???'s previous message
With regard to the code in my earlier post, perhaps I should have said compact and non-iterative.

The code in my previous post gives a complete Keil C51 implementation with a simple switch between too versions. The first was original to me and may be of some interest. I later found Peter Dannegger's method that is significantly quicker and more compact.

In case you are not using Keil, the assembly code for the Peter Dannegger version boils down to just this:
                                    ;C 76543210
                                    ;x hgfedcba
        MOV     C,Acc.1             ;b hgfedcba
        RLC     A                   ;h gfedcbab
        MOV     Acc.2,C             ;h gfedchab
        MOV     C,Acc.3             ;c gfedchab
        RLC     A                   ;g fedchabc
        MOV     Acc.4,C             ;g fedghabc
        MOV     C,Acc.5             ;d fedghabc
        RLC     A                   ;f edghabcd
        MOV     Acc.6,C             ;f efghabcd
        SWAP    A                   ;f abcdefgh

The above code reverses all the bits in a byte held in the accumulator and it only trashes the carry.

(I do wish I had thought of it!)

List of 36 messages in thread
TopicAuthorDate
Reversing Algorithm            01/01/70 00:00      
   remembered this one            01/01/70 00:00      
      the fastest code in the west            01/01/70 00:00      
         Am I wrong            01/01/70 00:00      
            not as simple, but less table            01/01/70 00:00      
               lookup table            01/01/70 00:00      
                  nope            01/01/70 00:00      
                     swap, the nibble mirror            01/01/70 00:00      
                        nibble-wise?            01/01/70 00:00      
                     nope nope            01/01/70 00:00      
                        noipe, nope, nope            01/01/70 00:00      
                            noipe, nope, nope, nope            01/01/70 00:00      
                              Ok, Ok. Ok, OK            01/01/70 00:00      
                                 max.255 entries - or the tricks :-)            01/01/70 00:00      
                                    the value of verification            01/01/70 00:00      
                  Mirrored tracks            01/01/70 00:00      
                     Why ?            01/01/70 00:00      
                        Working fine            01/01/70 00:00      
                           why you post wrong code ?            01/01/70 00:00      
                              Yes. Code has bug - Peter            01/01/70 00:00      
                                 efficiency            01/01/70 00:00      
                                    Obvious Vs Smart code            01/01/70 00:00      
                                       sorry            01/01/70 00:00      
                                          No offence - only learning            01/01/70 00:00      
   One byte-reversing solution            01/01/70 00:00      
   Byte Bit Reversal            01/01/70 00:00      
      Re: Byte Bit Reversal            01/01/70 00:00      
   Bit Addressing solution!            01/01/70 00:00      
      Hardware?            01/01/70 00:00      
      2 byte of ram or 2 port?            01/01/70 00:00      
   Three ways:            01/01/70 00:00      
      Three (smart) ways            01/01/70 00:00      
      Thanks, Peter, but...            01/01/70 00:00      
         its faster            01/01/70 00:00      
   Topic has been discussed before            01/01/70 00:00      
   You could try a CPLD            01/01/70 00:00      

Back to Subject List