CLRW Data Movement
Set the W register to zero.
| Syntax | CLRW |
|---|---|
| Operands | none |
| Operation | 00h → W, 1 → Z |
| Status bits | Z |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 00 0001 0xxx xxxx |
How it works
CLRW clears W and sets Z. MOVLW 0 also zeroes W but leaves Z alone, so pick CLRW when later code tests Z.
Example
; CLRW example from picsimulator.com/instructions/clrw.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0x55
clrw ; W = 0, Z = 1
W is 0 and Z is set.
Open this example in the simulator