6o6: virtualizing the 6502 on the 6502

  • Board Nominations
    Nominations have now closed and the results are available here.
  • Hey Guest, MARCHintosh 2026 is upon us. Check out community projects, join GlobalTalk, and have fun!

ClassicHasClass

Active Tinkerer
Aug 30, 2022
452
269
63
www.floodgap.com
This is something I've literally tinkered with for over twenty years, so it's time to clean it up and open source it, along with the Incredible KIMplement 1.0, its original demonstration application (a KIM-1 emulator that runs on a Commodore 64).

6o6 "6502-on-6502" presents a full NMOS 6502 to software, virtualizing the ALU for speed so that we get correct results and flags "for free." It has a completely abstracted memory model and can trap illegal instructions and faults. Depending on the complexity of the kernel and harness it runs about 50 host instructions for every guest instruction, which translates to something around 30-50 times slower than native code depending on instruction mix. It requires no special hardware.

It is comprehensive enough to pass Klaus Dormann's functional test and can even virtualize itself ... virtualizing itself.

Four demonstrations are included. The first three can run on a C64 or C128 (in C64 mode), or on an Apple IIe/c/gs with at least 64K of memory. One is a simple hello world, one is an "inception" demo that virtualizes hello world, then virtualizes itself virtualizing hello world, then virtualizes itself virtualizing itself virtualizing hello world, and one is a simple two-task kernel. The fourth requires a C64 with a geoRAM or compatible expander. It presents a full 64K addressing space of the RC2014 computer with a 6502 CPU, but the entirety of the guest runs completely within the geoRAM.

A more indepth discussion: https://oldvcr.blogspot.com/2024/04/virtualizing-6502-with-6o6-and.html
 

lauland

Tinkerer
Dec 12, 2023
39
28
18
"Yo dawg, I heard you liked 6502's...so I put a 6502 in..."...oh wait, you already did that...

You didn't mention if you implemented the classic 6502 bugs...bet you were tempted!

 
Last edited:
  • Haha
Reactions: Kai Robinson

trag

Tinkerer
Oct 25, 2021
309
152
43
IIRC, the VHDL text book my class used way back when contained the VHDL code for a 6502 in the back as an appendix. Of course, that would be for FPGAs, but thought I'd mention it.

Later Edit: 6805, not 6502. So completely irrelevant. Sorry.
 
Last edited:

ClassicHasClass

Active Tinkerer
Aug 30, 2022
452
269
63
www.floodgap.com
6o6 is now updated to 1.1. This improves guest zero page performance, but also cleans up addressing modes and furnishes greater control over the interrupt flag.

But wait, there's more! With the 50th anniversary of Apple coming up, why not add a new, gratuitous example: an Apple-1 emulator that runs on the Commodore 64 or Apple II? Yes, others have done it and I think it's fun to look at them - so the blog post does - but this is mine, and it synthesizes the complete addressing space and is bulletproof from segfaults, overwriting the "ROM" or trying to execute illegal instructions.

Binaries and disk images of all of the example programs, updated for 1.1, are included.

Further discussion: https://oldvcr.blogspot.com/2026/03/6o6-v11-faster-6502-on-6502.html

Just give me the binaries, man: https://github.com/classilla/6o6/releases
 

Attachments

  • big-va1-1.png
    big-va1-1.png
    2.1 KB · Views: 0
  • big-va1-3.png
    big-va1-3.png
    2.6 KB · Views: 0
  • big-vice-screen-2026032719535103.png
    big-vice-screen-2026032719535103.png
    2.5 KB · Views: 0
  • big-vice-screen-2026032720031702.png
    big-vice-screen-2026032720031702.png
    2.2 KB · Views: 0