TRSDOS 6.2 for the Model 4 - SYS10/SYS Disassembled

Page Customization

Introduction/Summary

TRSDOS 6.2 SYS10/SYS Disassembly (Model 4)

SYS10/SYS is the overlay of @REMOVE (SVC 57), the system's only way to delete a file. It is a load module of 257 bytes, 212 of them loaded: 210 at 1E00H-1ED1H and the length word at 23FEH-23FFH, with its transfer address at 1E00H. A program opens the file and calls @REMOVE with Register Pair DE pointing at the FCB; the stub at 19A6H on the SYS0/SYS page sends request 9CH, and RST28 has CKMOD@ load SYS10 into the overlay area, unless OVRLY$ shows it is still there, and calls 1E00H (1E00H). The REMOVE command (member 5 of SYS6/SYS), PURGE (member 5 of SYS7/SYS), SYSGEN (member 2 of SYS8/SYS), BACKUP/CMD, CONV/CMD and BASIC's KILL remove files this way.

For an open file SYS10 first checks the access level the file was opened with: only FULL or REMOVE (levels 0 and 1) may remove it, any other gives error 37 with nothing changed (1E0BH). On a write protected diskette @OPEN gives the FCB READ access, so @REMOVE fails here with error 37, not 15; an FCB built by hand, as PURGE builds it, gets error 15 from the first @DIRWR with nothing changed. It reads the GAT of the drive into DIRBUF$ (2300H) and then works through the file's directory entries, the primary entry (FPDE) at the file's DEC and each extended entry (FXDE) it links to. For each entry it walks the extent fields from DIR+22 and clears every granule of each extent in the GAT copy, stopping at a field that starts with FEH (a link) or FFH (the end); it marks the entry spare by resetting bit 4 of DIR+0 and writes the directory sector, then reads the HIT, puts 00H at the entry's position and writes the HIT. A link sends it on to the FXDE named in the field (1E1BH). After the last entry it writes the GAT and fills the 32 bytes of the FCB with 00H. The return goes through RESTREG, set up by CKOPEN@, so the caller gets back Register Pairs BC, DE and HL and Index Register IX; Register A holds 00H with the Zero flag, or the error with NZ.

The granules of an extent are cleared by RMVEXT (1E89H). The first byte of the extent field is the cylinder and so the GAT byte; the second gives the first granule in bits 7-5 and the count less one in bits 4-0. The granules per cylinder are DCT+8 bits 7-5 plus one, doubled for a two sided drive (DCT+4 bit 5), and the count runs on into the next GAT byte when the cylinder is used up. Each bit is cleared with an instruction RES n,B that RMVGRN writes for the granule (1EC5H).

An FCB that is not open goes another way (1E6BH). If its type byte is 10H, a device that @OPEN or @INIT routed to, @REMOVE closes it as @CLOSE would: the FCB becomes an asterisk, the device's two letters and 03H. The device stays as it is; removing a device is the REMOVE command's work with the DCB, not this SVC's. Any other FCB gets error 38, File not open.

The bytes are those of the TRSDOS 6.2.1 Level AR system diskette. The labels are those of Logical Systems' own source of the system, whose SYS10/ASM is headed LDOS 6.2 and dated 11 February 1983: aligned against this file it accounts for all 212 loaded bytes over 124 source rows with no instruction unexplained.

This file is the same program in LS-DOS 6.3.1H. Laid into memory through their own load records the two releases' SYS10/SYS images are identical to the byte, all 212 of them, and all 123 instructions stand at the same address doing the same thing. The two files differ in twenty bytes and nowhere else: the copyright record at file offset 0008H, which is never loaded, reads *(C) 1982,83,84 by LSI* here and (C) 1982-4,6,90 MISOSYS in the later release. So the LS-DOS 6.3.1 SYS10/SYS page is this same disassembly under the later name, and the two bugs below are those two bugs one generation earlier. The only way this system has of deleting a file was written in February 1983 and never changed again.

Notes

The entries are written as they are freed, the GAT only at the end. A disk error once the first directory write has reached the disk (its verify, the HIT read or write, the read of an FXDE, or the GAT write) returns at once: the entries written so far are spare, an entry whose HIT step failed keeps its HIT position, an FXDE not yet reached stays in use with its FPDE gone, and the GAT on the disk still shows all the granules in use (T28). An error in the GAT read or the FPDE read, or a write protected disk (error 15 at 1E44H), changes nothing. The FCB is then left open, and a second @REMOVE with it finishes the removal, since the walk does not test the in use bit; REMOVE and PURGE stop at the first error, and once the FCB is gone the file cannot be opened again (error 24).

The rest of a spare entry is left as it was, its name, dates and extent fields with it. Nothing tests whether another FCB has the same file open, which is a bug of SYS3/SYS. Nor is the entry at FCB+7 checked to be in use or to hold the file's name, so an FCB whose file was already removed, or whose diskette was changed, removes whatever entry now has that DEC (T29). A freed FXDE keeps bit 7 (80H) and the spare FPDE its FE link, where CLOSE writes 00H and FFH FFH; nothing reads a spare entry. Functions 2 to 7 of the request return NZ with Register A holding the function times 10H; no stub sends them.

There are no hidden instructions. Three operands are written while SYS10 runs: the LD DE at 1E53H keeps the extent field that ended each entry's walk (1E54H), the CP at 1EB9H the granules per cylinder (1EBAH), and the RES at 1ECFH its bit number (1ED0H). The GAT read at 1E21H puts the last two bytes of the GAT over the overlay length at 23FEH-23FFH.

Bugs (listed on the TRSDOS 6.2 reference page): T28, @REMOVE writes each directory entry and the HIT as it frees them and the GAT only at the end, and returns at the first disk error: once the first directory write has reached the disk the file is left half removed, its entries spare (one perhaps still in the HIT), an FXDE not yet reached in use with no FPDE, and all its granules allocated in the GAT on the disk, so the file can no longer be opened and its space is lost (1E27H, 1E52H, 1E5FH); T29, the entry at the FCB's DEC is freed without a test that it is still the file's, so removing through a second FCB of a file already removed, or through an FCB kept open across a diskette change, deletes whatever file now has that DEC (1E1BH).

Variables

Memory Used by SYS10/SYS

Address
Size
Contents
1D00H-1DFFH
256 bytes
SBUFF$
The directory sector of each entry (1E24H), then the HIT (1E47H), changed at 1E42H and 1E4DH.
1E54H-1E55H
2 bytes
EXTINFO+1
The extent field last read (1E2FH), loaded at 1E53H after the walk.
1EBAH
1 byte
GRNSCYL+1
The granules per cylinder (1EA2H), compared at 1EB9H.
1ED0H
1 byte
RMVGRN1+1
The second byte of RES n,B (1ECCH).
2300H-23FFH
256 bytes
DIRBUF$
The GAT of the drive (1E21H), changed by RMVEXT (1EB6H) and written at 1E5CH.
23FEH-23FFH
2 bytes
Overlay length
00D2H, the length of SYS10 read by SYSTEM (SYSRES); written over by the GAT read.

Routines of Other Files Called

AddressRoutine
1566H, 1568HLNKFCB@ and CKOPEN@ (SYS0/SYS): Index Register IX to the FCB, the return through RESTREG (1E70H, 1E0BH).
1803H@DIRWR (SYS0/SYS): writes SBUFF$ to the directory sector of entry Register B (1E44H).
1874H, 1875H@GATRD and @GATWR (SYS0/SYS): read and write the GAT in DIRBUF$ (1E21H, 1E5CH).
1897H, 1898H@HITRD and @HITWR (SYS0/SYS): read and write the HIT in SBUFF$ (1E47H, 1E4FH).
18BBH@DIRRD (SYS0/SYS): reads the directory sector of entry Register B into SBUFF$, Register Pair HL to the entry (1E24H).
1A2BH@DCTBYT (SYS0/SYS): a byte of the drive's DCT (1E8DH, 1E99H).

Disassembly

1E00H - SYS10: @REMOVE

@REMOVE (SVC 57) is LD A,57 and RST 28H with Register Pair DE pointing at an FCB; the stub at 19A6H on the SYS0/SYS page sends request 9CH, so RST28 has CKMOD@ load SYS10, unless OVRLY$ shows it is still there, and calls 1E00H. For an open file, with REMOVE or FULL access, SYS10 gives every granule of the file back in the GAT, marks its directory entry and any extended entries spare, puts 00H in their HIT positions and clears the 32 bytes of the FCB. For a device opened as a file it only turns the FCB back into the device specification, as @CLOSE does. The REMOVE command (member 5 of SYS6/SYS), PURGE (member 5 of SYS7/SYS), SYSGEN (SYS8/SYS), BACKUP/CMD, CONV/CMD and BASIC/CMD use it.

1E00SYS10
AND 70H E6 70
SYS10: mask Register A, the request from RST28 (9CH for @REMOVE), with 70H, keeping the function number times 10H in bits 6-4.
1E02
RET Z C8
Return at once if Register A is 00H: function 0 (request 8CH) only loads SYS10; nothing in the 6.3.1 system sends it.
1E03
CP 10H FE 10
Compare Register A with 10H, function 1, the remove itself; the source says remove all for now.
1E05
RET NZ C0
Return if Register A is not 10H, with the NZ flag and Register A holding the function times 10H (20H to 70H) as if it were an error number; no stub sends these requests.
1E06
LD A,(DE) 1A
Load Register A with FCB+0 at Register Pair DE, the type byte of the FCB: bit 7 is set for an open file.
1E07
BIT 7,A CB 7F
Test bit 7 of Register A, the open file bit of the FCB.
1E09
Jump to 1E6BH (CLOSDCB) if bit 7 is clear: not an open file, perhaps a device opened as one.
1E0B
Call 1568H (CKOPEN@, on the SYS0/SYS page): it points Index Register IX at the FCB, keeps JDCB$ for @ERROR and arranges that SYS10's return goes through RESTREG (1589H), which gives the caller back Register Pairs BC, DE, HL and Index Register IX.
1E0E
LD A,(IX+01H) DD 7E 01
Load Register A with FCB+1 at Index Register IX+01H, whose bits 2-0 are the access level the file was opened with.
1E11
AND 07H E6 07
AND Register A with 07H, keeping the access level: 0 FULL, 1 REMOVE, 2 RENAME and up to 7 NO.
1E13
CP 02H FE 02
Compare Register A with 02H, the RENAME level, the first level that may not remove the file.
1E15
Jump to 1E1BH (REMOV1) if Register A is below 02H: the file was opened with FULL or REMOVE access.
1E17
LD A,25H 3E 25
Load Register A with 25H, error 37, Illegal access attempted to protected file.
1E19
OR A B7
OR Register A with itself to set the NZ flag for the error return.
1E1A
RET C9
Return through RESTREG with error 37 in Register A and NZ: nothing has been changed on the disk.

1E1BH - REMOV1: Free the Granules, the Entries and the HIT Positions

The GAT of the file's drive is read into DIRBUF$ (2300H) and kept there to the end. For the file's primary directory entry (FPDE) and then each extended entry (FXDE) in turn, the extent fields from DIR+22 are walked: each extent's granules are cleared in the GAT copy (RMVEXT), and the walk ends at a field whose first byte is FEH (the link to an FXDE) or FFH (no more). The entry is then marked spare and written, and its HIT position set to 00H and the HIT written; a link sends the work on to the FXDE. Only after the last entry is the GAT written back. An error returns at once. Before the first directory write has reached the disk nothing has changed; after it, the entries already marked spare stay spare and the GAT on the disk still allocates their granules, because it is written only at 1E5CH (T28). Nothing tests that the entry at the FCB's DEC is in use or holds the file's name (T29).

1E1BREMOV1
LD C,(IX+06H) DD 4E 06
REMOV1: load Register C with FCB+6 at Index Register IX+06H, the drive number of the file (no test that the diskette is the one the file was opened on: T29). Bug T29: the entry at the FCB's DEC is freed with no test that it is still the file's, so an FCB kept across an earlier removal or a diskette change deletes whatever file now holds that DEC. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B209.
1E1E
LD B,(IX+07H) DD 46 07
Load Register B with FCB+7 at Index Register IX+07H, the DEC of the file: the position of its FPDE in the directory and in the HIT.
1E21
Call 1874H (@GATRD, on the SYS0/SYS page) to read the GAT of drive Register C into DIRBUF$ (2300H); NZ with the error on failure.
1E24REMOV2
REMOV2: call 18BBH (@DIRRD, on the SYS0/SYS page) if the Zero flag is set, reading the directory sector of entry Register B on drive Register C into SBUFF$ (1D00H); Register Pair HL points at the entry.
1E27
RET NZ C0
Return through RESTREG if the Zero flag is clear: the GAT or the directory could not be read (error 20 from @GATRD, or error 17 from @DIRRD, for the FPDE or, on a later pass, an FXDE): after an FXDE error the file is half removed. Bug T28: the entries and the HIT are written as they are freed and the GAT only at the end, so a disk error once the first directory write has reached the disk leaves the file half removed with all its granules still allocated. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B208.
1E28
LD A,16H 3E 16
Load Register A with 16H, 22, the offset of the first extent field in a directory entry.
1E2A
ADD A,L 85
Add Register L, the low byte of the entry's address in SBUFF$, to Register A.
1E2B
LD L,A 6F
Load Register L with Register A: Register Pair HL points at DIR+22, the first extent field.
1E2CREMOV3
LD E,(HL) 5E
REMOV3: load Register E with the byte at Register Pair HL, the first byte of an extent field: the cylinder of the extent relative to the start, or FEH or FFH.
1E2D
INC L 2C
Increment Register L to the second byte of the field.
1E2E
LD D,(HL) 56
Load Register D with the byte at Register Pair HL: bits 7-5 the first granule of the extent on its cylinder, bits 4-0 the count of granules less one, or for a link the DEC of the FXDE.
1E2F
LD (1E54H),DE ED 53 54 1E
Store Register Pair DE at 1E54H, the operand of the LD DE at 1E53H (EXTINFO): after the walk it holds the field that ended it.
1E33
LD A,E 7B
Load Register A with Register E, the first byte of the field, to see whether it is an extent.
1E34
CP 0FEH FE FE
Compare Register A with FEH: FEH links to an FXDE, FFH marks the end; a cylinder of 0 to FDH is an extent.
1E36
Jump to 1E3EH (FIXDIR) if Register A is FEH or more: the extents of this entry are done.
1E38
INC L 2C
Increment Register L to the next extent field; Register Pair DE still holds this one.
1E39
Call 1E89H (RMVEXT) to clear the granules of the extent in Register Pair DE in the GAT copy at 2300H.
1E3C
Jump back to 1E2CH (REMOV3) for the next extent field.
1E3EFIXDIR
LD A,L 7D
FIXDIR: load Register A with Register L, the low byte of the address of the field that ended the walk.
1E3F
AND 0E0H E6 E0
AND Register A with E0H: the low byte of the start of the 32 byte entry in SBUFF$.
1E41
LD L,A 6F
Load Register L with Register A: Register Pair HL points at DIR+0 of the entry.
1E42
RES 4,(HL) CB A6
Reset bit 4 of the byte at Register Pair HL, the in use bit of DIR+0: the entry is spare. Its name, dates and extents stay as they were.
1E44
Call 1803H (@DIRWR, on the SYS0/SYS page) to write SBUFF$ back to the directory sector of entry Register B on drive Register C, with the system data mark; it tries twice and returns error 18, or 15 for a write protected disk.
1E47
Call 1897H (@HITRD, on the SYS0/SYS page) if the Zero flag is set, reading the HIT of drive Register C into SBUFF$ (1D00H) over the directory sector.
1E4A
LD H,1DH 26 1D
Load Register H with 1DH, the high byte of SBUFF$, where the HIT now is.
1E4C
LD L,B 68
Load Register L with Register B, the DEC of the entry: Register Pair HL points at its HIT position. After an error of @DIRWR or @HITRD the 00H below goes into whatever SBUFF$ holds and is not written.
1E4D
LD (HL),00H 36 00
Store 00H at Register Pair HL, the HIT position of the entry: the position is free.
1E4F
Call 1898H (@HITWR, on the SYS0/SYS page) if the Zero flag is set, writing SBUFF$ back to the HIT of drive Register C.
1E52
RET NZ C0
Return through RESTREG if the Zero flag is clear: the directory sector could not be written or verified (error 18, or 15 for a write protected disk), or the HIT could not be read (22) or written (23). The entry may already be spare on the disk with its HIT position still in use, and the GAT on the disk still shows its granules in use. Bug T28: the entries and the HIT are written as they are freed and the GAT only at the end, so a return here leaves the file half removed with all its granules still allocated. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B208.
1E53EXTINFO
LD DE,0000H 11 00 00
EXTINFO: load Register Pair DE with the field that ended the walk, stored into this operand (1E54H, 0000H in the file) at 1E2FH: Register E is FEH for a link, FFH for the end, and Register D the DEC of the FXDE.
1E56
LD B,D 42
Load Register B with Register D, the DEC of the FXDE when the field is a link, for @DIRRD.
1E57
LD A,E 7B
Load Register A with Register E, the first byte of the field.
1E58
CP 0FEH FE FE
Compare Register A with FEH, the link to an FXDE, setting the Zero flag for it.
1E5A
Jump to 1E24H (REMOV2) if the Zero flag is set, with Register B the FXDE's DEC: its extents, its entry and its HIT position are freed the same way.
1E5C
Call 1875H (@GATWR, on the SYS0/SYS page) to write the GAT copy at 2300H back to drive Register C, with the system data mark, and verify it.
1E5F
RET NZ C0
Return through RESTREG if the Zero flag is clear: the GAT could not be written (error 21, which @GATWR returns for every failure; a write protected disk has already failed at 1E44H with error 15). Every entry is now spare and out of the HIT while the GAT on the disk still allocates their granules. Bug T28: the GAT is written only after every entry has been freed, so a return here leaves the entries spare and all the file's granules allocated on the disk. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B208.
1E60
PUSH IX DD E5
Push Index Register IX, the FCB address, onto the stack (Stack Pointer).
1E62
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): Register Pair HL points at the FCB.
1E63
LD B,20H 06 20
Load Register B with 20H, the 32 bytes of the FCB.
1E65
XOR A AF
Clear Register A to 00H, the byte the FCB is filled with; the Zero flag is set for the success return.
1E66ZERLP1
LD (HL),A 77
ZERLP1: store Register A (00H) at Register Pair HL, the next byte of the FCB.
1E67
INC HL 23
Increment Register Pair HL to the next byte of the FCB.
1E68
Decrement Register B and jump back to 1E66H while it is not zero (DJNZ): the whole FCB is cleared, so it is no longer open and holds no name.
1E6A
RET C9
Return through RESTREG with Register A 00H and the Zero flag set: the file is gone.

1E6BH - CLOSDCB: A Device Opened as a File

The FCB is not an open file. If its type byte is 10H, a device that @OPEN or @INIT routed to (DEVOPEN), @REMOVE only closes it: the FCB becomes an asterisk, the two letters of the device name from FCB+6 and FCB+7, and 03H, the way @CLOSE leaves it (CLOSDEV in SYS3/SYS). The device itself is not removed. Any other FCB gets error 38.

1E6BCLOSDCB
CP 10H FE 10
CLOSDCB: compare Register A, the type byte of the FCB, with 10H, the mark of a device opened as a file.
1E6D
LD A,26H 3E 26
Load Register A with 26H, error 38, File not open; the flags of the compare are kept.
1E6F
RET NZ C0
Return with error 38 in Register A and NZ if the type byte was not 10H: an FCB never opened, or one already closed.
1E70
Call 1566H (LNKFCB@, on the SYS0/SYS page), which takes the FCB as open: Index Register IX points at it and the return goes through RESTREG (1589H).
1E73
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 at Index Register IX+06H, the first letter of the device name.
1E76
LD B,(IX+07H) DD 46 07
Load Register B with FCB+7 at Index Register IX+07H, the second letter of the device name.
1E79
LD (IX+00H),2AH DD 36 00 2A
Store 2AH, the asterisk that starts a device specification, at FCB+0 (Index Register IX+00H).
1E7D
LD (IX+01H),C DD 71 01
Store Register C, the first letter of the device name, at FCB+1 (Index Register IX+01H).
1E80
LD (IX+02H),B DD 70 02
Store Register B, the second letter of the device name, at FCB+2 (Index Register IX+02H).
1E83
LD (IX+03H),03H DD 36 03 03
Store 03H, the end of the specification, at FCB+3 (Index Register IX+03H).
1E87
XOR A AF
Clear Register A to 00H and set the Zero flag: no error.
1E88
RET C9
Return through RESTREG with Register A 00H and Z, the device closed and the FCB holding its name again.

1E89H - RMVEXT and RMVGRN: Clear the Granules of an Extent

Register Pair DE holds an extent field: Register E the cylinder relative to the start of the disk, which is the GAT byte (2300H plus the cylinder); Register D bits 7-5 the first granule and bits 4-0 the count less one. The granules per cylinder come from the drive's DCT (DCT+8 bits 7-5, plus 1, doubled for a two sided drive: DCT+4 bit 5). The granules are cleared one by one with a RES n,B that RMVGRN builds, going on to the next GAT byte when a cylinder is used up, as an extent may run over cylinders.

1E89RMVEXT
PUSH HL E5
RMVEXT: push Register Pair HL, the pointer into the directory entry, onto the stack (Stack Pointer).
1E8A
PUSH BC C5
Push Register Pair BC, Register B the DEC and Register C the drive, onto the stack (Stack Pointer).
1E8B
LD A,08H 3E 08
Load Register A with 08H, the number of the DCT field that holds the granules per track less one in bits 7-5 (the sectors per granule less one in bits 4-0).
1E8D
Call 1A2BH (@DCTBYT, on the SYS0/SYS page) for DCT+8 of drive Register C in Register A.
1E90
RLCA 07
Rotate Register A left (RLCA), the first of three rotations that bring bits 7-5 down to bits 2-0.
1E91
RLCA 07
Rotate Register A left (RLCA) a second time, bits 7-5 of DCT+8 moving down.
1E92
RLCA 07
Rotate Register A left (RLCA) a third time: the granules less one are in bits 2-0.
1E93
AND 07H E6 07
AND Register A with 07H, keeping bits 2-0, the granules on one side of a cylinder less one.
1E95
INC A 3C
Increment Register A: the granules on one side of a cylinder, 1 to 8.
1E96
LD L,A 6F
Load Register L with Register A, keeping the count while the next field is read.
1E97
LD A,04H 3E 04
Load Register A with 04H, the number of the DCT field whose bit 5 marks a two sided drive.
1E99
Call 1A2BH (@DCTBYT, on the SYS0/SYS page) for DCT+4 of drive Register C in Register A.
1E9C
BIT 5,A CB 6F
Test bit 5 of Register A, the two sided bit of DCT+4.
1E9E
LD A,L 7D
Load Register A with Register L, the granules on one side; the flags of the BIT are kept.
1E9F
Jump to 1EA2H if the Zero flag is set: one sided, the count stands.
1EA1
ADD A,A 87
Add Register A to itself: a two sided cylinder has twice as many granules.
1EA2
LD (1EBAH),A 32 BA 1E
Store Register A, the granules per cylinder, at 1EBAH, the operand of the CP at 1EB9H (GRNSCYL).
1EA5
LD L,E 6B
Load Register L with Register E, the relative cylinder of the extent.
1EA6
LD H,23H 26 23
Load Register H with 23H, the high byte of DIRBUF$: Register Pair HL points at the GAT byte of the cylinder.
1EA8
LD A,D 7A
Load Register A with Register D, the first granule and the count of the extent.
1EA9
AND 1FH E6 1F
AND Register A with 1FH, keeping bits 4-0, the count of granules less one.
1EAB
LD C,A 4F
Load Register C with Register A, the count less one.
1EAC
INC C 0C
Increment Register C: the count of granules to clear, 1 to 32.
1EAD
XOR D AA
Exclusive OR Register A with Register D: the count bits cancel, leaving the first granule in bits 7-5 of Register A.
1EAE
RLCA 07
Rotate Register A left (RLCA), the first of three rotations that bring bits 7-5 down to bits 2-0.
1EAF
RLCA 07
Rotate Register A left (RLCA) a second time, the first granule moving down.
1EB0
RLCA 07
Rotate Register A left (RLCA) a third time: Register A is the first granule, 0 to 7.
1EB1RMVEX1
PUSH AF F5
RMVEX1: push Register Pair AF, the granule number in Register A, onto the stack (Stack Pointer).
1EB2
LD B,(HL) 46
Load Register B with the byte at Register Pair HL, the GAT byte of the cylinder.
1EB3
Call 1EC5H (RMVGRN) to clear the bit of granule Register A in Register B.
1EB6
LD (HL),B 70
Store Register B, the GAT byte with the granule free, back at Register Pair HL.
1EB7
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the granule number again.
1EB8
INC A 3C
Increment Register A, the granule number, to the next granule of the extent.
1EB9GRNSCYL
CP 00H FE 00
GRNSCYL: compare Register A with the granules per cylinder, the operand at 1EBAH that 1EA2H set (00H in the file).
1EBB
Jump to 1EBFH (DECGRNS) if Register A is not the granules per cylinder: the next granule is on the same cylinder.
1EBD
XOR A AF
Clear Register A to 00H, the first granule of the next cylinder.
1EBE
INC L 2C
Increment Register L: Register Pair HL points at the GAT byte of the next cylinder.
1EBFDECGRNS
DEC C 0D
DECGRNS: decrement Register C, the granules left to clear.
1EC0
Jump back to 1EB1H (RMVEX1) if Register C is not zero.
1EC2
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): the DEC and the drive again.
1EC3
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the pointer to the next extent field.
1EC4
RET C9
Return to REMOV3's loop at 1E3CH, which goes on with the next extent field.
1EC5RMVGRN
AND 07H E6 07
RMVGRN: AND Register A with 07H, the granule 0 to 7 of the cylinder.
1EC7
RLCA 07
Rotate Register A left (RLCA), the first of three rotations that move the granule into bits 5-3.
1EC8
RLCA 07
Rotate Register A left (RLCA) a second time, the granule number moving up.
1EC9
RLCA 07
Rotate Register A left (RLCA) a third time: the granule is in bits 5-3, the bit field of a RES instruction.
1ECA
OR 80H F6 80
OR Register A with 80H: 80H plus 8 times the granule, the second byte of RES n,B.
1ECC
LD (1ED0H),A 32 D0 1E
Store Register A at 1ED0H, the second byte of the RES at 1ECFH (RMVGRN1).
1ECFRMVGRN1
RES 0,B CB 80
RMVGRN1: reset bit 0 of Register B; the instruction is RES n,B for the granule n stored at 1ECCH: the granule is free in the GAT byte.
1ED1
RET C9
Return to RMVEX1 at 1EB6H with the GAT byte in Register B. This is the last byte of SYS10 (LAST is 1ED2H).
1ED2-23FD
DEFS 1324
1ED2H-23FDH: the rest of the overlay area, not loaded by SYS10/SYS; DIRBUF$ (2300H-23FFH) within it holds the GAT while SYS10 runs.
23FE-23FF
DEFW 00D2H D2 00
23FEH-23FFH = 00D2H (210): the length of SYS10, 1E00H to 1ED1H (LAST less 1E00H). SYSTEM (SYSRES) reads it when it copies the overlay into high memory; the GAT read at 1E21H puts the last two bytes of the GAT here.