PIC18 cheatsheet

ADDWFC

Detailed reference for the ADDWFC instruction in PIC18 ISA.

Description

Add the contents of WREG and the carry bit to file register f.

  • d = 0 → result is stored in WREG.
  • d = 1 → result is stored back into register f.
  • a = 0 → Access‑bank addressing.
  • a = 1 → Banked addressing.
  • The carry flag is updated based on the result.

Examples

; d=0, a=0  → result in WREG, Access bank
ADDWFC 0x20, 0, 0   ; W = W + 0x20 + C
; d=0, a=1  → result in WREG, Banked address
ADDWFC 0x20, 0, 1   ; W = W + 0x20 + C
; d=1, a=0  → result back to file register, Access bank
ADDWFC 0x20, 1, 0   ; 0x20 = 0x20 + W + C
; d=1, a=1  → result back to file register, Banked address
ADDWFC 0x20, 1, 1   ; 0x20 = 0x20 + W + C
; Load literal into WREG then add, result in WREG (Access bank)
MOVLW 0x10
ADDWFC 0x20, 0, 0   ; W = W + 0x20 + C