XORLW Logic
Bitwise exclusive OR of W with an 8-bit constant, often used to compare W with a value.
| Syntax | XORLW k |
|---|---|
| Operands | k: 8-bit literal 0-255 (0x00-0xFF) |
| Operation | (W) XOR k → W |
| Status bits | Z |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 11 1010 kkkk kkkk |
How it works
XORLW flips the bits of W that are 1 in k. Since a value XORed with itself is 0, XORLW k followed by a test of Z tells you whether W equalled k. W is changed, so reload it before the next comparison.
Example
; XORLW example from picsimulator.com/instructions/xorlw.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0x37
xorlw 0x37 ; W = 0, Z = 1: W was equal to 0x37
Z is set because the values matched.
Open this example in the simulator