6o6: virtualizing the 6502 on the 6502

ClassicHasClass

Tinkerer
Aug 30, 2022
234
141
43
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

New Tinkerer
Dec 12, 2023
30
20
8
"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
270
128
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: