Skip to content

Instantly share code, notes, and snippets.

@actraiser
Last active May 6, 2021 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save actraiser/1524478f770ce9c6fc01 to your computer and use it in GitHub Desktop.
Save actraiser/1524478f770ce9c6fc01 to your computer and use it in GitHub Desktop.
Zeropage Addressing
; When Addressing Modes use 8-Bit in favour of 16-Bit encoded locations
; they are commonly called Zeropage addressing modes
; Example: Zeropage Indirect Indexed Addressing
; Fill the whole screen with Spaces.
ldx #$04 ; load X-Register via Immediate Addressing
sta $fb ; store into $fb via Zeropage Addressing
lda #$04 ; load Accumulator via Immediate Addressing
sta $fc ; store into $fc via Zeropage Addressing
lda #$20 ; load Y-Register Spacebar code via Immediate Addressing
loop sta ($fb),y ; store Accumulator value by Zeropage Indirect Indexed Addressing
iny ; increase Y by implied Addressing
bne loop ; branch to loop until 255 locations have been addressed via Relative Addressing
inc $fc ; Increase most significant Byte to point to next page in Screen RAM
dex ; decrease X-Register by implied Addressing
bne loop ; branch to Loop to continue filling the screen with Spaces via Relative Addressing
rts ; after four rounds we are done and return
@mcaserta
Copy link

mcaserta commented May 6, 2021

Am I correct in assuming the chip registers are somehow reset to #$00 before the object code is run? Because your code seems to make this assumption. I was expecting, for instance, an lda #$00 before sta $fb on line 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment