INCX - Increment the X Register Command

Increments the value stored in the X register by one and stores it to the X register.
This is useful for things like timer tasks or counting the number of loops executed in a chase.

Syntax

INCX
Notice that there is no value or location attached to this command. It simply increases the value in the X register by 1.

If the value in the X register increments to zero from 255 then the carry flag and the zero flag are set and the minus flag is cleared.

Examples

Example 1

{
LDX #0x02    // Put the fixed hex value 0x02 into the X Register
INCX        // Increment the value in the X Register by 1
            // The X Register now contains the value 0x03
}

Example 2

Track the loops of a chase.

{
Area=11             //Set Default Area to 11 (RGB Lights)
Delay=1.5           //Set Default Delay time to 1.5s
Fade=1              //Set Default Fade time to 1s
LDX #0              //Reset the counter
Loop:
    Preset(P=5)     //Recall Preset 5 (Red)
    Delay()         //Delay between colors
    Preset(P=6)     //Recall Preset 6 (Yellow)
    Delay()
    Preset(P=7)     //Recall Preset 7 (Green)
    Delay()
    Preset(P=8)     //Recall Preset 8 (Teal)
    Delay()
    Preset(P=9)     //Recall Preset 9 (Blue)
    Delay()
    Preset(P=10)    //Recall Preset 10 (Magenta)
    Delay()
    INCX            //Increment the value by 1.
    CMPX #LoopTotal //Compare it to the max number of loops
    BRZ END         //If equal to then end
    BRA Loop        //Loop back to the top and repeat.
    Null
        END:
            Null
}