How to write a text editor for a 31 year old computer
8 min read
fairly easy
Article URL: Comments URL: Points: 2 # Comments: 0
How to write a text editor for a 31 year old computer

The Apple IIgs came out on September 15, 1986. It featured a 2.8 MHz WDC 65816 CPU (the same one that powered the SNES and other similar computers of that era, a 16-bit CPU with 24-bit addressing), 256k or 1MB RAM (upgradable to 8 MB), and an Ensoniq 8-bit stereo synth (which was a welcome upgrade from the bit-speaker of the Apple II family). For reference, the original Apple II family was built around the 6502 CPU (8 bit, 16-bit addressing), and had at most 1 MB of RAM in the IIe and II+. However, it was not until 1988 that Apple had released an operating system for the new computer that was able to meaningfully leverage the newer hardware. GS/OS was written in native 16-bit code, and more importantly, was intended to be used via its new shiny GUI.

This article is about how I built a tiny 'text editor' for the IIgs, from start to finish.

PS: This opcode reference might be useful while reading!

What do we have to work with?

At the beginning of this project I imposed a few requirements. My text editor should:

Be launchable from GS/OS regardless of whether or not it actually runs windowed in the operating system.

Not occupy more than 256k of RAM, so that it may run on any IIgs.

Run in native 16-bit mode.

If you are unfamiliar with this processor, then the last bulletpoint is confusing. By the time the IIgs had launched, there was already a plethora of software out in the wild that was compatible with the original Apple II (which used the 6502). The 65816 has an "emulation mode" that can be toggled which effectively turns the '816 into a 6502 by selectively "halving" the width of its accumulator and index registers (amongst some other things, which we will cover later).

GS/OS is a 16-bit "single-process at a time" operating system. For me, this means that my text editor is going to be the only running program on the system after it finishes loading. The OS will remain in RAM but I will have to abstain…
Read full article