Assembly Disc Access Primer, a TatungBytes course: DISKMON reading the hidden sector IDs of the course's own practice disc, on a rainbow sunburst
← Back to Modules
module
19

What the Einstein Does When It Starts

Introduction

Part four takes the DOS away. To run with no DOS, DISKMON must be what the Einstein starts when you switch it on - so first, what does it do when you switch it on?

The Boot Header

If there is a disc in drive 0, the MOS reads track 0, sector 0 and looks at its first seven bytes:

BytesHolds
0-1Start: where in memory to load, low byte first
2-3End: the last address to fill
4-5Jump: where to start running
6The side flag: 0

It then reads whole sectors - track 0 sector 0, sector 1, sector 2 and on, in order of their IDs - into memory from the start address until it has covered the end address, and jumps to the jump address. The header itself is loaded too: it is the first seven bytes at the start address.

That is all the Einstein does by itself. If what it loads is a DOS, you get XtalDOS's 0: prompt. If it is anything else, you get that.

The Code

U d reads track 0 sector 0 of a drive and shows its header.

After the line JP Z,CMDM, add:

        CP 'U'
        JP Z,CMDU

After the last line of CMDM (JP DONE), add:

; U d: read drive d's track 0 sector 0 and show its boot header.
CMDU:   CALL GETNUM
        JP C,WHAT
        LD (SDRV),A
        XOR A
        LD (STRK),A
        LD (SSEC),A
        CALL READSEC
        JP NZ,DISCERR
        LD IX,SECBUF
        LD HL,STARTM
        CALL PRINT
        LD L,(IX+0)
        LD H,(IX+1)
        CALL PHEXW
        LD HL,ENDM
        CALL PRINT
        LD L,(IX+2)
        LD H,(IX+3)
        CALL PHEXW
        LD HL,JUMPM
        CALL PRINT
        LD L,(IX+4)
        LD H,(IX+5)
        CALL PHEXW
        LD HL,SIDEM
        CALL PRINT
        LD A,(IX+6)
        CALL PHEX
        JP CRMAIN

After the line RLEFT: DEFB 0, add:

STARTM: DEFB 'START ',0
ENDM:   DEFB ' END ',0
JUMPM:  DEFB ' JUMP ',0
SIDEM:  DEFB ' SIDE ',0

Run it on a copy of PRIMER.DSK, with the system disc in drive 0 as always:

U 0
U 1

What you should see

> U 0
START E100 END FB00 JUMP FA00 SIDE 00
> U 1
START E5E5 END E5E5 JUMP E5E5 SIDE E5
>

The system disc loads from E100h to FB00h and starts at FA00h: that is XtalDOS putting itself where S5 found it - its command processor at E100h, the BDOS above, and at FA00h the part that 0000h's JP FA03H leads to. PRIMER.DSK was made by edisc.py, which leaves tracks 0 and 1 blank: there is no header, only E5h.

Change One Thing

  • How many sectors does the system disc's header make the MOS load? (From E100h to FB00h, 512 bytes a sector.) Do they fit on track 0?
  • The system disc starts running at FA00h, not at E100h where it starts loading. What, then, is in the first bytes at E100h - and does anything stop them being the header itself?

Summary

At power-on the MOS loads what track 0 sector 0's header says and jumps to it. XtalDOS is just the code a system disc's header points at.

Next

S20 writes a header of DISKMON's own, so that a disc starts DISKMON instead.

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.