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

Versions: 1.13, 1.2 and 1.21

Introduction

The MOS you have been reading is version 1.2. Einsteins are also found with MOS 1.21, and MAME carries both. Line the two ROM images up byte by byte and 4,071 of their 8,192 bytes differ - half the ROM. Yet the difference between them fits in a table of five rows. This section shows both facts and how they fit together, starting with where 1.2 itself came from.

Where 1.2 came from

The MOS's source code survives, and its header says who made it and when:

CRYSTAL RESEARCH VERSION OF TATUNG HOME-COMPUTER MACHINE OPERATING SYSTEM VERSION 1.2 - UPDATED 20/10/84 (MODIFIED FROM XTAL MOS VERSION 1.13 - BY Nigel Deakin) TATUNG SPECIFICATION 85-9647-6 ISSUE 2

So the MOS was written by Crystal Research - "Xtal", the usual abbreviation of crystal, is the name in the banner: TATUNG/Xtal MOS - to a specification from Tatung, and version 1.2 was a modification of an earlier Xtal MOS, 1.13.

Nor was 1.2 the first version in Einsteins. In March 1985 the magazine Einstein User told owners whose start-up screen said version 1.1 that they needed the new ROM - which Tatung sold for £11.90, refundable if the old one was returned. Replacing the MOS meant replacing a chip.

What 1.21 changed

Compare the two ROMs and three changes remain once the moved addresses are set aside:

In 1.2In 1.21Change
009Ch009Chstart-up writes two values to port 11h; the second changes from 27h to 15h
0146h-0166h0146h-0166hthe version text: MOS 1.2 becomes MOS 1.21
0F4Bh-0F4Dh0F4Bh-0F50hin the routine at 0F48h (call 160), RRA / JR NC,0F49h becomes AND 05h / CP 05h / JR NZ,0F49h, before OUT (10h),A
-0F55h-0F58hadded at the start of call 161's routine: LD A,35h / OUT (11h),A
-0F61h-0F66hadded before its RET: PUSH AF / LD A,05h / OUT (11h),A / POP AF

Ports 10h and 11h belong to the 8251, the serial chip (S2). Every change apart from the version number is in how the MOS drives it: one start-up setting, and the two routines that send and receive a byte. The routine for call 160 now waits until two status bits are set instead of one; the routine for call 161 now writes to the chip's control port before and after waiting for a byte. MOS 1.21 is MOS 1.2 with its serial handling revised.

Why 13 bytes moved half the ROM

The edits add 3 + 4 + 6 = 13 bytes in the middle of the ROM, at 0F4Bh. Everything after them - the dispatcher, the RAM-code images, the key table, the character set and the rest - moves 13 bytes higher. And every absolute address that points into that region must change by 0Dh:

  • every JP and CALL to a routine after 0F4Bh;
  • every LD HL, of a table there;
  • and the entries of FMTBL for every call whose routine moved.

A JR is untouched, because it holds a distance, not an address. Most of the ROM's other differences are these adjusted addresses: 125 bytes are halves of addresses that grew by exactly 0Dh, and the 13 extra bytes push everything after 0F4Bh out of line with the old image. The 33 unused bytes at the end of 1.21 are the 46 of 1.2, less the 13 it needed.

The course's files include mos121.asm, the source of MOS 1.21, built and checked the same way as mos12.asm. Put the routine at 0F48h in the two side by side and the 13 bytes are easy to find.

This is what an assembler does for you. Change one routine in the source, reassemble, and every address in the program is recomputed. Comparing images byte by byte makes the change look enormous; comparing the source makes it look like what it is.

The code

You can see the move from inside a running program. This reads the table entry for call 180 - entry 52, at 0282h + 104 = 02EAh - from the ROM, using the switching trick from S4, and leaves it in HL:

        ORG 256

        LD HL,GET       ; copy GET above 8000h (S4)
        LD DE,9000h
        LD BC,GETEND-GET
        LDIR
        DI
        CALL 9000h      ; HL = the word at 02EAh in the ROM
        EI
        RET

GET:    OUT (24h),A     ; ROM in
        LD HL,(02EAh)
        OUT (24h),A     ; RAM back
        RET
GETEND:

Build and run

Press Run. Then start MAME again with -bios mos121 and run it once more.

What you should see

With MOS 1.2:

 A   BC   DE   HL   PC  SZ-H-PNC
0E 0000 9008 0F6A 0FA5 00100000

With MOS 1.21:

 A   BC   DE   HL   PC  SZ-H-PNC
FF 0000 9008 0F77 0769 00001000

HL is the routine's address: 0F6Ah in 1.2, 0F77h in 1.21 - 0Dh higher, because that routine lies after the edit.

Change one thing

Change both 02EAhs in the program to 02BEh, the entry for call 158, and run it under each MOS again. Look up where OUTC is (S10) and decide before you run it: will HL differ between the two versions this time?

Summary

The MOS's source records it as Crystal Research's version 1.2 for Tatung, of 20 October 1984, modified from Xtal MOS 1.13. MOS 1.21 changes one start-up value, the version text and 13 bytes of the serial routines; everything after those 13 bytes moves up, and every absolute address pointing past them grows by 0Dh - which is why half the image differs.

Next

Part Four: changing the MOS yourself. S14 gathers the changes you have made along the way into a MOS of your own.

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.