6o6: virtualizing the 6502 on a 6502

Topics pertaining to the emulation or simulation of the 65xx microprocessors and their peripheral chips.
Post Reply
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

6o6: virtualizing the 6502 on a 6502

Post by 6502inside »

Source code is, after twenty years (!), available. 6o6 provides a virtual NMOS 6502 on a 6502, 65C02 or 65816 in 8-bit mode. It completely abstracts memory access, allowing memory to be remapped, and it uses the host ALU for accurate results and flags. It supports all documented opcodes, can pass Klaus Dormann's functional test, and can virtualize itself ... virtualizing itself. The ratio of guest to host instructions varies, but is about 50 depending on the complexity of the harness and kernel, running about 30-50 times slower than actual code depending on opcode mix.

This isn't (primarily) intended for people developing their own hardware, although it can serve that purpose, and it can be engineered to use hardware assist (like external memory, MMUs, etc.). Instead, it's meant for simpler systems or extant NMOS/CMOS machines that lack memory management but still need a controlled environment to run code.

Sample binaries of the four example programs are available for the C64 (all four) and the Apple IIe/c/gs (three of the four). These examples include a basic hello world, virtualizing itself virtualizing itself virtualizing hello world, a simple two-task kernel, and (C64 only) running the RC2014-6502 ROM with EhBASIC and monitor completely from an external geoRAM.

6o6 was originally written for the Incredible KIMplement, which emulates a KIM-1 on a C64. That is now open source as well.

Further discussion: https://oldvcr.blogspot.com/2024/04/vir ... 6-and.html
Github for 6o6 and pre-built binaries: https://github.com/classilla/6o6
KIMplement main page: https://www.floodgap.com/retrobits/kim-1/emu.html
Github for KIMplement: https://github.com/classilla/kimplement/
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: 6o6: virtualizing the 6502 on a 6502

Post by BigEd »

Nice work! Well done and thanks for sharing the code. Tiny PILOT is a nice bonus!
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: 6o6: virtualizing the 6502 on a 6502

Post by 6502inside »

Thanks! :) Yeah, that was a nice find from Dave Hassler. It performs surprisingly well, even the ELIZA demo.
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: 6o6: virtualizing the 6502 on a 6502

Post by 6502inside »

6o6 v1.1 is released. This is primarily a performance update, improving guest zero page performance with a fast store path, but also cleans up addressing modes and furnishes greater control over the interrupt flag.

As a gratuitous demonstration, 1.1 includes a new example which is an Apple-1 emulator for the Commodore 64 or Apple II. Yes, there are others, but this one synthesizes a full 64K addressing space and can't be overwritten by a guest program, and it is immune to stomping on "ROM" or running an illegal instruction.

The Incredible KIMplement is also updated to 1.1 with the new core.

Further discussion: https://oldvcr.blogspot.com/2026/03/6o6 ... -6502.html
Other links are the same as above.
Post Reply