Detailed reference for the NEGF instruction in PIC18 ISA.
Negate the contents of a byte‑wide file register f. The two's complement is written back to the same register. The result is always stored in the file register – there is no separate destination option.
a = 0 → access‑bank addressing.a = 1 → banked addressing.; a=0 → negate a register in the access bank
NEGF 0x20, 0 ; 0x20 = 0 - 0x20; a=0 → negate a register in the access bank
NEGF 0x20, 0 ; 0x20 = 0 - 0x20; a=1 → negate a register in the banked address space
NEGF 0x20, 1 ; 0x20 = 0 - 0x20; a=1 → negate a register in the banked address space
NEGF 0x20, 1 ; 0x20 = 0 - 0x20; Load literal into WREG, copy to a register and negate (Access bank)
MOVLW 0x10
MOVWF 0x20, 0
NEGF 0x20, 0 ; 0x20 = 0 - 0x10; Load literal into WREG, copy to a register and negate (Access bank)
MOVLW 0x10
MOVWF 0x20, 0
NEGF 0x20, 0 ; 0x20 = 0 - 0x10; Load literal into WREG, copy to a register and negate (Banked addressing)
MOVLW 0x10
MOVWF 0x20, 1
NEGF 0x20, 1 ; 0x20 = 0 - 0x10; Load literal into WREG, copy to a register and negate (Banked addressing)
MOVLW 0x10
MOVWF 0x20, 1
NEGF 0x20, 1 ; 0x20 = 0 - 0x10; WREG pre‑loaded with a literal value, moved to a register and negated
MOVLW 0x55
MOVWF 0x20, 0
NEGF 0x20, 0 ; 0x20 = 0 - 0x55; WREG pre‑loaded with a literal value, moved to a register and negated
MOVLW 0x55
MOVWF 0x20, 0
NEGF 0x20, 0 ; 0x20 = 0 - 0x55