Emulation Everywhere
More on the increasing importance of emulation and a curated selection of some of the most impressive open-source emulators
The success, or otherwise, of all these emulators may well be a key factor in whether we see mass migration away from x86 to Arm and even RISC-V in due course.
x86 to Arm : WOW64 on Windows and Tango on Xiaomi and Linux
We saw in Apple’s Mac Transitions how important emulation of superseded architectures has been in enabling Apple to move to new processor designs. For each transition, 68k → PowerPC → Intel → Apple Silicon, Apple has built a new emulator. They have supported each for a few years, to give developers and users time to move on to the new hardware.
I published that post last week as it seemed like architectural emulation would be likely to be an important topic in the very near future.
And indeed, last week the announcement of the latest Snapdragon X Elite Arm based platform for laptops from Qualcomm which is likely to prompt a renewed effort to make Windows on Arm a success. And to be a success, it’s likely to need successful x86 emulation. Microsoft have their own longstanding approach to emulating legacy applications in the 64-bit Arm version of Windows, called WOW64, which supports running 32 and 64-bit x86 applications on Arm.
But it’s not just Intel to Arm emulation that can be necessary. As recent Arm cores drop support for the 32-bit AArch32 Arm ISA (to save die space) older 32-bit Apps can no longer be run on the latest Android phones such as the Xiaomi 14. In fact this phone can run 32-bit Apps using software from that translates 32-bit AArch32 to 64-bit AArch64 instructions. This software, called Tango, has been licensed from UK based Amanieu Systems, who offer Tango for both Android and GNU/Linux.
From Amanieu’s website, Tango includes:
Dynamic translator - The dynamic translator is the core component of Tango. It wraps a 32-bit ARM process and runs it as 64-bit process by translating all of the instructions into AArch64 code.
Pre-translator - The pre-translator performs off-line translation of executable files to generate persistent caches of translated code. This enables improved application start-up times and reduced memory usage.
Amanieu claims that Tango can run within 10% of native speed, and can actually sometimes be faster than the original 32-bit code.
There are also links on their website to a number of papers from Amanieu’s founders on the topic. I found Low Overhead Dynamic Binary Translation on ARM to be a great introduction to the approach that their software uses.
As we see more efforts to move to 64-bit only systems (for both Arm and Intel - see the proposals in Intel’s APX to remove 32-bit support) and more promotion of Windows on Arm, then we can expect to see much more focus on software like WOW64 and Tango that allows legacy code to run on 64-bit only systems.
The success, or otherwise, of these all emulators and translators may well be a key factor in whether we see mass migration away from x86 to Arm and even RISC-V in due course.
Open Source Emulators
Emulators can also have a long term role, as a way of keeping older software alive when the corresponding hardware is no longer available or supported. This might be for commercial reasons or to keep a vital service running. Or it might be simply for the sake of digital preservation.
Reproducing the precise behaviour of a complex piece of legacy hardware can be extremely difficult. So it’s a challenge that has attracted some of the most talented and inventive developers.
So the rest of this post brings together a curated selection of the most impressive and useful open source emulation tools. They emulate systems that range from 8-bit games consoles, all the way to minicomputers, more recent RISC CPUs including RISC-V, and even IBM mainframes running authentic mainframe operating systems.
Not only are these emulators useful tools in themselves, but their source code is often a great starting point to understand how the emulated systems work.
All can be downloaded and run on desktop systems or run in the browser. Most are compatible with all of Windows, Linux and the Mac, and all have source code that is freely available. We’ve featured some of these before, some quite a long time ago, but it’s probably helpful to have them all together in one place.
Let’s start with some fun, and the leading emulator for arcade consoles and other video games systems.
MAME
MAME (originally standing for Multiple Arcade Machine Emulator) was started as long ago as 1997, by Italian Developer Nicola Salmoria. It’s an open-source emulator for Arcade games systems and, since the MESS (for Multi Emulator Super System) project was merged into MAME, a very extensive range of home consoles too.
In the latest version, Version 0.26, released in October 2023, MAME emulates over 7,000 games systems. We can get a sense of the range of games that are emulated from this video with just a small sample of 150.
If we dig under the surface, MAME provides emulators for an impressive range of architectures. From DEC Alpha to Zilog Z8000, by way of Fairchild Clipper and the Intel i860, I counted over 170 different processors.
If you want to build emulator for one of these architectures, then MAME is a great place to go, just to study how the MAME source code works. Even if you just want to understand how the architecture works then it’s a useful supplement to the original documentation.
QEMU + UTM
We’ve covered QEMU and UTM before. QEMU is from programming wizard Fabrice Bellard (also the creator of FFMPEG).
QEMU allows a number of relatively recent, architectures to be emulated: Arm, MIPS, PPC, RISC-V, s390x, SPARC and x86. Of particular note is the emulation of RISC-V. In the absence of real hardware this may be the most straightforward way to run RISC-V software. QEMU will also run a ‘guest’ operating system using virtualisation natively if the you’re running on the appropriate architecture.
UTM provides a friendly ‘front end ‘ for QEMU for Mac users. It can automatically download and run a number of architecture / operatimg system combinations. It’s probably the quickest and most seamless way of getting a guest operating system running on the Mac.
Two RISC-V Emulators - JSLinux and in Scratch
Separately, Fabrice Bellard has also built a Javascript emulator for DOS / Windows / Linux emulating x86 or RISC-V architectures, that runs in the browser.
You can try a RISC-V based Fedora 33 system here.
And here is another remarkable Linux RISC-V emulator, this time written in the Scratch visual programming language, again running in the browser (via Adafruit).
Hercules + Jason
Moving to bigger and older systems, Hercules is an emulator for IBM mainframes. From the Hercules website:
Hercules is an open source software implementation of the mainframe System/370 and ESA/390 architectures, in addition to the latest 64-bit z/Architecture. Hercules runs under Linux, Windows, Solaris, FreeBSD, and Mac OS X.
Now you might think, ‘what is the use of a mainframe emulator, when all the operating system software will be proprietary, and strongly protected.’ In fact, early IBM mainframe OS software is in the public domain. From, the IBM Public Domain Software Collection website, which makes downloads of these systems available:
IBM, by corporate policy, does not assert copyright ownership of any software which it distributed without copyright notices. US copyright law, until 1978, placed such materials in the public domain.
Now Hercules itself is very useful, but it doesn’t quite capture the experience of a room full of blue boxes, teleprinters and washing machine sized disk drives. Enter the Jason front-end for Hercules.
Jason is a ‘front-end’ for Hercules that not only provides an easier way to operate Hercules, but a fun set of graphical representations of the actual IBM hardware itself: terminals, disk drives, printers and even a bookshelf for the manuals.
After the break, seven more emulators or collections of emulators to run in the browser, or on the desktop (Windows, Linux, or Macs).
The rest of this edition is for paid subscribers. If you value The Chip Letter,then please consider becoming a paid subscriber. You’ll get additional weekly content, learn more and help keep this newsletter going!