shifttin 32-bit block of data in 8051 microcontroller

Thread Starter

eng.me

Joined Dec 10, 2012
27
Dear developers

How can I implement an shift left and shift right instruction for 32-bit block of data with using 8051 assembly language.

Can somebody help me with give code examples for create SHIFT functions in assembly only?

Thanks
 

Thread Starter

eng.me

Joined Dec 10, 2012
27
let's consider that I have replace the least significant BYTE at r4 , the second Byte at r5, the third r6 then the last Byte (M.S.Byte at r7 ).
It's OK using rrc & rlc, but I need to replace the Carry flag contents to the next Data register.
Example:
Data = 10010 0100 in binary placed at r4
code :
mov a,r4
clr PSW.7
ccr a
mov r4,a

the result will be
r4 = 010010 010
carry flag = 0 that comes from r4

So I need to replace the carry flag content at MSB of r7. what shuld I do.
 

Markd77

Joined Sep 7, 2009
2,806
You want to do a circular rotate so the last bit gets shifted back to the start?
Just do four RRC, then test the carry bit and use that to set the bit at the left end.
 

Thread Starter

eng.me

Joined Dec 10, 2012
27
Not a circular rotate . I have to take the shifted bit of r4 from carry flag then put it at the LSB of r5 . this is when shifting left.
 
Last edited by a moderator:

absf

Joined Dec 29, 2010
1,968
RLC A:

Description: Shifts the bits of the Accumulator to the left. The left-most bit (bit 7) of the Accumulator is loaded into the Carry Flag, and the original Carry Flag is loaded into bit 0 of the Accumulator. This function can be used to quickly multiply a byte by 2.
RL A:

Description: Shifts the bits of the Accumulator to the left. The left-most bit (bit 7) of the Accumulator is loaded into bit 0.
http://www.8052.com/51rlc.php

So just use 4 "RLC" and it should multiply the whole 32 bit number by 2.

Allen
 
Top