Code:
0200: A9 00 START: LDA #0
0202: 85 00 STA PILEN
0204: 18 CLC
0205: 20 00 01 NXKEY: JSR GETKEY
0208: C9 0F CMP #15
020A: D0 05 BNE NXTST
020C: 20 87 02 JSR BEEP3
020F: 90 EF BCC START
0211: C9 0E NXTST: CMP #14
0202: 85 00 STA PILEN
0204: 18 CLC
0205: 20 00 01 NXKEY: JSR GETKEY
0208: C9 0F CMP #15
020A: D0 05 BNE NXTST
020C: 20 87 02 JSR BEEP3
020F: 90 EF BCC START
0211: C9 0E NXTST: CMP #14
The part that has me confused is line 6. BNE's opcode is D0 so no problem there, but what has me confused is the 05 following. By my math, it is coming up one short of NXTST. However, I'm thinking that when the CPU reads the '05' it then moves onto the next slot before counting? Would that be the case?
Also, with BCC START, given START's position, you would get 02FF (or 0300 if current address is incremented by one after reading EF) and if START is at 0200, how exactly does that work? I'm thinking it kind of just rolls over back to 0200 instead of going to 0300.