ANDLW Logic

Bitwise AND of W with an 8-bit constant.

SyntaxANDLW k
Operandsk: 8-bit literal 0-255 (0x00-0xFF)
Operation(W) AND k → W
Status bitsZ
Words / cycles1 word, 1 cycle
Encoding11 1001 kkkk kkkk

How it works

ANDLW masks W with the literal k: bits that are 0 in k are cleared in W. Z is set if nothing is left.

Example

; ANDLW example from picsimulator.com/instructions/andlw.html
    list p=16f84a
    include <p16f84a.inc>

    org 0
    movlw 0xA5
    andlw 0x0F        ; W = 0x05

Only the low nibble of 0xA5 survives.

Open this example in the simulator

Related instructions