define SRC_LO $00 define SRC_HI $01 define DEST_LO $02 define DEST_HI $03 define temp $04 ;temp storage used by foo ;some prep work since easy6502 doesn't allow you to define arbitrary bytes before runtime. SET_TABLE: TXA STA $1000,X INX BNE SET_TABLE ;stores the identity table at memory address $1000-$10FF CLEAR_TABLE: LDA #0 STA $1200,X INX BNE CLEAR_TABLE ;fills the range $1200-$12FF with zeroes. LDA #$10 STA SRC_HI LDA #$00 STA SRC_LO ;store memory address $1000 in zero page LDA #$12 STA DEST_HI LDA #$00 STA DEST_LO ;store memory address $1200 in zero page loop: LDA (SRC_LO),y ;load accumulator from memory address $1000+y JSR foo ;multiplies accumulator by 3. STA (DEST_LO),y ;store accumulator in memory address $1200+y INY CPY #$56 ;alternatively you can store a size variable and check that here instead. BCC loop BRK foo: STA temp ASL ;double accumulator CLC ADC temp ;2a + a = 3a RTS