RETURN Control Flow

Return from a subroutine.

SyntaxRETURN
Operandsnone
Operationtop of stack → PC
Status bitsNone
Words / cycles1 word, 2 cycles
Encoding00 0000 0000 1000

How it works

RETURN pops the most recent return address from the hardware stack into the program counter, continuing after the CALL that entered the subroutine. W and STATUS are unchanged.

Example

; RETURN example from picsimulator.com/instructions/return.html
    list p=16f84a
    include <p16f84a.inc>

    org 0
    clrf 0x20
    call bump
    call bump         ; 0x20 = 2
done:
    goto done
bump:
    incf 0x20, f
    return

The subroutine runs twice, so 0x20 counts to 2.

Open this example in the simulator

Watch out for

  • Use RETFIE, not RETURN, to leave an interrupt routine: RETURN would leave GIE cleared.

Related instructions