DECFSZ

Decrement f, Skip if 0

The contents of register ‘f’ are decremented. If ‘d’ is ‘0’, the result is placed in the W register. If ‘d’ is ‘1’, the result is placed back in register ‘f’. If the result is ‘1’, the next instruction is executed. If the result is ‘0’, then a NOP is executed instead, making it a 2 TCY instruction.

[the_ad id="3059"]

Syntax:

[ label ] DECFSZ f,d

Operation:

(f) - 1 → (destination);
skip if result = 0

Operands:

  • f is from 0 to 127 (decimal)
  • d can be either 0 or 1

Status Affected: None

Example:

DECFSZ REG,0
GOTO SUB1
GOTO SUB2

Before instruction:

REG = 0x0A
W = 0x01

After instruction:

REG = 0x0A
W = 0x09

The result is not zero, therefore, the line GOTO SUB1 is read.

[the_ad id="3059"]

Example:

DECFSZ REG,1
GOTO SUB1
GOTO SUB2

Before instruction:

REG = 0x01
W = 0x01

After instruction:

REG = 0x00
W = 0x01

The result is zero, hence the line GOTO SUB1 is skipped and the program jumps to GOTO SUB2.