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

Why a Computer Needs a MOS

Introduction

Switch on any computer and the processor starts running instructions immediately. It has no choice: that is all a processor does. So the very first question in the design of a home computer is: which instructions, and where do they come from?

The first instruction

The Z80 starts at address 0000h. On the Einstein, at the moment of power-on, the ROM is switched in at the bottom of memory, so the first instruction the machine ever runs is the MOS's first byte. Here are the first eight bytes of the ROM, from the course's source:

l0000h:
        ld hl,08000h            ;0000
        ld de,08001h            ;0003
        jr l0040h               ;0006

Three instructions, then a jump past the next 56 bytes to 0040h, where start-up proper begins. Why jump? Because the addresses in between are special to the Z80: RST 8, RST 10h, RST 18h and their siblings each call a fixed low address, so the MOS keeps those slots for itself. S7 opens the one at 0008h - the one every RST 8 in your programs has called.

There is nothing else the machine could run. RAM holds no program at power-on. If the ROM were not there, the Z80 would execute whatever meaningless values the RAM happened to contain.

The jobs

Starting the processor is only the first of the MOS's jobs. Between the first instruction and the > prompt, and after it, the MOS:

  1. Starts the machine. It fills memory, copies some of its own code into RAM (S6 explains why that is needed), sets up the stack and the interrupt system, and draws the start-up screen.
  2. Drives the screen. Every character you see, it puts there - shapes included. (S10)
  3. Reads the keyboard. It turns a key press into a character code. (S11)
  4. Keeps time. Once a second it updates a clock: six digits held at FB8Ch. (S12)
  5. Offers calls. RST 8 and a number gets your program any of these services without knowing a single port. (S7, S8)
  6. Runs the monitor. The > prompt reads a command letter and runs it: arithmetic, memory display, fill, copy and more. When your program returns, the monitor shows you its registers. (S9)
  7. Finds a disc. The start-up screen says so: Insert disc in drive 0 and press Ctrl-BREAK to load. The MOS is not the operating system you use from disc; it is the part that is always there.

All of that fits in 8K.

The code

The monitor has a command that converts hexadecimal to decimal, D. The ROM runs from 0000h to 1FFFh, so it ends one byte before 2000h. At the prompt, type:

D 2000

and press ENTER.

What you should see

>D 2000
8192
>

8,192 bytes: everything the MOS does is in that many.

Summary

The Z80 starts at 0000h, where the ROM sits at power-on, so the MOS is the first program the machine runs. From there it starts the hardware, drives the screen and keyboard, keeps time, offers calls to your programs and runs the monitor - all in 8K.

Next

S4: the ROM shares its addresses with RAM. How can one address hold two things, and what does that do to a program that wants to call the MOS?

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.