It is possible to run modern software on classic 6502-based computers such as the Commodore 64 and the Apple II.
Some ground work is in order. The basic strategy involves beefing up the 6502-based machines as much as possible and dumbing down Linux as much as possible.
The secret sauce involves writing a new, 6502-based emulation of an ARM Versatile/PB development board. The ARM Versatile/PB is still a first-class target for Linux. I think that with the make tinyconfig command with cross-compilation, we can get the size of a Linux kernel sufficiently small to have it in expanded memory on the 6502 host.
We will need to write parts of an ARM926EJ-S emulator in 6502/65816 assembly. This sounds a lot harder than it actually will be, and large parts of it probably won’t even have to be written at all. While the ARM seems to have a ton of instructions, at the bit level, each instruction breaks neatly into its command and operand components. Most of the work will be in emulating ARM interrupts and user/supervisor modes in 6502 assembly, and for a first bringup it wouldn’t even be necessary to emulate the Versatile/PB interrupt controller. Each of the addressing modes will need to be handled, but no individual addressing mode will be that complicated. The ARM instruction set has a lineage dating back to the original MOS chips, and many of the state flags for ARM are exactly the same as they were in the 6502 days.
Sixteen megabytes of memory will need to be added to the 6502 machines, with appropriate bank switching logic. This has been done already for each of the 6502 hosts. There is also a period-appropriate chip, the 74LS610, which was intended specifically for increasing the addressable memory on the 6502 series.
We use 65816 microprocessor (SuperCPU) instructions to access 16 MB of memory in a 6502 machine. Or, we develop a virtual memory abstraction that can arbitrarily bank in and out pages of the 16 MB into the lower 64KB of memory on each host. The cc65 development environment already supports RAM expansion drivers for the Apple II and the Commodore 64.
To get Linux to be sufficiently small, we use make tinyconfig with a modern Linux cross-compiled kernel to get it under 8 MB. We target the version 1 ARM thumb instruction set in the Linux cross compile, and that’s the instruction set we emulate on the 6502.
For testing the correctness of the emulator, we run QEMU emulating the VersatilePB, in parallel with the 6502 emulator emulating Thumb1. We write a script that single-steps both virtual machines and verifies that emulator states run in lockstep.
The performance will be abysmally slow, but who cares. Most likely the 6502 machines will, at first, themselves be running in emulation on a much faster PC.
See Woz’s SWEET16 emulator for further inspiration and basic proof of concept for the Thumb portion of ARM emulation.