Chemistry

PIC programming

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
DECFSZ: decrement f and jump to 0
Syntax:DECFSZ f, d
Operands:0 ≤f ≤ 127 d = [0.1]
Surgery:(f) - 1 → d jump if result = 0
Cycles:1(2)
Words:1
Affected flags:no
Code: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


Video: Baseline PIC C programming lesson 1 - Flash an LED (July 2022).


Comments:

  1. Norvin

    I consider, that you are not right. I am assured. Let's discuss it. Write to me in PM.

  2. Escanor

    I join. It was and with me.



Write a message