A reusable application environment: the other half of the story

In my last post I shared my research into Realia COBOL for DOS, which was part of a much bigger project. The truth is that it was actually only half of the story. But why did I end up researching a compiler for DOS in the first place?

Let me go back in time for a second.

Somewhere around the end of May and beginning of June 2026, I was finishing my research into Cobolito/400, although I hadn’t started writing the essay yet. At the same time, I was experimenting with my PursePC and CrumbStation. As you might recall, CrumbStation is perfectly able to adapt to running either on a Cobolito appliance or standalone. Around that time, I received the announcement about the CardPuter Zero. It was really tempting: why not get a truly pocket-sized device, even smaller than my PursePC, that isn’t yet another Android phone, where I could run COBOL, Clipper and other TULIP/400-style TUI applications? And it came with an irresistible bargain: early backers would get it at a substantial discount. It was basically a no-brainer.

For those unfamiliar with it, the CardPuter Zero is based on the Raspberry Pi Compute Module Zero (CM0) platform. At the time, I assumed that it shared the ARMv6 architecture of the original Raspberry Pi Zero, which incidentally sat in a box beside my desk. I’ve had some experience with that architecture before, and finding precompiled software isn’t always straightforward. Quite often, you end up compiling things yourself, including, in my case, the compilers themselves (COBOL/Clipper).

And you probably recall my post It’s not that I like COBOL. I like software that leaves me alone. I don’t particularly like programming. I want software that, once proven useful, stays put without requiring much adaptation.

And then that dangerous little question: “How can I write the software once and run it on any platform?”

I wanted to write an application once and be able to run the same executable on the CardPuter Zero and my PursePC (x86), my primary targets for small, portable data-collection applications. But since I’m travelling quite a lot and can’t always bring those devices with me, I also wanted to run the same applications on my laptops running Linux Mint (x86). And, as a nice side effect, why not on my workstation running Linux Mint or my servers running FreeBSD (x86) too?

Something like a timesheet, for example, where I could collect data locally and eventually transfer it to a server for processing. For server-side applications, native compilation would still make much more sense.

As I’ve shared before, I’ve lately developed the habit of asking myself silly questions that look innocent on the surface, but eventually turn into months of research and a lot of documentation. This was one of those “little” questions.

My initial thought was to have some sort of binary compatibility layer sitting between the application and the underlying operating system and processor. Something along the lines of a hardware abstraction layer, providing a stable execution environment regardless of the language the application was written in, or the machine it was running on.

Given how much I admire IBM i, the first thing that came to mind was its Technology Independent Machine Interface (TIMI). One of the things I find fascinating about IBM i is that applications can survive substantial changes in the underlying processor architecture, thanks to an abstraction layer between the application and the actual machine. You can save a library with SAVLIB, including its programs and data, and restore it on a later generation of the system without necessarily having to recompile everything. IBM’s mainframe architecture has also maintained remarkable backwards compatibility over the decades, although much closer to the machine architecture itself, with hardware and microcode preserving the expected behaviour.

But there are other approaches. Apple, for example, introduced Universal Binaries, where a single executable or shared library contains machine code for more than one processor architecture. The operating system then selects the appropriate one. It’s a different way of addressing the problem, and one that helped Apple during its transitions from PowerPC to x86 and later to ARM with Apple Silicon.

This is rather different from the approach taken by one of my previous employers, Sun Microsystems, with Java and its famous “write once, run anywhere” philosophy. Java moves that compatibility layer further up, into a virtual machine running on top of the operating system. It is a perfectly valid approach, and an impressive piece of engineering, but it wasn’t quite what I wanted. You’re limited to applications targeting the Java Virtual Machine, whether written in Java, Kotlin or another compatible language. You can’t simply take an arbitrary existing executable and run it there.

These are different engineering solutions, but the underlying idea interested me: how can you preserve the applications while changing the machinery underneath?

I deeply admire those engineering houses, in some of which I had the privilege of working. But I’m neither IBM, nor Apple, nor Sun. I might be able to conceive the idea, but I don’t have the resources to create an abstraction layer that works across every processor, operating system and commercially available computer. I’m just a woman sitting at her small desk, mostly in hotel rooms, with her computers.

Then an idea out of the blue: “What if I use DOS as an abstraction layer?”

That came from the same adjacent thought that led me to choose COBOL as a programming language: something stable I could work with. The DOS executable environment and its basic interfaces have been around for decades, and there are plenty of existing compilers and applications that target them. Instead of building my own virtual machine or hardware abstraction layer, what if I could simply use DOS as a common binary target, and find something small enough to provide that environment on different operating systems and processors?

A sort of poor woman’s TIMI, if you’ll forgive the rather stretched comparison.

Not a universal solution, of course. DOS applications have their limitations, and this wouldn’t magically make every application portable. But for the small, data-oriented TUI applications I had in mind, perhaps it would be enough.

And then two questions that eventually became two independent, parallel subprojects.

The first was: “Can I create a TUI data-oriented application for DOS, along the lines of CrumbStation?” I already had experience with Clipper and xBase, including my flight log application, and dBase III+ was another old friend. But COBOL was the biggest missing piece, especially for the kind of field-oriented application I had been exploring with Cobolito/400. That led to the Realia COBOL investigation I described extensively in my previous post, and eventually to BOOKS.EXE. What I initially thought would be an innocent search for a small and easy COBOL compiler turned out to be a rather deeper rabbit hole than I expected, consuming a considerable amount of energy and eventually producing some fifty pages of documentation.

The second question was: “How can I run the same DOS program on different operating systems and processor architectures?”

That deserves a little more explanation.

The original question and the two parallel
!subprojects

Finding the missing execution layer

My first thought was inevitably DOSBox, as I was already using it for Realia COBOL. DOSBox, along with DOSBox-X, is well known among retrogamers, and there are also versions running on Android phones. If it runs on Android, there is a good chance that it could work on ARM too. Except that DOSBox is primarily designed around a graphical environment, almost like having a separate little computer inside your computer. And while I can definitely run X on both PursePC and CardPuter Zero, that’s not the experience I wanted. I’m perfectly comfortable with the TUI-only environment I already use on PursePC.

Then I moved to dosemu2. The -t option was a perfect fit, as I could run DOS applications directly in terminal mode without requiring an X session at all. And the other options were also quite convenient for executing a program against a Unix directory without having to maintain a complete standalone DOS installation:

dosemu2 -t BOOKS.EXE -K /home/tara/tulip400/books/

This was getting much closer to what I had in mind. Instead of entering a separate emulated computer, I could almost treat DOS as an execution layer sitting between my application and the host operating system. There was still a fair amount of machinery involved, including supporting libraries, dependencies and DOS integration, but the approach was promising.

I even compiled it for Alpine Linux x86 (PursePC), and I was really excited that I’d found an answer in a reasonably short amount of time.

Until I clashed with my ARMv6 test target.

That deserves another tangent. As I’ve mentioned in previous articles, I travel quite a lot. Much of this research happened on my personal laptop in hotel rooms, rather than in front of my actual hardware. I can’t realistically carry an assortment of single-board computers, monitors, keyboards and cables around with me. So most of my experiments happen in virtual machines or simulated environments, or directly on my laptop, as was the case with DOSBox and dosemu2. For this reason, I tend to leave hardware-specific testing until the very end of a project, especially when it comes to hardware that is more challenging to emulate.

In this case, when the time came, I created a Raspbian armhf chroot on my x86 laptop (using debootstrap with raspbian.raspberrypi.com), running under qemu-user-static with the CPU model set to arm1176 (ARM1176JZF-S). This allowed me to approximate the Raspberry Pi Zero user-space environment. For this particular project, that was enough to test my point before moving to the actual hardware.

Back to dosemu2: the emulator officially targets x86 and arm64. And arm64 is 64-bit. My target, however, was an ARMv6 32-bit processor with VFPv2 (not VFPv3), and no NEON instructions. I couldn’t get dosemu2 to build in my simulated environment.

I wasn’t able to determine whether this was a fundamental limitation or simply missing porting work. Some supporting components, such as comcom64, were designed around 64-bit environments, and getting their 32-bit counterparts to work with a recent dosemu2 release could be quite challenging. My gut feeling was that I might eventually be able to address those issues, given enough time and patience, but it would probably mean going down a much deeper rabbit hole than I did with Realia. And even if I succeeded, I’d still have to maintain the result.

I’ll be honest. I was thinking about it. Until I tripped over another emulator: emu2.

Its GitHub page describes it as “a simple DOS emulator for the Linux text console, supporting basic DOS system calls and console I/O”. Do you believe in love for a piece of software at first sight? Yeah, it was kind of that feeling.

I had a quick test on my Linux Mint laptop on x86: emu2 is just a single binary. No libraries built. No external dependencies except the basic OS shared libraries. Just one, single binary.

And it ran both my BOOKS.EXE application from Realia COBOL and my beloved dBase III+ (although I found some bugs).

I can’t hide it, I was super excited. This was much closer to the abstraction layer I’d imagined at the beginning. Not an entire separate DOS machine, not a complicated environment with plenty of supporting machinery, but a thin execution layer that could provide the DOS services expected by my applications. Almost firmware-like in spirit, although technically it is, of course, a user-space emulator.

So I started compiling it on Alpine Linux (x86) and FreeBSD 15 (x86), and everything was working fine. And then the final test in my simulated environment: it compiled in my QEMU ARM1176 chroot and… it ran both DOS applications!

Wow! I stared at the video in happy disbelief.

During the process, I encountered a few bugs that I tried to fix:

I also got to know Jeffrey Johnson, who maintains an active fork of emu2. Jeffrey was kind enough to look into the issues I encountered, and I eventually switched to his version. I owe him a couple of beers.

At this point, the architecture I had imagined at the beginning was finally taking shape. The same DOS applications, running through emu2, with different operating systems and processor architectures underneath.

Reusable application environment
!architecture

From QEMU to real hardware

This is the part where I got slower.

The tests under QEMU had given me confidence, but I still wanted to verify the result on actual ARMv6 hardware. Fortunately, I already had that Raspberry Pi Zero sitting in a box. Unfortunately, finding the time and energy to get it out of the box was another matter.

And even when I was finally in the same place as my hardware, finding the time, and especially the energy, to do anything with it was another challenge. Testing on actual hardware would mean finding the Raspberry Pi in one of my boxes, getting a temporary monitor and keyboard out, cabling everything together, and running the tests. And we all know that hardware testing takes time. So I had to wait until all the planets aligned.

But then it was utterly satisfying. I installed DietPi on the actual Raspberry Pi Zero hardware, which is a Debian derivative, and simply copied the emu2 binary I’d previously compiled, along with BOOKS.EXE and the dBase III+ suite.

Bam! It worked on the first try. Of course, I couldn’t believe it.

It took me a while longer to get the Raspberry Pi running at the right screen resolution, as I had to fight an incompatibility with the video driver. But that’s because I’m stubborn, and I wanted the experience to be as close as possible to what I had in mind.

And then, much later in the investigation, I discovered something that I really wish I’d known at the beginning.

Remember the CardPuter Zero, the little machine that started all this? Well, it turns out that its Compute Module Zero isn’t based on the original Raspberry Pi Zero’s ARMv6 processor after all. It’s based on the Raspberry Pi Zero 2 W architecture, with a quad-core Cortex-A53, which is ARMv8-A and 64-bit capable.

Yes. I’d spent all that time treating the original Raspberry Pi Zero as a representative of the CardPuter’s processor architecture, and they weren’t actually the same.

Well, that was a bit of a facepalm moment. 🤦‍♀️ But the ARMv6 investigation wasn’t wasted: I’d demonstrated that my applications could run on the original Raspberry Pi Zero, a machine that had been sitting unused in a box for quite some time.

But what about the actual CardPuter’s architecture?

I went back to my laptop and created another chroot, this time using Debian Trixie arm64 under qemu-user-static, with the CPU model set to Cortex-A53. I compiled Jeffrey’s emu2 fork with my patches, and ran BOOKS.EXE.

And it worked too.

Of course, that didn’t guarantee everything would work on the CardPuter Zero itself. The display, keyboard and operating-system environment still needed testing on the actual device. But at least the processor architecture was no longer an unknown.

And, while I was at it, another thought occurred to me. Somewhere in my garage there should be a VisionFive 2 board, a RISC-V computer I bought some time ago and never even powered on. I couldn’t possibly tell you which box it’s in, and I wasn’t particularly keen on starting another hardware expedition. But I wondered whether the same approach could work on RISC-V too.

So I created yet another Debian Trixie chroot, this time for riscv64, using qemu-user-static with the SiFive U54 CPU model. It isn’t quite the processor used by the VisionFive 2, but it was enough for another userspace experiment. I compiled my patched version of emu2 and ran BOOKS.EXE.

And, yes, that worked too.

Then, finally, the CardPuter Zero arrived. Just one week before my birthday, which was rather nice timing.

I didn’t have much time initially, but I managed to flash the stock M5 image, based on Debian Trixie, and confirm that it was indeed running ARM64. The image comes with M5’s launcher, which I don’t particularly dislike, despite being a TUI girl at heart. It also shows the Wi-Fi connection, battery level and time in the upper-right corner. I copied over emu2 and tried both BOOKS.EXE and dBase III+.

And both applications ran. No glitches in the actual execution, and even the function keys worked.

There was, however, a catch I hadn’t really considered. The terminal provided by the M5 launcher reported just 45 columns and 10 lines. Both applications were written for the traditional DOS screen geometry, so while they were running correctly, their interfaces were cut off. I could see parts of the screens, issue commands in dBase, and interact with the programs, but a substantial part of the display simply wasn’t there. Although I was really happy that it worked on the first try, I can’t deny I’m a bit disappointed with the screen resolution. But perhaps I was expecting too much from a device of this size. What can I say? I’m a perfectionist.

And because I couldn’t quite leave the question alone, I tried a Kali Linux image for the CardPuter Zero on another microSD card. It offered an 80×24 terminal, which seemed promising. And indeed, the applications could be displayed much more completely. Unfortunately, on such a tiny screen, the characters were barely readable even with my glasses. Worse, that particular terminal didn’t handle some symbols or the function keys properly, so I even had to prepare a small wrapper script to launch the emulator. Nice to know, and useful for a couple of screenshots, but certainly not something I would want to use every day.

The limitation wasn’t in the DOS executable or its ability to run through emu2. It was in the assumptions those applications made about the screen and keyboard. A program designed around an 80-column terminal doesn’t suddenly become comfortable to use on a pocket-sized display just because the binary executes correctly. This was also why I’d been so keen on testing actual hardware rather than relying entirely on QEMU.

That might eventually lead to another experiment, perhaps writing small data-collection applications that adapt to the available terminal geometry, or simply designing them around a much smaller common denominator. I might also explore Alpine Linux on the CardPuter, particularly to reduce boot time and get closer to an instant-on device. But those are separate questions, and I don’t particularly want to turn this investigation into another one.

And then, just out of curiosity, while updating the applications on my Android TCL NXTPAPER tablet, I tried compiling emu2 under Termux too. It worked, including BOOKS.EXE and dBase III+, with a perfectly usable display. Another platform added to the list, although Android wouldn’t be my first choice for this kind of data-collection workflow, particularly when it comes to moving files onto removable storage.

At this point, I thought it might be useful to put the results together. These are the environments I’ve tested so far, distinguishing between real hardware, virtual machines and QEMU userspace tests.

Target libc Verification
x86, Alpine (PursePC) musl Real hardware, console tested
x86, Linux Mint (laptop) glibc Real hardware, console tested
x86, FreeBSD FreeBSD libc VirtualBox VM, working
ARMv6, Raspberry Pi Zero glibc Real hardware, F1–F5 fix verified
ARM64, Debian Trixie (CardPuter Zero) glibc Real hardware, both applications working. Display limited to 45×10
ARM64, Debian Trixie (Cortex-A53) glibc QEMU userspace, BOOKS.EXE working
RISC-V 64, SiFive U54 glibc QEMU userspace, BOOKS.EXE working
ARM64, Android (Termux) Bionic Real hardware, both applications working; function keys verified

The QEMU tests don’t replace verification on the actual devices, particularly where console handling and peripherals are concerned. But taken together with the physical hardware tests, they’re sufficient to demonstrate that the same DOS executable can run through emu2 on several very different processor architectures and host environments, without recompiling the application itself.

And back to the original question

I wasn’t trying to create a universal hardware abstraction layer, nor am I suggesting that anybody should build their applications around DOS. I had a particular need: a small, reusable application environment for client-side, data-oriented programs, where I could keep the executables unchanged while the operating system and processor underneath them could be different.

While not the initial goal, there’s also a nice side effect. During my experiments with Realia COBOL, I had already used DOSBox with a directory on a FAT-formatted USB stick mounted as a DOS drive. That also showed me I could potentially carry the same DOS applications, together with their configuration and data, and run them on another machine using a suitable emulator. Perhaps DOSBox on Windows or macOS, or emu2 on Linux or FreeBSD. My preference would still be to use my own machines, with Nextcloud or a simpler file-transfer mechanism to move the data around, but knowing that I could carry the environment elsewhere is rather reassuring.

And the data remains independent of the applications. Whether it’s a sequential file produced by BOOKS.EXE or the DBF files used by dBase III+ and my flight log application, I can still inspect and process them with other tools, even if the original applications are no longer available. That’s something I’ve written about extensively before, and I won’t repeat the entire argument here.

After four months of effort, and a lot of ibuprofen, I can reliably say: yes, I can write the software once and potentially run it on all the platforms I normally use.

Looking at the whole system running, my reaction was simply: “Yeah, I made it.”

And, as it turns out, the CardPuter Zero did arrive before my birthday after all. That was a rather nice present. 🎂🥳

P.S. In the picture below BOOKS.EXE, compiled with Realia COBOL for DOS, running through emu2 on the CardPuter Zero under Kali Linux’s Term80x24 terminal.

BOOKS.EXE, compiled with Realia COBOL for DOS, running through emu2 on
!the CardPuter Zero under Kali Linux’s Term80x24
!terminal.

2026-11-28