Inside the Einstein: The MOS, a TatungBytes course: the MOS 1.2 start up screen on a rainbow sunburst
← Back to Modules
module
1

Introduction

Introduction

Every program you wrote in the assembly course ended the same way. It returned, and something took over: the screen filled with a row of register values and a > appeared, waiting. Every character you printed went through RST 8 followed by 158; every key you read, through 156 or 181. You called these hundreds of times. You never saw what answered.

What answered is the MOS - the Machine Operating System - 8,192 bytes of program that live in a ROM chip inside the Einstein. This course opens it up.

What you will see

The MOS is small enough to read completely, and old enough that its design choices are visible on the surface. By the end of this course you will know:

  • What an 8-bit computer needs from a program like this - why a machine with a perfectly good processor and 64K of memory does nothing at all until 8K of fixed code tells it what to do.
  • How it starts the machine - from the first instruction after you switch on to the word Ready.
  • How your RST 8 calls reach it - including the clever part: how the MOS answers a call even when its own code is switched out of sight.
  • How it drives the screen, the keyboard and the clock - down to the ports and chips it talks to.
  • How the > prompt works - one table of 85 addresses doing two jobs.
  • Where it came from - the source code's own header records it as Crystal Research's version of the Tatung home computer's MOS, version 1.2, dated 20 October 1984, modified from Xtal MOS 1.13 by Nigel Deakin. You will see exactly what changed in the later MOS 1.21, and why so small a change touched thousands of bytes.
  • How to change it - and boot your changed MOS.

How the course works

You read the MOS as source code: a listing of all 8K, with every instruction at its ROM address. The source has been checked the only way that counts - assembling it gives back the original ROM, byte for byte - so anything you read in it is exactly what the machine runs. Where the original authors' names for routines are known, the source uses them: OUTC for the routine that prints a character, FMTBL for the table of calls.

Each section looks at one part of the MOS, says what it does and why it was built that way, and then gives you something to run: a small program that pokes at the MOS from outside, a monitor command, or a changed ROM. Now and then, where it really pays, a section ends with Change one thing: a single edit and a question. Predicting the result before you look is the quickest way to find out whether you have understood.

What you need

  • The assembly course, or the same knowledge: registers, LD, CALL and RET, the stack, RST 8 calls, hex. Nothing here is harder than its later sections, but nothing is explained twice.
  • The same tools: the assembler, MAME with the Einstein ROM, and the editor with the Run button. If you finished the assembly course you have them all. S5 adds one thing: building a ROM of your own.

The code

There is nothing to assemble yet. Start the Einstein as you always have and look at what the MOS puts on the screen before you have done anything:

            ***  EINSTEIN  ***

        Insert disc in drive 0 and
         press Ctrl-BREAK to load

TATUNG/Xtal MOS 1.2        (C) 1983 1984

Ready
>

Every character there was put on the screen by the MOS, using the same print routine your programs call. By S10 you will know where each one came from - the letters' shapes included.

What you should see

The screen above. The version number after MOS is the one this course teaches: 1.2.

Summary

The MOS is the 8K program that starts the Einstein, runs the > prompt and answers every RST 8 call. This course reads it as checked source code, one part at a time, and ends with you building and booting your own version.

Next

S2 steps back to the machine the MOS runs on: what an 8-bit computer is made of, and what the MOS has to work with.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.