# PIC programming

We are searching data for your request:

Forums and discussions:
Manuals and reference books:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.

## DECFSZ command

Decrement and jump at zero
Tab. 1
Syntax: DECFSZ f, d 0 ≤f ≤ 127 d = [0.1] (f) - 1 → d jump if result = 0 1(2) 1 no 00 1011 dfffffff

The addressed register is decremented and the result is then stored in the same register (d = 1) or in the W register (d = 0). If zero was generated when decrementing, and this is the specialty of this command, the next command is skipped.

When using this command, it is important that the parameter "d" is always set to 1, otherwise the result will not appear in the register again. Consequently this remains the same and can never reach the value zero. With the help of this command, a loop, similar to a FOR loop, can be set up very comfortably, as shown in the following example.

example
LOOPDECFSZ OPERAND, 1; the OPERAND register is decremented GOTO LOOP; Jump to the beginning of the loop if the operand is zero; if OPERAND = 0 it continues here