Ok, so this is a relatively simple operation. I'm new to 6502 machine (or for that matter machine code in general), so take it easy.
I'm trying to copy a chunk of memory (8192 bytes to be exact), here is my code:
lda #$00 ;set our source memory address to copy from, $8000
sta $FB
lda #$80
sta $FC
lda #$00 ;set our destination memory to copy to, $6000, WRAM
sta $FD
lda #$60
sta $FE
ldy #$00 ;reset x and y for our loop
ldx #$00
Loop:
lda [$FB],Y ;indirect index source memory address, starting at $00
sta [$FD],Y ;indirect index dest memory address, starting at $00
inc $FB ;increment low order source memory address byte by 1
inc $FD ;increment low order dest memory address byte by 1
bne Loop ;loop until our dest goes over 255
inc $FC ;increment high order source memory address, starting at $80
inc $FE ;increment high order dest memory address, starting at $60
lda $FE ;load high order mem address into a
cmp #$80 ;compare with the last address we want to write
bne Loop ;if we're not there yet, loop
forever: ;once we finish with memory loop forever
jmp forever
I'm sure there is a better way to do this... But this should work (I think), can anyone see why?
Thanks
I'm trying to copy a chunk of memory (8192 bytes to be exact), here is my code:
Quote:
lda #$00 ;set our source memory address to copy from, $8000
sta $FB
lda #$80
sta $FC
lda #$00 ;set our destination memory to copy to, $6000, WRAM
sta $FD
lda #$60
sta $FE
ldy #$00 ;reset x and y for our loop
ldx #$00
Loop:
lda [$FB],Y ;indirect index source memory address, starting at $00
sta [$FD],Y ;indirect index dest memory address, starting at $00
inc $FB ;increment low order source memory address byte by 1
inc $FD ;increment low order dest memory address byte by 1
bne Loop ;loop until our dest goes over 255
inc $FC ;increment high order source memory address, starting at $80
inc $FE ;increment high order dest memory address, starting at $60
lda $FE ;load high order mem address into a
cmp #$80 ;compare with the last address we want to write
bne Loop ;if we're not there yet, loop
forever: ;once we finish with memory loop forever
jmp forever
I'm sure there is a better way to do this... But this should work (I think), can anyone see why?
Thanks