Hello all. I'm just sinking my teeth into 6502 and I thought a good idea for a simple starter program was to write one that could fill a screen. My various attempts failed because I'm an idiot and didn't know how to properly reference 16 bit addresses. So, I found a program that does what I was trying to do so I could try to reverse engineer it a bit, but it just left me with more questions. Here's the code I found:
Code:
lda #1
ldx #$02
fill_screen:
stx $01
draw_segment:
sta ($00),Y
iny
bne draw_segment
inx
cpx #$06
bne fill_screen
As I understand it, the X register being stored at $01 represents the first half of the 16 bit address being referenced, which is then combined(?) with the increasing Y value. Starting at $0200 and increasing with each loop until reaching the end of the vram at $05FF. However, I don't understand how this works. The indirect indexed reference
Code:
sta ($00),Y
is referencing $00, which stores nothing. Shouldn't it be
Code:
sta ($01),Y
? And in draw_segment, there is a branch not equal instruction with no compare instruction before it? What is the branching condition?
All of this is probably very simple to anyone versed in machine languages, but that's why I'm in the newbies board. Try and go easy on me.