PIC18 cheatsheet

BRA

Detailed reference for the BRA instruction in PIC18 ISA.

Description

Branch (BRA) – unconditional relative branch.

  • The BRA instruction alters the program counter (PC) by a signed 8‑bit displacement relative to the following instruction.
  • The operand is a label; the assembler computes the displacement.
  • It takes 2 bytes: opcode 0x80 followed by the 8‑bit offset.
  • No options (d or a).

Examples

; forward branch to FWD_LABEL
BRA FWD_LABEL   ; branch to FWD_LABEL
; backward branch to START
BRA START   ; return to START
; branch to the next instruction (offset 0)
BRA NEXT_INSTR   ; no operation, PC remains at NEXT_INSTR
; branch near maximum negative offset
BRA NEG_LIMIT   ; jumps back 126 bytes