# Doubt in the rotation asm pic16F

#### aless2056

##### Newbie level 6
Guys, I'm a beginner and I'm in doubt in the RRF Rotation instruction. Assuming I have this value

0000 0011 0011 1100
AH = 0000 0011
AL = 0011 1100

Did I do that?

RRF AH, F
RRF AL, F
RRF AH, F
RRF AL, F

Will the result be?

AH = 0000 0000
AL = 1100 1111

#### KlausST

##### Super Moderator
Staff member
Hi,

The answer is: it depends.

I don't want to do your homework.
So please show the states after each commend. Step by step.

Klaus

#### betwixt

##### Super Moderator
Staff member
You should study the data sheet, it explains all the instructions and gives examples.

'AH' and 'AL' presumably are register names and independent 8-bit values.
RRF AH, F AH is 0000 0011 before the instruction so rotating it right through the carry flag, bit 7 = whatever was in C, and C becomes what was in Bit 0
The same applies to the AL register but note there is only one carry bit so it may transfer a bit from one register to the next.

We can't predict what the result will be without knowing what was in C at the outset.

Brian.

#### FvM

##### Super Moderator
Staff member
C must be cleared before executing RRF AH, e.g. with CLRF STATUS.

#### KlausST

##### Super Moderator
Staff member
Hi,

... or filled with the LSB of AL for a true rotation...

Klaus

Replies
2
Views
994
Replies
1
Views
2K
Replies
0
Views
790
Replies
2
Views
1K
Replies
20
Views
3K