Title: Altair OS Part 1
Date: February 19, 2021
Tags: altair programming
========================================

After several project false starts, I finally settled on my next Altair project.
Spoiler: it's an OS.

I had a number of projects I wanted to do next on the Altair.  Getting a working
assembler opened the floodgates.  The obvious next step was a better assembler.
I ended up fixing a few bugs and smoothing out the process of using the
assembler but haven't added any new fucntionality.

I wanted to implement some simple mathematical functions for the assembler so
you can reference offsets from a labeled address, or set immediate values that
are multiples or whatever of values or existing EQU/SET values without having to
do the math yourself.  I started writing a basic calculator to figure out the
math routines but didn't get far.

I also wanted to write an editor to take one more step towards self-hosting
development directly on the Altair.  I got a ways into writing supporting
functions but got tired of it.  I don't have a working IDE interface for disk
storage so it seemed like it wouldn't be particularly useful, yet.

I took a brief attempt at getting the DualIDE card[0] working so I would have
permanent storage but something isn't right in the hardware and I wasn't feeling
up to trying to track that down.

I knew that I really wanted to write an OS but it just seemed too big.  An OS
could abstract away some of the hardware interfacing and other things I might
want to move into it.  It would make the other applications easier to build.
The more I thought about it, the more I knew that's what I wanted to work on.


# What kind of OS? #

The only real OS contender on the Altair was CP/M[1].  CP/M had a simple design
with a system specific BIOS to interface with the hardware and a consistent
application interface.  Applications written for CP/M didn't need to care about
the hardware.  They only needed to know how to ask CP/M to do it for them.

Since then, of course, numerous Operating Systems have been developed and used
on other systems.  A DOS also existed for the Altair, MITS had their own but it
wasn't until after the Altair's time that DOS grew to the full featured
Operating System we knew it as before Windows took over.  Graphical Operating
Systems are basically a non-starter as my Altair does not have a graphics card.
Maybe I could do something with ASCII characters over the serial port but it
would be slow.

UNIX was one of era's most prolific Operating Systems.  Created in the 70's and
still used in various forms today.  Today's UNIX Operating Systems can't run in
64K of RAM.  The closest thing is probably FUZIX[2] which requires banked RAM
that the Altair doesn't have (side note, I've just learned of an ESP8266 port of
FUZIX[3] that does not require banked RAM).  Still, it's UNIX-like and small so
such a system is possible on the Altair.


# Why not something compatible? #

It's often advantageous to create an OS that is compatible with another one to
leverage existing applications.  I thought about starting with a CP/M compatible
OS of my own to be able to run existing CP/M software.  Or porting FUZIX and to
use software compiled for FUZIX.

I chose not to do this since, so far, this journey has been about implementing
everything myself from scratch.  I am using 100% my own code.  Discovering and
solving all the problems my own ways.  I've bootstrapped from hand assembly
entered on the front panel.  And I've looked at very little 8080 code, let alone
copied any.

I want to keep going down that road.  There are applications I want to write,
too.  And I don't really have any existing applications in mind that I want to
run.  I had never used CP/M, coming to computers well past it's time.  And of
course there are UNIX utilities I'll need but if 2 guys could write the first
UNIX themselves without ever having seen in before, surely, knowing what it is,
I can write it myself, too.  ...Given some amount of time.


# Altair UNIX #

So I started to build a UNIX-like OS for the Altair.  TOS for now, T for TronDD.
Or maybe TUNIX?

I had considered writing a replica of the first version of UNIX.  Not to try to
run programs from it, they were all written for the PDP-11 anyway, but just to
keep things simple, follow in the UNIX footsteps, and have a kind of port of the
original to the Altair which never got it.  But having used UNIX for many years
(decades), I'm used to some of the more modern paradigms and improvements.  I'm
not trying to build a modern UNIX, for sure there isn't enough memory in the
Altair for that, but just taking some of the ideas and simplifying them.

So far, I have glanced at some FUZIX code and the original UNIX documentation
for architecture and feature ideas but mostly I am using OpenBSD man pages and
include files and just figuring things out as I go.


Part 2 will get into what's been written and what some of the design decisions
and plans are.

[0] http://s100computers.com/My%20System%20Pages/IDE%20Board/My%20IDE%20Card.htm
[1] https://en.wikipedia.org/wiki/CP/M
[2] https://github.com/EtchedPixels/FUZIX
[3] http://cowlark.com/2021-02-09-esp8266-fuzix/