Animated 6502 Block Diagram (http link)
run a transistor-level simulation of the MOS Technology 6502 and shows the internal state on Donald Hanson's Block Diagram. Runs in a (modern) webbrowser.
If you want to see it run ehbasic, press the run button and switch to the I/O tab. Type "c4000" into the text box, press enter, and then unfocus the texbox. This will send the input needed to get you to READY. Give it some time, it is slow. Type your program into the textbox then unfocus the textbox to start sending input. You will see the input being consumed character by character from the textbox.
If you want to see how an instruction executes, switch to the RAM tab, select "empty (4k)". Start entering instructions into memory starting at address 0. To do this, double click on a cell in the table then enter a new hexadecimal value. Unfocus the textbox to save the value. Switch back to the processor tab and use the step and back button to explore execution in half-cycle increments. Enter new opcodes into memory and press the reset button to look at the next instruction of interest.
2025-12-13 · 5 months ago · 👍 norayr, shapes
3 Comments ↓
Great. My favorite CPU. Nothing is as fun to write assembly for. Is it your project?
I remember reading about some kind of inaccuracies in the block diagram... Is this one corrected?
🥬 lamb-duh [OP] · Dec 13 at 15:25:
My favourite CPU too :) It was the first ISA I wrote assembly for, and still the only one where I've written more than bits of glue for C.
Yes, the project is mine, although my contribution is really just bringing a bunch of amazing work by different people together. Check out the "about" tab on the page to see who did all the real work.
I did do some work to "fix" the block diagram but it's possible that there are still some issues with it. I don't really know the internal architecture, I made this tool to help me learn too. The changes I made to the block diagram were made during testing when I found behaviour in the perfect6502 simulation that was incorrect on the block diagram.
The only major change I made to the diagram was showing the stack register as two seperate "boxes". This came up because I noticed that the stack pointer was behaving inconsisntly with how the diagram was labeled, it was acting like an edge-triggered register rather than a level-triggered latch (like every other "box" on the diagram). I was able to find the other half in the 6502 transistor network, and it made the diagram update those "boxes" when it said it was.
I tested every legal instruction manually. It's very possible that I missed some things, but I fixed all of the bugs I found. I'm very confident that the Hanson diagram is a very faithful representation of the internal architecture. There is another well known block diagram of the 6502 that is published in a datasheet. That one is known to be incorrect and incomplete. That diagram should be avoided by anyone who wants to learn about the internal architecture.
Thank you. I've been itching to do something 6502-related lately...