COMF Logic
Invert every bit of a file register.
| Syntax | COMF f, d |
|---|---|
| Operands | f: register address 0-127 (bank bits come from STATUS); d: 0 or w puts the result in W, 1 or f puts it back in f |
| Operation | NOT (f) → destination |
| Status bits | Z |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 00 1001 dfff ffff |
How it works
COMF takes the one's complement of register f: every 1 becomes 0 and every 0 becomes 1. Z is set if the result is 0 (the register was 0xFF). For a two's complement negate, follow COMF with INCF.
Example
; COMF example from picsimulator.com/instructions/comf.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0x0F
movwf 0x20
comf 0x20, f ; 0x20 = 0xF0
Each bit is inverted.
Open this example in the simulator