menu_top_normal
NeoLoch Home Page
Home Inquisitor Tester Learning Lab Consulting Shipping Policy Contact us Support ----------------------
News
Coming soon! 9060 Blade.
INCF Command:
Syntax:
Status Flags Effected:
INCF
INCF f,d
Z

The INCF command increments (counts up) the register specified by f. If d is equal to 0 then the result is stored in the working register, if d is equal to 1, then the result is stored in the register specified by f.

Code Example 1: Assume we have a register labeled COUNT. The following command will increment the value currently stored in COUNT and then store the new value in the same register.
INCF         COUNT,1
Increment COUNT and store the new value in COUNT.

Code Example 2: The following command is identical, but now the resulting value is stored in the working (w) register.
INCF        COUNT,0 Increment COUNT and store the new value in the working register.

This command effects the z (zero) flag in the status register. If resulting value is zero, then the Z flag will be set, and if it's not zero then the Z flag will be clear.

INCFSZ Command:
Syntax:
Status Flags Effected:
INCFSZ
INCFSZ f,d
NONE

The INCFSZ operates almost identical to the DECF command, but if the resulting value from the increment is zero, then the next command will be skipped. INCFZ can also be used for control loops that need to execute a certain number of times.

Code Example 3: The following example illustrates using the INCFSZ command to send eight high and low pulses out of the PORTA, BIT 0 pin.
MOVLW     0XF7
MOVWF     COUNT
BSF              PORTA,0
NOP
BCF             PORTA,0
INCFSZ      COUNT,1
GOTO          $-4
RETURN
Load the working register with the hex value of 8.
Load the register COUNT with the value 8.
Turn bit 0 of PORT A on.
Leave the bit on for a little while.
Turn off bit 0 of PORTA.
Increment F and store the new value in F. Does COUNT = 0?
No - Jump back 4 commands and do them again.
Yes - Exit routine and move on.










All contents of this website are copyrighted 2010-2018 NeoLoch