Searching \ for 'RRF and RLF instructions :) puzzle' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/index.htm?key=puzzle
Search entire site for: 'RRF and RLF instructions :) puzzle'.

Truncated match.
PICList Thread
'RRF and RLF instructions :) puzzle'
1997\11\04@172849 by Dmitry Kiryashov

flavicon
face
Hello Andrew .

> That's how it works.
[skip]

I understand how RLF FILE,F command work but i have real puzzle
when i try to think what RLF(RRF) STATUS,F(W) commands do ? ;)

WBR Dmitry.

1997\11\04@185426 by TONY NIXON 54964

flavicon
picon face
> I understand how RLF FILE,F command work but i have real puzzle
> when i try to think what RLF(RRF) STATUS,F(W) commands do ? ;)

The data from file register F is placed in the ALU and the RRF/RLF
operation is performed. File register F at this point has not been
altered. If the destination bit = 1 then the new data from the ALU is
placed back into file register F. If the destination bit = 0, then
the new data from the ALU is placed into the W register. The carry bit in
the status register will also be changed.

Tony


Just when I thought I knew it all,
I learned that I didn't.

1997\11\05@002555 by Mike Keitz

picon face
On Wed, 5 Nov 1997 10:14:00 +1000 TONY NIXON 54964
<spam_OUTTony.nixonTakeThisOuTspamENG.MONASH.EDU.AU> writes:
>> I understand how RLF FILE,F command work but i have real puzzle
>> when i try to think what RLF(RRF) STATUS,F(W) commands do ? ;)
>
>The data from file register F is placed in the ALU and the RRF/RLF
>operation is performed. File register F at this point has not been
>altered. If the destination bit = 1 then the new data from the ALU is
>placed back into file register F. If the destination bit = 0, then
>the new data from the ALU is placed into the W register. The carry bit
>in
>the status register will also be changed.

But this is different with the STATUS register.  Any instruction which
affects any or all of C,DC,and Z and writes to the STATUS register will
not change *any* of these bits as a result of the write, only as a result
of the automatic change by the instruction.  Also the TO and PD bits are
set only by the reset logic and can't be written at all by any program.

For example, clrf STATUS will clear all the page bits, not affect the TO
and PD bits, set the Z bit, *and not change C or DC*.  It says so in the
Microchip book and also does so on a real chip.  A movwf STATUS *will*
write to C,DC, and Z, because movwf doesn't inherently affect any status
bits.

RRF or RLF STATUS,W will work as expected.  A shifted copy of STATUS will
be placed in W.  The C bit will be unchanged (on a rotate right) or
copied from STATUS.7 (on a rotate left).  The other bits in STATUS will
not change.

However, RRF or RLF STATUS,F will not work conventionally.  Regardless of
any input conditions, the Z and DC bits will never change.  The C bit
will either be copied from bit 7 on a rotate left or copied from bit 0
(which is the old C bit) on a rotate right.  The TO and PD bits will of
course not change.

1997\11\05@013458 by Ray Gardiner

flavicon
face
<Snip>

>However, RRF or RLF STATUS,F will not work conventionally.  Regardless of
>any input conditions, the Z and DC bits will never change.  The C bit
>will either be copied from bit 7 on a rotate left or copied from bit 0
>(which is the old C bit) on a rotate right.  The TO and PD bits will of
>course not change.

Good question, Dmitry.

Continuing on from Mike Keitz's comments.
The RLF, RRF instructions only affect the C bit in STATUS, and since
TO and PD are READ only, I agree they will be unchanged, so the
result will be to rotate all the other STATUS reg bits, either way. But with
the TO and PD bits being unchanged. Since RLF RRF update C, presumably
AFTER the rotate.

So...
BEFORE:                 IRP RP1 RP0  TO  PD  Z  DC  C
AFTER:   RLF STATUS,F   RP1 RP0  TO  TO  PD DC  Z  IRP

And..
BEFORE:                 IRP RP1 RP0  TO  PD  Z   DC  C
AFTER:   RRF STATUS,F    C  IRP RP1  TO  PD  PD  Z   C

Can anyone confirm that this actually happens?...If so are there any
clever uses for such a trick. (copying DC into Z etc.)



Ray Gardiner  Technical Director DSP Systems   .....rayKILLspamspam@spam@dsp-systems.com
private email to:- rayspamKILLspamnetspace.net.au  http://www.dsp-systems.com

1997\11\05@015609 by Bob Lunn

flavicon
face
Bob Lunn
11/05/97 05:56 PM


> So...
> BEFORE:                 IRP RP1 RP0  TO  PD  Z  DC  C
> AFTER:   RLF STATUS,F   RP1 RP0  TO  TO  PD DC  Z  IRP
>
> And..
> BEFORE:                 IRP RP1 RP0  TO  PD  Z   DC  C
> AFTER:   RRF STATUS,F    C  IRP RP1  TO  PD  PD  Z   C

    No, I don't think so.

    The pic uses a read/modify/write mechanism.

    The status register is read to the alu, modified
    according to the instruction being executed, and
    then written to the destination.

    After this, the alu updates the <zero>, <carry>,
    and <digit carry> flags in the status register
    according to the result of the operation.

    So, where a rotate instruction takes the status
    register as source, and the <W> register as
    destination, the result is exactly as would be
    expected.  That is, <W> will contain the original
    contents of <status> suitably shifted, and <carry>
    will contain either <rp1> or <carry>.  The other
    bits of <status> will be unchanged.

    However, where a rotate instruction takes the
    status register as source, and the status register
    as destination, the result is NOT as would be
    expected.  The reasons for this are two-fold.

    Some bits in <status> are read-only, so the write-
    back of the result of the operation back to the
    status register by the alu doesn't affect these bits.

    Further, the update of the <zero>, <carry>, and
    <digit carry> flags by the alu will overwrite
    (actually, will prevent from being written) the
    settings of these flags by the write-back of the
    result to the status register.

___Bob

1997\11\05@022452 by tjaart

flavicon
face
Bob Lunn wrote:
>
> Bob Lunn
> 11/05/97 05:56 PM
>
> > So...
> > BEFORE:                 IRP RP1 RP0  TO  PD  Z  DC  C
> > AFTER:   RLF STATUS,F   RP1 RP0  TO  TO  PD DC  Z  IRP
> >
> > And..
> > BEFORE:                 IRP RP1 RP0  TO  PD  Z   DC  C
> > AFTER:   RRF STATUS,F    C  IRP RP1  TO  PD  PD  Z   C
>
>      No, I don't think so.
>
>      The pic uses a read/modify/write mechanism.

I tried it, and it seems that bits 7,6,5 do actually rotate right.
the lower 3 bits don't seem to rotate right.

When rotating left, the TO bit is propagated to the left. The carry
is also propagated into C (as it should), and C propagated into DC.
DC won't propagate into Z (to be expected).

--
Friendly Regards

Tjaart van der Walt
.....tjaartKILLspamspam.....wasp.co.za
_____________________________________________________________
| WASP International http://www.wasp.co.za/~tjaart/index.html |
|       R&D Engineer : GSM peripheral services development    |
|   Vehicle tracking | Telemetry systems | GSM data transfer  |
|    Voice : +27-(0)11-622-8686 | Fax : +27-(0)11-622-8973    |
|              WGS-84 : 26010.52'S 28006.19'E                 |
|_____________________________________________________________|

1997\11\05@053241 by Andrew Warren

face
flavicon
face
Dmitry Kiryashov <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU> wrote:

> I understand how RLF FILE,F command work but i have real puzzle when
> i try to think what RLF(RRF) STATUS,F(W) commands do ? ;)

... and he got a whole BUNCH of responses, all of which I've deleted,
so I'm not sure if anyone actually got it right.

Anyway... If the STATUS register holds ABCDEFGH before the
operation, here's what happens after the various RLF/RRF
instructions:

   After RRF STATUS,W:

       STATUS = ABCDEFGH (unchanged)
            W = HABCDEFG (exactly what you'd expect, if you remember
                that STATUS.0 and the Carry flag are the same thing)

   After RLF STATUS,W:

       STATUS = ABCDEFGH (unchanged)
            W = BCDEFGHH (again, exactly what you'd expect given
                that STATUS.0 is the Carry flag)

   After RRF STATUS,F:

       STATUS = HABDEFGH (just as we saw above, the MSB gets a copy
                of the Carry flag.  /TO and /PD don't change, since
                they're read-only, and DC, Z, and C don't change
                because their protected by logic within the PIC)

   After RLF STATUS,F:

       STATUS = BCDDEFGA (this one's interesting... I wouldn't have
                expected STATUS.0 to have changed, but it does [at
                least on the emulator])

-Andy

=== Andrew Warren - fastfwdspamspam_OUTix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1997\11\05@081627 by Tom Handley

picon face
  Dmitry, the difference determines if the result of a RRF/RLF
affects the W register or a File register. For example:

     RRF    reg,0    ; (W) holds the result
     RRF    reg,1    ; (F) register holds the result

  - Tom

At 01:26 AM 11/5/97 +0300, you wrote:
>Hello Andrew .
>
>> That's how it works.
>[skip]
>
>I understand how RLF FILE,F command work but i have real puzzle
>when i try to think what RLF(RRF) STATUS,F(W) commands do ? ;)
>
>WBR Dmitry.

1997\11\05@114058 by Mike Keitz

picon face
On Wed, 05 Nov 1997 17:10:40 +1000 TONY NIXON 54964
<@spam@Tony.nixonKILLspamspameng.monash.edu.au> writes:
>>For example, clrf STATUS will clear all the page bits, not affect the
>>TO and PD bits, set the Z bit, *and not change C or DC*.  It says so
>>in the Microchip book and also does so on a real chip.  A movwf
>STATUS
>>*will* write to C,DC, and Z, because movwf doesn't inherently affect
>>any status bits.
>
>In my data book...
><snip>
>For example, CLRF STATUS will clear all bits except for TO and PD and
>then set the Z bit and leave STATUS register as 000UU100.

An old data book (1994 paper "Microchip Data Book") agrees with you.  A
newer one (16X84 pdf on the 1996 CD) has the section about the STATUS
register rewritten.  It says:

"If the STATUS register is the destination for an instruction which
modifies the Z, DC, or C bits, then the write to these three bits is
disabled."

"For example, CLRF STATUS will clear the upper three bits and set the Z
bit.  This leaves the STATUS register as 000uu1uu (where u=unchanged)"

My experience with a 1997-made 16F84 has been that CLRF STATUS doesn't
clear the C bit.  I don't know if the old silicon works differently or if
it is a mistake in the old book.

The description in the new book is that if the instruction can change one
or more of the bits, hardware "locks-out" writing to all three.  I would
assume this is true for rotate as well as clear, and, or, add, etc.

1997\11\05@144406 by Bob Lunn

flavicon
face
Bob Lunn
11/06/97 06:45 AM


> If the STATUS register holds ABCDEFGH before...
>
> After RLF STATUS,F:
>
> STATUS = BCDDEFGA (this one's interesting... I wouldn't have
>                    expected STATUS.0 to have changed, but it
>                    does [at least on the emulator])

    Andy, this is EXACTLY what I would expect.

    The definition of RLF is that it changes STATUS.0.  The
    data destination of the instruction is irrelevant to this
    behaviour.

    The carry out bit in your example is 'A'.  Therefore, it
    is 'A' that must appear in STATUS.0.

___Bob

1997\11\05@191320 by Dmitry Kiryashov

flavicon
face
Hello Andrew.

I check your experiment data with real PIC16C63JW chip.

>     After RRF STATUS,W:
>
>         STATUS = ABCDEFGH (unchanged)
>              W = HABCDEFG (exactly what you'd expect, if you remember
>                  that STATUS.0 and the Carry flag are the same thing)
True.

>     After RLF STATUS,W:
>
>         STATUS = ABCDEFGH (unchanged)
>              W = BCDEFGHH (again, exactly what you'd expect given
>                  that STATUS.0 is the Carry flag)
True.

>     After RRF STATUS,F:
>
>         STATUS = HABDEFGH (just as we saw above, the MSB gets a copy
>                  of the Carry flag.  /TO and /PD don't change, since
>                  they're read-only, and DC, Z, and C don't change
>                  because their protected by logic within the PIC)
True.

>     After RLF STATUS,F:
>
>         STATUS = BCDDEFGA (this one's interesting... I wouldn't have
>                  expected STATUS.0 to have changed, but it does [at
>                  least on the emulator])
True.

Some unexpected but interesting results.

WBR Dmitry.

1997\11\05@193425 by Bob Lunn

flavicon
face
Bob Lunn
11/06/97 11:33 AM


> I check your experiment data with real PIC16C63JW chip.
>
>>  After RLF STATUS,W:
>>
>>  STATUS = ABCDEFGH (unchanged)
>>       W = BCDEFGHH (again, exactly what you'd expect given
>>                     that STATUS.0 is the Carry flag)
>
> True.
    Dmitri, I'm now quite confused.

    The function of the RLF instruction is to change the
    carry flag.

    AndyW says the RLF shown above DOESN'T change status.0
    and you confirm his assertion empirically.

    I would have expected the result to be

         STATUS = ABCDEFGA

    Maybe it's because you're both in the northern hemishpere?

___Bob

1997\11\05@212414 by Dmitry Kiryashov

flavicon
face
Hello Bob. Sorry I was really mistake. RLF STATUS,W change Carry.

> >>  After RLF STATUS,W:
> >>
> >>  STATUS = ABCDEFGH (unchanged)
> >>       W = BCDEFGHH (again, exactly what you'd expect given
> >>                     that STATUS.0 is the Carry flag)
> >
> > True.
>      Dmitri, I'm now quite confused.
>      The function of the RLF instruction is to change the carry flag.
>      AndyW says the RLF shown above DOESN'T change status.0
>      and you confirm his assertion empirically.
>      I would have expected the result to be
>
>           STATUS = ABCDEFGA
Yes, you are right. I was scattered when look in my results.

STATUS VALUE    BEFORE RLF_STATUS,W     AFTER RLF_STATUS,W
----------------------------------------------------------
1.              01011101                01011100
2.              10111010                10111011
----------------------------------------------------------

>      Maybe it's because you're both in the northern hemishpere?
No, it was occur because i wanna sleep ;) (Time difference between
USA and Russia is about 8 hours)

WBR Dmitry .

P.S. Thank you for your correction.

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...