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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/30/08 21:12
Read: times


 
#158706 - asm
Responding to: ???'s previous message
;according to http://en.wikipedia.org/wiki/Gray_code
;
; Let G[n:0] be the input array of bits in Gray code
; Let B[n:0] be the output array of bits in the usual binary representation
;   B[n] = G[n]
;   for j = n-1 downto 0
;     B[j] = B[j+1] XOR G[j]


       DSEG   AT   30h
       
G:  DS     3

       CSEG
       
Gray24_Bin:
       
       mov    r2, #25
G24BLoop:
       mov    a, G+0
       rlc    a
       mov    G+0, a
       mov    a, G+1
       rlc    a
       mov    G+1, a
       mov    a, G+2
       rlc    a
       mov    G+2, a
       djnz   r2, G24BLoop1
       sjmp   G24BLoopEnd
G24BLoop1:
       clr    a
       rrc    a      
       xrl    G+2, a
       rlc    a
       sjmp   G24BLoop
G24BLoopEnd:

;that's all, folks. But let's just make a test, a B->G conversion, to verify
       clr    c
       mov    a, G+2
       rrc    a
       xrl    G+2, a
       mov    a, G+1
       rrc    a
       xrl    G+1, a
       mov    a, G+0
       rrc    a
       xrl    G+0, a
;... and by here whe should have the original number in G
       
       end

 



List of 20 messages in thread
TopicAuthorDate
Gray Code To Binary 8051            01/01/70 00:00      
   huge table            01/01/70 00:00      
      RE: Take a pen and paper            01/01/70 00:00      
   Here are a few places to look...            01/01/70 00:00      
   What for?            01/01/70 00:00      
   Algorithm            01/01/70 00:00      
      Gray Code To Binary 8051            01/01/70 00:00      
         Post it            01/01/70 00:00      
            Yes!            01/01/70 00:00      
               Shifting ?            01/01/70 00:00      
                  Gray Code To Binary 8051            01/01/70 00:00      
                     Posting times            01/01/70 00:00      
   Gray Code To Binary 8051            01/01/70 00:00      
      2^n - 1 is not fast for large n            01/01/70 00:00      
         Ouch            01/01/70 00:00      
            Gray Code To Binary 8051            01/01/70 00:00      
               hardware            01/01/70 00:00      
               gray to bin            01/01/70 00:00      
                  asm            01/01/70 00:00      
                     Gray Code To Binary 8051            01/01/70 00:00      

Back to Subject List