Code:
reset:
sei ; ignore IRQs
cld ; disable decimal mode
ldx #$40
stx $4017 ; disable APU frame IRQ
ldx #$ff
txs ; Set up stack
inx ; now X = 0
stx $2000 ; disable NMI
stx $2001 ; disable rendering
stx $4010 ; disable DMC IRQs
I was wondering how x became zero in this bit of code.
First x contains #$40
After the stx $4017 ; #$40 still in the x reg?
Then ldx #$ff ; x now contains 255?
Then txs ; transfering the contents (#$ff) of x reg to stack?
x still contains 255?
Then inx ; does x reset back to 0 (255 + 1 =0) here?
Thanks,
T