We are searching data for your request:
Upon completion, a link will appear to access the found materials.
- 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.
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