Detailed reference for the SUBLW instruction in PIC18 ISA.
Subtract the contents of WREG from an 8‑bit literal constant k. The result is written back to WREG.
WREG = k - WREG.; From literal, WREG=5, literal=10 → W=5
MOVLW 0x05
SUBLW 0x0A; From literal, WREG=5, literal=10 → W=5
MOVLW 0x05
SUBLW 0x0A; Underflow, WREG=2, literal=0 → W=0xFE
MOVLW 0x02
SUBLW 0x00; Underflow, WREG=2, literal=0 → W=0xFE
MOVLW 0x02
SUBLW 0x00; Borrow across the high byte, WREG=0xFF, literal=0x80 → W=0x81
MOVLW 0xFF
SUBLW 0x80; Borrow across the high byte, WREG=0xFF, literal=0x80 → W=0x81
MOVLW 0xFF
SUBLW 0x80; Zero result, WREG=0, literal=0 → W=0
MOVLW 0x00
SUBLW 0x00; Zero result, WREG=0, literal=0 → W=0
MOVLW 0x00
SUBLW 0x00; Literal pre‑load then subtract, result in W
MOVLW 0x12
SUBLW 0x20 ; W = 0x20 - 0x12 = 0x0E; Literal pre‑load then subtract, result in W
MOVLW 0x12
SUBLW 0x20 ; W = 0x20 - 0x12 = 0x0E