PIC18 cheatsheet

GOTO

Detailed reference for the GOTO instruction in PIC18 ISA.

Description

Jump unconditionally to the given program memory address.

  • The goto instruction causes the program counter (PC) to be set to the 22‑bit operand k.
  • Execution continues at the target location without affecting any data registers or status bits.
  • The operand can be an absolute address or a label that the assembler resolves to an address.

Examples

; Goto absolute address 0x1234
GOTO 0x1234 ; PC = 0x1234
; Goto label defined later in the code
GOTO LOOP_START ; PC = address of LOOP_START
; Goto label with an EQU constant
PAGE equ 0x2000
GOTO PAGE ; PC = 0x2000
; Goto a relative label using back‑reference
GOTO END
;
END: ; Execution continues here after the jump