Microcontroller 8051

Thread Starter

Velu anbalagan

Joined Apr 27, 2014
1
Hello sir,

Someone please give me the idea about how to do swapping of bits from even numbered bit to odd numbered bit.

here i found one program but i couldnt get the logic.see below

Mov A,R3
RL A
ANL A,#0AAh
PUSH 0E0
MOV A,R3
RR A
ANL A,#055H
MOV R3,A
POP 0E0
ORL 03H,A

SOME ONE EXPLAIN ME THE LOGIC OF ABOVE PROGRAM
 

Arm_n_Legs

Joined Mar 7, 2007
186
I think there are some errors in your code. Anyway, the algorithm is something like this:
It is assume the bits that you want to alter is stored in R3.

(1) Move one set of the original byte to A and then shift it left. Mask off all the even bits. Store this result in the stack. The instruction should be PUSH ACC.

(2) Move another set of the original byte to A, and then shift it right. Mask off the odd bits.

(3) If you OR the result in (1) and (2), you will get your final answer.
 
Top