Back in the 80s, I knew this instruction set well.
February 27, 2025 · First shared on Facebook

Back in the 80s, I knew this instruction set well. The 6502 only ran at 1 Mhz, so if you wanted to do anything fast, you had to do it in 6502 assembly language. For what the 6502 lacked in registers, it offered the zero page, and for what it lacked for speed, it offered instruction efficiency. You would code loops to run backwards because when a decremented register reached zero, the zero flag would be set, so you could make branch decisions without a compare instruction.
Yesterday I was writing some 6502 to hook the ProDOS operating system so I could intercept an OS call. But instead of doing it on the Apple //, I did it on the AppleWin emulator because it gives you a full debugger with real breakpoints. Something you only got with expensive ICEs, In-Circuit Emulators, back in the day. Back in the early 80s I didn’t have access to those, so debugging was much more time consuming. 6502, Z80, 8051, 8080, 8088, NEC7811 were a few of the microprocessors I coded in assembler. C was a godsend when I finally started using it around 1985.
I wrote the most assembler in 6502 (Apple II) and Z80 (ColecoVision, Sun Electric’s Point of Sale system for Gas Stations). Those opcodes and cycle counts are still rattling around in my mind after all these years lol!
6502 vs Z80, which was your favorite:
The 6502 and Z80 are two iconic 8-bit microprocessors from the 1970s, and comparing their average clock cycles per instruction (CPI) is a great way to understand their performance characteristics. Let’s break it down.
The 6502, designed by MOS Technology, is known for its simplicity and efficiency. Its instruction set is relatively small, with most instructions taking between 2 and 7 clock cycles to execute. Simple operations like register loads (e.g., LDA immediate) take 2 cycles, while more complex ones like indexed addressing with page boundary crossing (e.g., LDA absolute,X) can take up to 7 cycles. Due to its design, the 6502 doesn’t fetch a new instruction every cycle—it overlaps fetch and execution, which boosts efficiency. Estimates for the average CPI typically range around 3 to 4 cycles, depending on the mix of instructions in a program. Real-world usage, like in the Apple II or Commodore 64, often leaned toward simpler addressing modes, keeping the average closer to 3.
The Z80, designed by Zilog, is a more complex beast, building on the Intel 8080. It has a larger instruction set with a wider range of cycle counts—anywhere from 4 to 23 cycles per instruction. Basic operations like an 8-bit register load (e.g., LD A,B) take 4 cycles, while more involved instructions like 16-bit arithmetic (e.g., ADD HL,BC) take 11 cycles, and some prefix instructions (e.g., bit manipulation like SET n,(HL)) can hit 23 cycles. The Z80 fetches and executes instructions sequentially without the same overlap as the 6502, so its CPI tends to be higher. Studies and benchmarks, like those from retro computing enthusiasts, suggest an average CPI of about 4 to 6 cycles, skewed higher by its richer instruction set and frequent use of multi-cycle operations in software like CP/M.
Direct comparison is tricky because CPI depends heavily on the specific program and how well it leverages each CPU’s strengths. The 6502 shines with tight loops and simple addressing, often averaging around 3 cycles in optimized code. The Z80, with its more versatile instruction set, typically averages closer to 5 cycles but offers more flexibility for complex tasks. In practical terms, a 1 MHz 6502 might execute around 333,000 instructions per second (1M / 3), while a 1 MHz Z80 might hit 200,000 (1M / 5)—though real-world mileage varies.
So, in short: the 6502 generally has a lower average CPI (around 3–4) compared to the Z80 (around 4–6), reflecting its leaner design versus the Z80’s broader capabilities. Which one’s “better” depends on what you’re coding!


Tags: prodos, history, software