
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.
These come back in A, and your program decides what to do:
| Call | Means "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.
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:
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 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.
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:
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?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.
Part three: under the DOS, to the MOS and its sectors - starting with the first sector DISKMON reads for itself.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.