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
12

When the DOS Says No

Introduction

So far everything DISKMON asked for was there. Sooner or later something will not be: a file that was never written, a record past the end, a disc with a bad sector. The BDOS says no in two very different ways.

Answers You Get

These come back in A, and your program decides what to do:

CallMeans "no"
Open (15), delete (19), rename (23)FFh: no such file
Read sequential (20)1: the end of the file
Read random (33)1: no such record (in a part of the file that exists); 4: no such extent - the record number is past any part of the file

DISKMON's R so far printed A= and the number. Now it says what the number means.

Errors You Do Not Get

When the disc fails - a sector that cannot be found, a drive with no disc - the BDOS does not tell your program. It puts its own message on the screen and asks the person at the keyboard:

  • A sector it cannot read: No Sector 1: and Try Again(Y/N)?. Y tries again. N abandons your program altogether and returns to the 0: prompt - your program's next instruction never runs.
  • No disc in the drive: No Drive 1: and No.(0-3)?, asking for another drive to use instead.

So a program working through the BDOS cannot recover from a disc error by itself. In Part three DISKMON goes to the MOS, which reports disc errors to the program instead.

The Code

Replace CMDR1 with one that names the two answers:

Take out these lines:

CMDR1:  PUSH AF
        LD HL,AM
        CALL PRINT              ; PRINT leaves A = 0, so keep it
        POP AF
        CALL PHEX
        JP CRMAIN

After the last line of CMDR (JP MAIN), add:

CMDR1:  CP 1
        LD HL,NORECM
        JP Z,DONE
        CP 4
        LD HL,NOEXTM
        JP Z,DONE
        PUSH AF
        LD HL,AM
        CALL PRINT
        POP AF
        CALL PHEX
        JP CRMAIN

After the line RENM: DEFB 'RENAMED',13,10,0, add:

NORECM: DEFB 'NO SUCH RECORD',13,10,0
NOEXTM: DEFB 'NO SUCH EXTENT',13,10,0

Run it on a copy of PRIMER.DSK:

R 1:ROOMS.DAT 300
T 1:NOSUCH.TXT
> R 1:ROOMS.DAT 300
NO SUCH EXTENT
> T 1:NOSUCH.TXT
NOT FOUND
>

Then put BROKEN.DSK (from the course download, with DISKMON added) in drive 1 instead. On it, POEM.TXT's only sector is missing.

T 1:POEM.TXT

and when the DOS asks, press N:

> T 1:POEM.TXT

No Sector 1:
Try Again(Y/N)?N
0:

Change One Thing

  • R 1:ROOMS.DAT 200 and R 1:ROOMS.DAT 256. Both are past the end. Which gives NO SUCH RECORD and which NO SUCH EXTENT - and why?
  • On BROKEN.DSK, answer Y instead. What happens, and how do you get out?

Summary

The BDOS answers "not found" and "no such record" in A, and DISKMON can act on them. Disc errors it handles itself, on the screen, and the program may never get control back.

Next

Part three: under the DOS, to the MOS and its sectors - starting with the first sector DISKMON reads 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.