??? 04/01/05 15:27 Read: times |
#90815 - One byte-reversing solution Responding to: ???'s previous message |
Mike Hymel said:
I've been trying to think of a solution to this all night but haven't come up with anything compact. Anyone? Not sure if you'd consider this compact, but here's something I came up with off the top of my head. ACC holds the value to be reversed and, on exit, R1 holds the reversed value. R1 does not need to be initialized since the operation will affect all eight bits of R1. REVERSE: MOV R0,#08h ;Number of bits REVERSELOOP: MOV C,ACC.0 RR A XCH A,R1 RL A MOV ACC.0,C XCH A,R1 DJNZ R0,REVERSELOOP RET Hope this helps. It looks like this is about the same as the link Erik provided, but takes into account the fact that the 8052 can only rotate the accumulator. Regards, Craig Steiner |