The compiled code for the FOR..NEXT statement has a bug if the STEP isn't 1, which causes the loop to end before it should.
For example, the following compiled code runs as intended-- three playfield pixels are drawn in a diagonal line:
.L01; for a=1 to 3 step 1:pfpixel a a on:next LDA #1 STA a .L01fora LDX a LDY a LDA #0 jsr pfpixel LDA a CMP #3 INC a bcc .L01fora
Note that the CMP statement occurs *before* the variable gets incremented, which is okay, because the STEP is 1, so there's no chance the INC statement will go beyond the final desired value.
However, this next compiled code does *not* run as intended-- only one playfield pixel gets drawn:
.L01; for a=1 to 3 step 2:pfpixel a a on:next LDA #1 STA a .L01fora LDX a LDY a LDA #0 jsr pfpixel LDA a CLC ADC #2 STA a CMP #3 bcc .L01fora
Note that the CMP is done *after* the variable has been increased, which is the way it should be-- except the BCC statement branches only if the result is *less* than the final desired value, but the loop should repeat if the result is less than or *equal* to the final desired value. So to correct the bug, the compiled code needs to include a BEQ to the label, either before or after the BCC:
bcc .L01fora beq .L01fora
Until the bug gets fixed, the workaround is to add 1 to the final desired value (i.e., "FOR A=1 TO 4 STEP 2" when we actually want to stop after 3). The only problem would be if the final desired value were 255.