CLRF Data Movement
Set a file register to zero.
| Syntax | CLRF f |
|---|---|
| Operands | f: register address 0-127 (bank bits come from STATUS) |
| Operation | 00h → f, 1 → Z |
| Status bits | Z |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 00 0001 1fff ffff |
How it works
CLRF writes 0 to register f and always sets Z. It is the shortest way to zero a counter, clear a port or make every pin of a port an output (CLRF TRISB, in bank 1).
Example
; CLRF example from picsimulator.com/instructions/clrf.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0x55
movwf 0x20
clrf 0x20 ; 0x20 = 0, Z = 1
RAM 0x20 is 0 and Z is set.
Open this example in the simulator
Watch out for
- Bits that are read-only in a register (such as TO and PD in STATUS) aren't cleared by CLRF.