
DISKMON has called the MOS without checking anything. Two questions every call raises: which of my registers are still mine afterwards, and how do I know it worked?
After call 162, IX, IY and the alternate registers (AF', BC', DE', HL') are as you left them. A, BC, DE and HL are not - keep anything you need in them on the stack, as READDIR will in S16.
The Z flag. Set, the sector was read. Clear, it was not. Test it with JP NZ straight after the call.
Do not test A for 0: a successful read leaves A = 80h. On failure A holds an error number, the same one the MOS leaves in its scratch-pad at FB56h:
| Number | Means |
|---|---|
| 3 | No sector: the ID is not on that track, or the track is not on the disc |
| 1 | Bad data |
When a sector will not read, the MOS tries again - several seconds of trying - before it gives up and returns. It prints nothing: deciding what to do is your program's job. That is the great difference from the BDOS in S12.
One case does not come back at all: asking for a drive with no disc in it. Make sure there is a disc there.
DISCERR prints the number and, for 3 and 1, what it means. S jumps there on NZ:
After the line CMDS1: CALL READSEC, add:
JP NZ,DISCERR
After the line JP CMDS1, add:
; DISCERR: the MOS said no. A holds its error number.
DISCERR: PUSH AF
LD HL,DERRM
CALL PRINT
POP AF
PUSH AF
CALL PHEX
POP AF
CP 3
LD HL,NOSECM
JP Z,DONE
CP 1
LD HL,BADM
JP Z,DONE
JP CRMAIN
After the line SSEC: DEFB 0, add:
DERRM: DEFB 'DISC ERROR ',0
NOSECM: DEFB ': NO SECTOR',13,10,0
BADM: DEFB ': BAD DATA',13,10,0
Run it on a copy of PRIMER.DSK:
S 1 2 10
S 1 40 0
What you should see (each after a pause while the MOS tries)
> S 1 2 10
DISC ERROR 03: NO SECTOR
> S 1 40 0
DISC ERROR 03: NO SECTOR
>
There is no sector 10 on an Einstein track, and no track 40.
PUSH IX / POP IX round the RST 8 in READSEC. Is it needed?JP NZ,DISCERR to JP C,DISCERR. What will S 1 2 10 do?| Symptom | Cause |
|---|---|
DISKMON stops responding after S 1 ... | No disc in drive 1: the call never returns. Reset MAME |
Call 162 keeps IX, IY and the alternate set; the Z flag says whether it read the sector; on failure A (and FB56h) holds the reason, and your program decides what to do.
S16: DISKMON reads the directory itself and lists the files.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.