INC - Increment the Accumulator Command
Increments the value in the accumulator by one and stores it to the accumulator.
This is useful for things like timer tasks or counting the number of loops executed in a chase. Same effect as an ADD 1 command.
Syntax
INC
Notice that there is no value or location attached to this command. It simply increases the value in the accumulator by 1.
If the value in the accumulator increments to zero from 255 then the carry flag and the zero flag are set and the minus flag is cleared. |
Examples
Example 1
This sequence is handy for tracking what step in a sequence we are in.
{
LDA ~1 //Load the value in memory location ~1 into the accumulator.
INC //Increment the value by 1.
STA ~1 //Store back into ~1.
}
Example 2
This task is a timer in minutes that allows you to set the duration in a template.
{
LDA #0 //Load a value of 0 to clear the timer.
STA $Timer //Store it.
DURATION_LOOP:
LDA $Timer //Load the timer
CMP #Duration //Compare it to the max duration
BCC COMPLETE //If greater then end
Delay(60) //Delay one minute
INC //Increase the timer count by 1 min
STA $Timer //Store it.
BRA DURATION_LOOP
Null
COMPLETE:
LDA #0 //Load that we are complete
STA $Feature_State //Store it.
Preset(A=4,P=3) //Turn off the thing we were doing.
END:
Null
}
Example 3
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
LDA #0 //Reset the counter
STA ~1
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()
LDA ~1 //Load the value in memory location ~1 into the accumulator.
INC //Increment the value by 1.
STA ~1 //Store back into ~1.
CMP #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
}