https://imapenguin.com/how-fast-can-a-6502-transfer-memory/ Imapenguin * Home * How To * Retro * Software * Downloads * FAQ Subscribe C64 How fast can a 6502 transfer memory * Michael Doornbos Michael Doornbos Jun 14, 2022 * 8 min read Marketing Parody Image by Gregorio Nacu at c64os.com Image by Gregorio Nacu at c64os.com The amazing Gregorio Nacu posted the article title graphic this week to bring attention to the venerable 6502 processor and poke fun at Apple's M2 chip marketing slides. He's doing probably the most ambitious single-person Commodore 64 project I know of and has a fantastic blog. Apple claims the new M2 chip has the following specs. M2 features Image by Apple via YoutubeM2 features Image by Apple via Youtube We all know that these numbers are probably a little fluffy. Maybe a lot fluffy, and in practical applications, they are probably pretty far off. Benchmarking in a lab is fine, but the numbers rarely reflect real-world performance. Tom's hardware does an excellent breakdown on this new chip. It does look pretty neato! How fast is a 6502? After Gregorio posted this image earlier this week, it sparked a fair amount of discussion on the interwebs about the memory transfer speed of a 6502 processor. The 6502 on Commodore machines shares the clock with the video chip. Since dual ported ram wasn't financially feasible at the time, they chose a memory access trick that allowed both the video chip and processor to access memory during a single clock cycle. I think it's the same on most Commodores, but on the VIC-20, the processor accesses the memory on the low part of the signal and the VIC chip on the high part. Maybe that's backward... anyhoo, you get the point. [image]VIC-20 PAL Clock signal from the 6561 Memory at 1MB per second Going back to the slide, this 1Mhz memory bandwidth is what folks are questioning. On every clock cycle, the 6502 reads memory from somewhere... the stack, registers, program counter, memory locations, etc. So at 1 Mhz, typical for Commodore machines, this 1MB per second bandwidth is probably accurate in a vacuum, where marketing people hang out. [20d09557-8311-4239-91ec-6232d07102bd-2]Image by Gregorio Nacu at c64os.com It's important to note that Gregorio Nacu's slide was a parody and not intended to be a hard numbers accurate kind of thing. Please remember that because if you don't, the rest of this discussion will ruffle your feathers. Testing real-world block transfers We'll try some memory transfers to get an idea of what actual transfer speeds might look like using standard Commodore hardware. Other 6502-based platforms might be faster or slower, so I encourage you to try some tests of your own, and please let me know what you find. Again, remember that transferring memory takes more clock cycles than just reading or writing... The Commodore 64 Version Let's give this a go on the most popular 6502-based system of all time, the Commodore 64. [IMG_1403]Everyone has a heads-up display for their Commodore 64 these days. The transfer We'll take a queue right from the venerable Rodney Zaks. [IMG_4130] Incidentally, Robin did a long video fixing this book's implementation bug. I'll be using the revised version as I think it's a well-established example of doing a real-world block transfer. Sure there may be faster ways, but this is a realistic way, which is what we're going for. [IMG_4131] You can read this excellent chapter on how this works, and Robin's video goes into it in great detail. Here's what we're going to do: source = $0800 dest = $4800 len = $4000 from = $fb to = $fd tmpx = $a6 copyr .block lda #source sta from+1 lda #dest sta to+1 ldy #0 ldx #>len beq remain next lda (from),y sta (to),y iny bne next inc from+1 inc to+1 dex bne next remain ldx #