Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18 to PIC16 asm instructions

Status
Not open for further replies.

augustinetez

Active Member
I know there used to b a 16F to 18F migration document on the Microchip website at one stage, but I'm buggered if I can find anything on that site anymore.

So quick (dumb-ish) question - is RRCF in 18F asm the same as RRF in 16F asm?

Reading the datasheets seems to indicate it is, just want to make sure I'm not missing something.

As for why do I want to know - converting this to use in a 12F chip:-

Code:
16-bit random generator (tested)

The 0xA1 is part of a prime polynom value 0xA1A1 which generates a full LFSR

Random:
    BCF     STATUS,C   
    RRCF    LFSRVALUEH,F
    RRCF    LFSRVALUEL,F
    BTFSS   STATUS,C
    RETURN
    MOVLW   0xA1
    XORWF   LFSRVALUEH
    XORWF   LFSRVALUEL   
    RETURN
 
So quick (dumb-ish) question - is RRCF in 18F asm the same as RRF in 16F asm?
It's not a dumb question, they are the same.

I think that the name RRCF, Rotate Right f through Carry, is to distinguish it from RRNCF, Rotate Right f (No Carry).

RRNCF has no equivalent in 16F asm, so there the RRF just means Rotate Right f through Carry.

RRNCF would be incorrect in your code as the carry bits wouldn't do anything and the code would always return with the carry bit clear.
 
You can mimic RRNCF in pic16 by doing,
RRF file,w
RRF file,f
first instruction moves bit 0 into carry and the second moves the file content and moves bit 0 into bit 7.
Not relevant to this question but may be useful down the line.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top