Need help with a loop that has 16 bit counter
Posted: Tue Sep 09, 2014 5:27 am
So, I'm trying to make a loop that counts to 960 (decimal), but I have never used 16 bit numbers so far, so I have no idea how to do it. What the loop is supposed to do is that it loads data from different location with indexed X addressing mode and stores it to $2007 (which automatically stores the data to pre-defined location and stores the next data to the next slot). Here is example (8 bit tough):
LDA $2002 ; Reset High/Low latch
LDA #$20 ; Defines high and low bytes
STA $2006
LDA #$00
STA $2006
LDX #$00 ; Load 0 to X for loop
DrawBackground: ; Loop for drawing background
LDA background, x
STA $2007
INX
CPX #$FF
BNE DrawBackground ; Branch to DrawBackground if X is less than $FF
LDA $2002 ; Reset High/Low latch
LDA #$20 ; Defines high and low bytes
STA $2006
LDA #$00
STA $2006
LDX #$00 ; Load 0 to X for loop
DrawBackground: ; Loop for drawing background
LDA background, x
STA $2007
INX
CPX #$FF
BNE DrawBackground ; Branch to DrawBackground if X is less than $FF