NES86 – IBM PC Emulator for the NES
github.com
github.com
(meme picture goes here)
By the way, there used to be some few MMUs for pre-286 x86 CPUs back in the day. It was all extremely custom stuff as far as I can tell. The one I'm mostly familiar with was for 80186, and made entirely out of 74xx style logic chips and a bit of SRAM. It supported page-granular mapping and protection across multiple (hardware-defined) process address spaces + kernel, and even I/O space protection (though original SINIX, the system that used it, did not seem to end up turning on I/O protection for some reason). No on-demand paging though, i.e. page faults had to resolve to killing the process instead of resolving the fault, as the pipelined design of even 8088 CPUs already made restarting instructions entirely unpractical.[1]
It would have been fun to see ELKS support such things, though I don't have the time and energy left to look into that nowadays (especially given that those super-bespoke MMUs were never very common, and are virtually extinct today). I also guess that the more interesting MMUs, i.e. the ones that do have page-granular mapping, also wouldn't fit very well with ELKS in the first place, as it's (presumably) entirely written for segmentation.
[1] There is the famous Silicon Valley lore of a workstation manufacturer running two 68000 CPUs in lock step to work around similar limitations, one CPU running behind the other one so it can be used to "restart" the faulting instruction, but that's a story for another day.
Never had any hardware with those exotic MMU's, so working with them never crossed my radar.
Paging MMUs are still useful, one could just tell the memory allocator to place user space programs at 4K, or even 64K, boundaries.
I realized last night (almost 30 years late!) that I should've implemented a BIOS-type interface (or modified EMS) to do memory mapping and then had a few different handlers (memory swapping, 286 and 386 LOADALLs, 386 v86 mode, etc) to choose from without messing with ELKS itself too much.
Working on ELKS now has the great advantage that the emulated 8088 PC is now faster than the computers anyone had back in the 90's, and all of that emulation can easily fit in CPU caches.
I can't pick these up for a few reasons (#dayjob and other hobby projects that I don't have enough time/energy to work on properly!), but here's a couple of thoughts that've been percolating for a while that didn't make the last topic:
- If I were a 19-year old (and odd) college student thinking about starting something like this again (I picked up the idea from Alan Cox and did the early versions suuuuch a long time ago now!), I'd have targeted the Pi Pico, and been absolutely estatic when the RP2350/Pico 2 came out.
You could make a pretty interesting 80/early-90's workstation using a couple of rp2350's (one for frontend, the other to run the hacked-up Linux) w/additional SRAM and Flash.
- One can use a 386+ as a memory mapper/protection unit while still running everything the rest of the system in real/v86 mode, in blissful ignorance that it's running on a 32-bit system.
They're basically as capable as a Pi Zero, but work in a Pi Pico form factor. Check out the Ox64 and Oz64 boards from Pine64 or the Duo series from Milk-V.
https://www.federalregister.gov/documents/2025/01/16/2025-00...
Obviously not the same thing, it's not "real" Linux, but a similar goal of getting "something like Unix on hardware that has no business running it".
I have mad respect for these kinds of projects. Writing software on powerful hardware is easy, that's what I do for a living, but people squeezing the life out of the NES and C64 are on another level of intelligence and dedication that I'm not sure I'll ever be able to match.
But then he received a lot of comments saying that it's not real Linux, so he made NES86 to run ELKS and made another video https://www.youtube.com/watch?v=OooHTDMUSGY. It's a bit funny since ELKS does not consider itself Linux anymore, just a "Linux-like OS", so maybe we'll have a third iteration of this project eventually ;)
It's extremely cool stuff, it doesn't feel like even an approximation of Unix should be possible on the NES.
(Please note the sarcasm in the above comment.)
[0] https://web.archive.org/web/20181113230737/http://www.uclinu...
I suppose the next step to take this project to its logical conclusion would be to make an actual cartridge of it that works on a stock NES. Alternatively, add another level by running this in a browser JS NES emulator.
Is there already a good short term for this sort of "testing the limits of Turing-completeness in practice" exercise? Here are two other well-known attempts:
See "DOOM on NES": https://www.youtube.com/watch?v=FzVN9kIUNxw
or Reverse emulating the NES to give it SUPER POWERS https://www.youtube.com/watch?v=ar9WRwCiSr0
A few period games, like Star Fox and Yoshi's Island, include a RISC processor and a frame buffer, rendering the graphics in the cartridge before transferring the output to the PPU.
Edit: The original SNES version of DOOM itself ran this way.
https://www.nesdev.org/wiki/MMC5#Unsigned_8x8_to_16_Multipli...
It takes about a week to boot, but it's fun.
It is very well produced, funny and informative.
Importantly, this means we can port the PlayStation 3 emulator or mine Bitcoin on the NES.
This is the most vile and nefarious act of evil genius I've witnessed in ages!