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
2

Setting Up: Source to a Running Program on a Disc

Introduction

Before DISKMON can read a disc it has to be on one. In the assembly course MAME loaded your program straight into memory. From now on your program lives on a disc image, the way a real program does, and XtalDOS loads it when you type its name.

The Routine

Every section from here on ends the same way:

  1. Assemble the source to a .COM file.
  2. Put it on a disc image with edisc.py.
  3. Start MAME with the XtalDOS system disc in drive 0 and your image in drive 1.
  4. Type its name at the 0: prompt.

Keep your work in one folder, with edisc.py and a copy of the system disc (XTALDOS.DSK) in it. Use a copy, not your only one.

The Code

The first DISKMON does one thing: prints its own name. Type it in as diskmon.asm.

; DISKMON - reads and writes the Einstein's discs.
; The Assembly Disc Access Primer's program, as it stands at the end of
; the section named in this file's name.

        ORG 0100H

START:  LD HL,TITLE
        CALL PRINT
        RET

; --------------------------------------------------------------- output
; PRINT: print the zero-terminated text at HL.
PRINT:  LD A,(HL)
        OR A
        RET Z
        CALL PUTC
        INC HL
        JR PRINT

; PUTC: print the character in A, keeping BC, DE and HL.
PUTC:   PUSH BC
        PUSH DE
        PUSH HL
        RST 8
        DEFB 158
        POP HL
        POP DE
        POP BC
        RET

; ----------------------------------------------------------------- data
TITLE:  DEFB 'DISKMON',13,10,0

ORG 0100H because XtalDOS loads a program at 0100h and starts it there. PUTC keeps BC, DE and HL safe around call 158 itself, so that everything DISKMON builds on it can rely on them - you know HL survives the call, but not every register does. 13,10 is carriage return then line feed, a full newline. And RET at the end hands control back to the DOS.

Run it

z80asm -o diskmon.com diskmon.asm
python3 edisc.py create diskmon.dsk
python3 edisc.py add diskmon.dsk diskmon.com DISKMON.COM
mame -rompath ~/roms einstein -window -nomaximize -ui_active -skip_gameinfo -flop1 XTALDOS.DSK -flop2 diskmon.dsk

-flop1 is drive 0 and -flop2 drive 1. When the 0: prompt appears, type:

1:DISKMON

What you should see

0:1:DISKMON
DISKMON

0:

Then ask the DOS what is on your disc:

0:DIR 1:
1: DISKMON .COM
2k Size, 186k Free, 190k Total
0:

DISKMON's name, then DIR 1:

Each time you change the source, assemble again and replace the program on the disc. edisc.py add will not put a second file of the same name on a disc - it says DISKMON.COM is already on this disc - so take the old one off first:

python3 edisc.py remove diskmon.dsk DISKMON.COM
python3 edisc.py add diskmon.dsk diskmon.com DISKMON.COM

Quit MAME before you change the image, and start it again afterwards.

Change One Thing

  • Take out the 13,10 before the 0. Where will the 0: prompt appear after DISKMON has run?
  • Change ORG 0100H to ORG 0200H. PRINT, PUTC and TITLE are reached by absolute addresses. What will happen when you run it - and why does nothing in the source warn you?

When It Goes Wrong

SymptomCause
DISKMON.COM is already on this discThe old copy is still there: remove, then add

Summary

You can assemble a program, put it on your own disc image, and run it under XtalDOS from drive 1. DISKMON prints its name and hands back to the DOS.

Next

S3 recaps what is on a disc - the map DISKMON will need when it starts reading one for itself.

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.