RET, RETFI, RETW

 

RET                        Return from subroutine


Words:        1        Cycles:        2                Affects:        none

 

Operation:        The next stack value is moved into the program counter. On '5x devices, W is cleared to 0.

 

Coding:        '5x        RETLW        0

       'xx        RETURN

 

 

RETI                        Return from Interrupt


Words:        1        Cycles:        2                Affects:        none

 

Operation:        The next stack value is moved into the program counter.  Interrupts are enabled by setting the Global Interrupt Enable bit, GIE (INTCON.7).

 

Coding:        'xx        RETFIE

 

 

RETW        literal1,literal2,...      Assemble RET’s which load W with literal data


Words:        ?        Cycles:        2 per RETLW        Affects:        none

 

Operation:        A list of RET's with literal data in the W area is assembled, which can be accessed by JMP PC+W or JMP W instructions. This is useful for lookup tables.

 

Coding:        RETLW        literal1

       (RETLW        literal2)

       (RETLW        ...)

 

Example:        jmp        pc+w        ;Jump to byte at location pc+w

 

       retw        00100011b        ;Return with w holding appropriate

       retw        00h,01h,02h,03h        ;value

       retw        "Enter cycle count"