PIC18 cheatsheet

RETLW

Detailed reference for the RETLW instruction in PIC18 ISA.

Description

Load an 8‑bit literal value into WREG and return from the current subroutine.

  • The register WREG is overwritten with the specified literal.
  • The processor then performs the equivalent of a retfie/return by popping the return address from the stack and loading it into the program counter.
  • The operand is an 8‑bit immediate value.
RETLW literal

Examples

; Return with literal 0x27 in WREG
RETLW 0x27    ; WREG = 0x27, PC = return address