Search code examples
cmicrochipinterruptpic18

Assembler to C conversion INCF and CPFSLT


Does these's two codes mean the same?

Assambler ->

_asm
    INCF PR4,0,ACCESS
    CPFSLT TMR4,ACCESS
_endasm

C ->

++PR4;
if (PR4 < TMR4)
   PIR3bits.TMR4IF = 1;

If not, how should the assambler code be translated?

Kind regards :)


Solution

  • Could anyone else verify this, I think the code below is correct!

    _asm
        INCF PR4,0,ACCESS  //PR4+1 destination WREG, Access bank
        CPFSLT TMR4,ACCESS //Compare TMR4 with contents of WREG in Access bank, Skip if TMR4 < WREG
    _endasm
    /* Above says: if (TMR4 <= PR4 + 1)*/
        PIR3bits.TMR4IF = 1; // Then do this line