TRSDOS 6.2 for the Model 4 - SYS0/SYS Disassembled

Page Customization

Introduction/Summary

TRSDOS 6.2 SYS0/SYS Disassembly (Model 4)

SYS0/SYS is everything resident in TRSDOS 6.2 that is not in BOOT/SYS. LBOOT on the BOOT/SYS page reads it record by record through the floppy disk driver and jumps to its transfer address, 1E00H. It is a load module of 43 load blocks, 4708 bytes of file and 4499 bytes loaded, every one of which is on exactly one row of this page, and the blocks go to five places: low memory (0000H-01FFH, the restart vectors, the time, the interrupt vectors and the task table, the 26 system flags, the system control blocks and the supervisor call table), 0380H-03FFH (the stack guard, @PAUSE, @SOUND, @DECHEX and the reboot stub), the resident system SYSRES at 1300H-1CFFH, the start-up code at 1E00H-2166H, which runs once and is then overwritten by the first overlay to load, and the sign-on screen, which is loaded straight into video memory at F80DH-FE27H in sixteen blocks.

SYSRES holds the file positioning routines from 1300H: the byte I/O that @GET and @PUT reach for an open file, the record services @READ, @WRITE, @POSN, @LOC, @LOF and the rest, the end of file test, the translation of a record number into a cylinder and a sector through the extents of the file control block, the allocation of space as a file grows, and the directory, GAT and HIT routines. Then comes the loader: @HIGH$, the stubs of the calls a system overlay serves, the disk calls, the RST 28H dispatcher, the routine that reads an overlay into 1E00H or a library member into 2400H, @LOAD, @RUN and the load module reader. Last is the task processor: the interrupt handler, the real time clock interrupt that runs the twelve task slots, and the task calls.

The start-up points the non maskable interrupt at the floppy disk driver, sets the ports from their images in low memory, works out how much memory the machine has, asks for the date and the time unless SYSTEM has turned the prompts off or a date survived a reset, shows the date, looks at the D, ENTER and CLEAR keys and at the AUTO command, loads the SYSGEN configuration, restores the drives and ends in the AUTO command or at TRSDOS Ready.

The bytes are those of the TRSDOS 6.2.1 system diskette, patch level AR. The labels and the names of the system's cells are those of Logical Systems' own source of TRSDOS 6.2, which is one patch level behind this release at level AD: aligned instruction by instruction against the whole of this file it leaves one instruction and five bytes unaccounted for, which are listed under Notes, so every label on this page sits on the instruction the source gives it.

Notes

Bugs (listed on the TRSDOS 6.2 reference page): T6, the search for a cylinder with a free granule (1756H) has no limit where the GAT's cylinder map ends, which a drive of more than 203 cylinders would need (latent); T7, EXITBRK (1C8EH) goes to the debugger or the BREAK vector without putting the memory map, the logical bank or NFLAG$ bit 6 back; T8, the start-up accepts only the years 1980 to 1987 (1ECAH), which is the limit that made an upgrade unavoidable and that LS-DOS 6.3 was sold to lift; T9, bit 7 and bit 0 of DATE$+4 are set and never cleared (1ED4H), and this file does not load the byte, so both survive a reset; T10, the boot key test reads keyboard rows 0 and 6 as one byte (1FDAH), so the down arrow starts the debugger as D does and the at sign skips the AUTO command as ENTER does; T11, the CLEAR key test reads rows 5 and 6 as one byte (204CH), so the space bar, the 9 and the oblique stroke all skip the SYSGEN configuration; T12, a reply of fewer than three fields does not end the parse (20F6H), so a short time reply is completed from whatever is left in the buffer at 1E00H. T6 and T7 stand in the same instructions in LS-DOS 6.3.1 and so are its bugs too, and so, in a wider form, are T9 to T12; T8 is the one the later release fixed outright.

Three places hide an instruction in the operand of another: 1567H (0D2H, so LNKFCB@ skips the open test of CKOPEN@), and 1874H and 1897H (0F6H, an OR 0AFH that sets NZ for @GATRD and @HITRD one byte before the XOR A of @GATWR and @HITWR).

Several instructions are written over while the system runs: FDDINT$ at 000EH by SYSTEM (SMOOTH); the debugger hook @DBGHK at 199FH (1A68H, 1A7AH, 1C75H); the operand bytes at 13EAH (the verify), 1650H and 1660H (IOREC), 16A7H (ALLOC), 1760H (CG17), 17ACH (STUFDEC), 1802H (NHIT3), 1839H (NHIT7), 1862H and 186DH (TSTBIT and SETBIT), 1A70H, 1A75H and 1A79H (the dispatcher), 1AD2H, 1BB3H, 1C88H (the BREAK vector) and 1CECH (@RPTSK); and in the start-up 1FD2H and 2002H, both of which patch the stub at 2056H before it is moved to 4350H.

The stub at 2056H-20ADH is shown at the addresses it is loaded at and runs 22FAH higher, at 4350H-43A7H: 2019H moves it there because 1E00H-23FFH is where the SYSGEN configuration and then the overlays load. Its run addresses are the same as LS-DOS 6.3.1's, 4360H for the call to @ICNFG and 4398H for the store at 0038H, although its file addresses are 28H lower.

A supervisor call number below 128 is looked up in SVCTAB$ (0100H), and the dispatcher copies the caller's Register C into Register A before it jumps to the routine it finds. A number with bit 7 set is an overlay request: its bits 3-0 name the overlay and its bits 6-4 the function wanted in it.

The whole of this file against Logical Systems' source of level AD. Over 2153 source rows and all 4499 loaded bytes there is one instruction and there are five bytes that the two do not share, and every one of the six is a patch of the levels between AD and AR rather than a mistake in the source: at 1A16H this release calls @BANK as a supervisor call, LD A,66H and RST 28H, where the source has a plain CALL into the routine, the same three bytes either way; FDDINT$ at 000EH ships as DI where the source leaves NOP, which goes with bit 3 of DFLAG$ being set; OSRLS$ at 003BH is 01H against 00H, which with OSVER$ at 0085H is what makes this release 6.02.01 and the source's 6.02.00; DFLAG$ at 006DH is 0AH against 02H, so type-ahead and SMOOTH are both on where the source has type-ahead alone; and the sign-on text in video memory carries this version and this year of copyright where the source carries the earlier ones.

Against LS-DOS 6.3.1, which Part 13 of this project disassembles in full. This release answers 99 supervisor calls where LS-DOS answers 107: 95 (@HEXD) and 107 (@VDPRT) are later additions and hold the invalid word here. @DATE is call 18 at 07A8H here, in the clock module of BOOT/SYS beside @TIME, where LS-DOS moves it into this file at 1420H. Every one of the fifteen file services, calls 61 to 75, is at a different address in the two releases, because LS-DOS re-laid the whole of 1300H-15FFH. And @SEEKSC, call 71, is a routine of its own here at 1421H that seeks the drive to a record, where LS-DOS points it at a RET and its own update sheet says the call does nothing.

Index Register IX points at the file control block through the whole of the file positioning code. Its bytes as that code reads them: byte 0 the access and type, with bit 6 set when the file may be written; byte 1 bit 7 byte or record working, bit 6 the end of file moves only when the file grows, bit 5 the buffer does not hold the record wanted, bit 4 the buffer has been changed, bits 2-0 the access level; bytes 3 and 4 the buffer address; byte 5 the offset of the next byte in the buffer; byte 8 the end of file offset; byte 9 the logical record length; bytes 10 and 11 the next record number; bytes 12 and 13 the ending record number.

Variables

Memory the Parts Written So Far Use and Do Not Show

Address
Size
Contents
0300H-037FH
128 bytes
STACK$
The system stack, which BOOT/SYS loads and this file does not. It rests at 0380H and grows downward; the two zero bytes at 0380H are the guard under it.
0470H-04BFH
80 bytes
DCT$
The eight drive code tables, ten bytes each, which BOOT/SYS loads. The stub moves a configured set over them at 2064H, and Index Register IY points at the table of the drive in hand through the disk code.
04C4H
1 byte
RSTOR$
Whether the drives are to be restored at boot, read by the stub at 2078H. BOOT/SYS loads it.
1D00H-1DFFH
256 bytes
SBUFF$
The system's own sector buffer, the last page of SYSRES. The system control block at 008FH and the job control block at 00C3H both point at it, so an overlay read and a job control file read share it.
1E00H-23FFH
1536 bytes
OVERLAY and DIRBUF$
The overlay area. The start-up code of this file runs at 1E00H and is the first thing in it; after that each of SYS1/SYS to SYS13/SYS loads there in turn, and 2300H-23FFH is the directory sector buffer. 1E00H is also the buffer the start-up reads its replies into.
2400H
-
MAXCOR$
The first address above the overlay area, where a library member, a driver, a filter or a drive table loads.
3000H
-
MINCOR$
The lowest address a program may use, which is what LOW$ at 001EH holds in the file.
4300H-43FFH
256 bytes
MOD3BUF
A scratch page above the overlay area, which the boot sector ran in. @IPL copies the five byte reboot stub at 03FBH to 4300H and returns to it, the start-up moves eight drive code tables through it, and the stub at 2056H is moved to 4350H and run there.
F400H-F7FFH
1024 bytes
The keyboard
Eight rows read at F401H, F402H, F404H, F408H, F410H, F420H, F440H and F480H when the keyboard is switched in. The start-up reads row 6 at F460H for the CLEAR key at 204CH and rows 0 and 6 together for the boot keys.
F800H-FFFFH
2048 bytes
CRTBGN$
The video memory, 80 by 24 characters from F800H. Sixteen of this file's load blocks write the sign-on screen straight into it at F80DH-FE27H, so the screen is painted by the loader and not by any code.
90H
port
SNDPORT
The sound port. @SOUND at 0392H drives bit 0 high and bit 1 low in turn, holding each for a count that sets the pitch.
9CH
port
The Model 4P boot ROM control
Bit 0 set maps the boot ROM in at 0000H. Only a Model 4P answers it; the three bytes at 0001H write to it and a Model 4 ignores them.

Disassembly

0000H - Page 0: Restart Vectors and System Storage

SYS0/SYS loads the first page of memory, 0000H-00F0H, in six pieces: the restart vectors, the time, the interrupt vectors and the task table, the 26 system flags, two chain vectors and the control blocks of the system files. In the memory map this DOS runs the Model 4 in there is no ROM, so every one of these addresses is RAM. The six areas the file does not load (user storage, the whole of DATE$, the non maskable interrupt vector, the debugger's save area and the ends of two file control blocks) are shown as DEFS rows and keep whatever was in memory; the boot code and the start-up code at 1E00H set some of them.

0000@RST00
DI F3
Disable interrupts. RST 00H and a jump to 0000H start the Model 4P's power up sequence; @IPL (SVC 0) at 1BF2H does not come here, it carries its own five byte stub.
0001
LD A,01H 3E 01
Load Register A with 01H for port 9CH, the Model 4P boot ROM control port: bit 0 set maps the boot ROM in at 0000H.
0003
OUT (9CH),A D3 9C
Send Register A (01H) to port 9CH. On a Model 4P the boot ROM now answers at 0000H and runs from 0005H on; on a Model 4, which has no port 9CH, the write does nothing and the three zero bytes and the RET at 0008H follow.
0005-0007
DEFB 00H, 00H, 00H 00 00 00
0005H-0007H: three zero bytes left free for a CP/M emulator's system call jump, which a CP/M program enters at 0005H.
0008@RST08
RET C9
Return at once to the address on the stack: RST 08H does nothing until a program stores a JP here over the RET and the two bytes after it.
0009-000A
DEFW 0000H 00 00
0009H-000AH: the two operand bytes of the RST 08H vector, 0000H until a program puts a JP and its address at 0008H.
000B-000CSVCRET$
DEFW 0000H 00 00
SVCRET$ (SVC Return Address), 000BH-000CH: the return address of the last supervisor call a program issued, stored by the RST 28H handler at 1A4BH for every call but @ERROR. 0000H in the file.
000DLSVC$
DEFB 00H 00
LSVC$ (Last SVC), 000DH: the number of the last supervisor call a program issued, stored at 1A47H for every call but @ERROR (SVC 26). 00H in the file.
000EFDDINT$
DI F3
Disable interrupts. The floppy disk driver calls FDDINT$ before it passes a command to the controller (CALL 000EH at 0F3FH on the BOOT/SYS page). The source leaves the byte as NOP and names DI (F3H) as the other value it takes: this release ships the DI, which agrees with DFLAG$ at 006DH having bit 3 set, so SYSTEM (SMOOTH) is on and interrupts are off through a disk transfer. SYSTEM (SMOOTH=OFF) stores a NOP here.
000F
RET C9
Return from FDDINT$ to the floppy disk driver through the address on the stack.
0010@RST10
RET C9
Return at once to the address on the stack: RST 10H does nothing until a program stores a JP here.
0011-0012
DEFW 0000H 00 00
0011H-0012H: the two operand bytes of the RST 10H vector, 0000H until a program puts a JP and its address at 0010H.
0013-0017USTOR$
DEFS 5
USTOR$ (User Storage), 0013H-0017H: five bytes left for programs' own use. SYS0/SYS does not load them, so they hold whatever was in memory.
0018@RST18
RET C9
Return at once to the address on the stack: RST 18H does nothing until a program stores a JP here.
0019-001A
DEFW 0000H 00 00
0019H-001AH: the two operand bytes of the RST 18H vector, 0000H until a program puts a JP and its address at 0018H.
001BPDRV$
DEFB 01H 01
PDRV$ (Physical Drive), 001BH = 01H in the file, the select bit of drive 0: the drive select byte the floppy disk driver last sent to port F4H, which it reselects the drive with while the controller is busy (0E87H, 0ED4H and 0F2EH on the BOOT/SYS page).
001C-001DPHIGH$
DEFW 0000H 00 00
PHIGH$ (Physical HIGH$), 001CH-001DH: the highest address of memory a program may use, below any resident driver. 0000H in the file; the start-up code at 1E4CH stores the value it works out here.
001E-001FLOW$
DEFW 3000H 00 30
LOW$, 001EH-001FH = 3000H in the file, MINCOR$: the low limit of the memory a program may use, read by @HIGH$ (SVC 100) at 1962H and written at 1965H when Register B is not zero. SYS1/SYS moves it to 2FFFH on every @EXIT and @CMNDI, so the 3000H of the file holds only through the start-up.
0020@RST20
RET C9
Return at once to the address on the stack: RST 20H does nothing until a program stores a JP here.
0021-0022
DEFW 0000H 00 00
0021H-0022H: the two operand bytes of the RST 20H vector, 0000H until a program puts a JP and its address at 0020H.
0023LDRV$
DEFB 00H 00
LDRV$ (Logical Drive), 0023H: the logical drive number of the disk request in hand, stored from Register C by the disk service front end at 1A04H and read by 19B8H. 00H in the file.
0024-0025JDCB$
DEFW 0000H 00 00
JDCB$, 0024H-0025H: the file control block or device control block address (Register Pair DE) of the last file request, saved by CKOPEN@ at 156EH. 0000H in the file.
0026-0027JRET$
DEFW 0000H 00 00
JRET$, 0026H-0027H: the return address of the last file request, saved by CKOPEN@ at 156BH. 0000H in the file.
0028@RST28
Jump to RST28 at 1A5BH, the supervisor call handler: a program loads Register A with a call number and executes RST 28H.
002BTIMSL$
DEFB 55H 55
TIMSL$ (Time Slice), 002BH = 55H (01010101 binary). The real time clock routine at 1C9BH rotates it left on every interrupt and runs the clock and tasks 0 to 10 only when a 1 bit falls out: with 55H on every second interrupt, which is 15 times a second, and with FFH on every one.
002CTIMER$
DEFB 00H 00
TIMER$, 002CH: the heartbeat counter, incremented at 1CB7H on every interrupt the time slice lets through; its low three bits choose which of tasks 0 to 7 runs. 00H in the file, and the keyboard driver reads it for the key repeat (09A8H and 0A1EH on the BOOT/SYS page).
002D-002FTIME$
DEFB 00H, 00H, 00H 00 00 00
TIME$, 002DH-002FH: the time of day in binary, the seconds at 002DH, the minutes at 002EH and the hours at 002FH, kept by the clock in BOOT/SYS. The start-up code copies the three bytes typed at the Time prompt here at 1FBFH.
0030@RST30
Jump to @DEBUG at 19A0H: RST 30H enters the system debugger.
0033-0037DATE$
DEFS 5
DATE$, 0033H-0037H: the date, the year less 1900 at 0033H, the day of the month at 0034H, the month at 0035H, the low eight bits of the day of the year at 0036H, and at 0037H bit 0 as bit 8 of the day of the year, bits 3-1 as the day of the week and bit 7 as the leap year flag. SYS0/SYS loads none of the five, so a date still in memory survives a reset and the start-up code reads it at 1E9AH; LS-DOS 6.3.1 loads 00H into 0036H, which is the one byte of DATE$ the two releases differ over.
0038@RST38
Jump to RST38@ at 1BFFH, the interrupt handler of the task processor. The boot code had stored C9H (RET) here so that a stray interrupt returned at once (4325H on the BOOT/SYS page); this file loads the jump over it, and the stub stores C3H here once more at 209EH, which it runs at 4398H after any SYSGEN configuration has been loaded.
003BOSRLS$
DEFB 01H 01
OSRLS$ (OS Release), 003BH = 01H, the release number: with OSVER$ at 0085H = 62H it names the system 6.02.01. The source has 00H here, which is the 6.02.00 of the earlier patch levels.
003CINTIM$
DEFB 00H 00
INTIM$ (Interrupt Image), 003CH: the interrupt latch read from port E0H by the interrupt handler and inverted, so that a set bit is a device asking to be served. 00H in the file.
003DINTMSK$
DEFB 2CH 2C
INTMSK$ (Interrupt Mask), 003DH = 2CH: the bits of INTIM$ the interrupt handler will serve. 2CH is bits 2 (the real time clock), 3 (the I/O bus) and 5 (the RS-232 receive), which are the only interrupts the task processor lets through.
003E-0045INTVC$
DEFW 1C48H, 1C48H, 1C94H, 1C48H 48 1C 48 1C 94 1C 48 1C
INTVC$ (Interrupt Vectors), 003EH-0045H, the first four of eight words, one for each bit of INTIM$ from bit 0 up. Bits 0, 1 and 3 point to RETINST, a RET at 1C48H, and bit 2, the real time clock, to RTCPROC at 1C94H. The handler steps through them at 1C29H.
0046-004D
DEFW 1C48H, 1C48H, 1C48H, 1C48H 48 1C 48 1C 48 1C 48 1C
INTVC$+8, 0046H-004DH: the words of interrupt bits 4 to 7, all of them RETINST at 1C48H. A driver that takes an interrupt, as the RS-232 driver takes bit 5, stores the address of its own routine here.
004E-0055TCB$
DEFW 1CE9H, 1CE9H, 1CE9H, 1CE9H E9 1C E9 1C E9 1C E9 1C
TCB$ (Task Control Block Vectors), 004EH-0055H, slots 0 to 3 of twelve. Each slot holds the address of a task's control block, whose first word is the task's entry point; 1CE9H is NOTASK, whose word points at a RET.
0056-005D
DEFW 1CE9H, 1CE9H, 1CE9H, 1CE9H E9 1C E9 1C E9 1C E9 1C
TCB$+8, 0056H-005DH: task slots 4 to 7, all of them NOTASK at 1CE9H. Slots 0 to 7 each come up on one clock tick in eight, chosen by the low three bits of TIMER$.
005E-0065
DEFW 1CE9H, 1CE9H, 0B26H, 1CE9H E9 1C E9 1C 26 0B E9 1C
TCB$+16, 005EH-0065H: task slots 8 to 11. Slots 8, 9 and 11 hold NOTASK at 1CE9H and slot 10 holds TYPTSK$ at 0B26H, the type-ahead task of the keyboard driver on the BOOT/SYS page. Slots 8 to 10 run on every tick the time slice lets through and slot 11 on every real time clock interrupt.
0066-0068@NMI
DEFS 3
@NMI, 0066H-0068H: the non maskable interrupt vector, which this file does not load. The boot code left a jump to its own read routine here; the start-up code stores 0FE9H, which is @RSTNMI of the floppy disk driver, into 0067H at 1E04H, so that the controller's interrupt goes to the driver.
0069OVRLY$
DEFB 00H 00
OVRLY$ (Overlay), 0069H: the request code of the system overlay last loaded, stored by the supervisor call handler at 1A71H and read at 1A91H; its low four bits name which of SYS1/SYS to SYS13/SYS is resident at 1E00H. 00H in the file.
006AAFLAG$
DEFB 01H 01
FLGTAB$ and AFLAG$, 006AH = 01H: the first of the 26 system flags A to Z that @FLAGS (SVC 101) points Index Register IY at. AFLAG$ is the cylinder the search for free space starts on.
006B
DEFB 00H 00
BFLAG$, 006BH: system flag B, 00H in the file.
006CCFLAG$
DEFB 00H 00
CFLAG$ (Condition Flag), 006CH: bit 0 HIGH$ may not be moved by SVC 100, 1 @CMNDR is running, 2 @KEYIN was called from SYS1/SYS, 3 a system request for a driver, filter or drive table, 4 @CMNDR may run library commands only, 5 SYSGEN is inhibited, 6 @ERROR is to show nothing, 7 @ERROR is to use the caller's buffer at Register Pair DE. 00H in the file.
006DDFLAG$
DEFB 0AH 0A
DFLAG$ (Device Flag), 006DH = 0AH: bit 0 the spooler is active, 1 type-ahead is active, 2 VERIFY is on, 3 SMOOTH is active, 4 a memory disk is active, 5 FORMS is active, 6 KSM is active, 7 graphics characters pass through a screen print. 0AH sets bits 1 and 3, so this release ships with type-ahead and SMOOTH on; the source has 02H, type-ahead alone, and the SMOOTH bit is what the DI at 000EH goes with.
006EEFLAG$
DEFB 00H 00
EFLAG$, 006EH: when it is not zero SYS1/SYS runs SYS13/SYS with bits 6-4 of this byte merged into the request, so that a program can have its own entry code passed to an Immediate Execution Program. 00H in the file.
006FFEMSK$
DEFB 00H 00
FEMSK$ (Port FE Mask), 006FH: the byte the start-up code reads at 1E6BH and sends to port FEH. 00H in the file.
0070-0071
DEFB 00H, 00H 00 00
GFLAG$ and HFLAG$, 0070H-0071H: system flags G and H, both 00H in the file.
0072
DEFB 00H 00
IFLAG$ (International Flag), 0072H: bits 2-0 the French, German and Swiss character sets, bit 6 a special printer mode, bit 7 seven bit working. 00H in this United States build, which is the only build the source switches on.
0073
DEFB 00H 00
JFLAG$, 0073H: system flag J, 00H in the file.
0074KFLAG$
DEFB 00H 00
KFLAG$ (Keyboard Flag), 0074H: bit 0 BREAK has been seen, 1 PAUSE has been seen, 2 ENTER has been seen, 5 the CAPS lock, 7 a character is waiting in the type-ahead buffer. The keyboard driver on the BOOT/SYS page sets and reads it. 00H in the file.
0075LFLAG$
DEFB 11H 11
LFLAG$, 0075H = 11H: bit 0 FORMAT does not ask for the step rate, bit 4 FLOPPY/DCT does not ask about eight inch drives, bit 5 FORMAT does not ask for the number of sides, bits 7-6 are kept for interrupt mode 2 hardware. 11H sets bits 0 and 4.
0076MODOUT$
DEFB 78H 78
MODOUT$, 0076H = 78H: the copy of port ECH, which cannot be read back. Bit 1 the cassette motor, 2 forty characters a line, 3 the alternate character set, 4 the external I/O bus, 5 the video wait states, 6 the 4 MHz clock. 78H sets bits 6 to 3; the start-up code reads it at 1E32H and the stub sends it to the port at 2061H.
0077
DEFB 00H 00
NFLAG$ (Network Flag), 0077H: bit 0 lets the open bit of a directory entry be set, bit 6 is set while the task processor is running, at 1C06H on the way in and cleared at 1C40H on the way out. 00H in the file.
0078OPREG$
DEFB 87H 87
OPREG$, 0078H = 87H: the copy of port 84H, the Operation Register, which cannot be read back. Bits 1-0 at 11 give RAM at every address, bit 2 the 80 by 24 display, bit 7 the second page of video memory. The boot code stored the 86H it sent here (0078H on the BOOT/SYS page), the start-up code reads it at 1E3CH, and the task processor saves and restores it at 1C12H and 1C37H.
0079
DEFB 00H 00
PFLAG$ (Printer Flag), 0079H: bit 7 is set while the printer spooler is paused. 00H in the file.
007A
DEFB 00H 00
QFLAG$, 007AH: system flag Q, which the floppy disk driver reads as Register C of the word load at 0F46H on the BOOT/SYS page, where Register B takes RFLAG$. 00H in the file.
007BRFLAG$
DEFB 08H 08
RFLAG$ (Retry Flag), 007BH = 08H: the number of tries the floppy disk driver makes before it gives a disk error, which it picks up as Register B of the word load at 0F46H on the BOOT/SYS page. The source asks for two at least.
007CSFLAG$
DEFB 08H 08
SFLAG$ (System Flag), 007CH = 08H: bit 0 the open bit of a file is not to be set, 1 an execute only file was opened, 2 @RUN may load an execute only file, 3 SYSTEM (FAST), 4 BREAK is disabled, 5 a job control file is running, 6 the long form of the error messages, 7 the debugger is to run after the load. 08H is the FAST bit alone, and the stub clears bit 4 at 2059H.
007DTFLAG$
DEFB 04H 04
TFLAG$ (Type Flag), 007DH = 04H, the machine type, a Model 4. The stub stores 05H instead at 2098H, which it runs at 4392H, when it finds the Model 4P boot ROM's leftover bytes at 4018H.
007E
DEFB 00H 00
UFLAG$, 007EH: system flag U, 00H in the file.
007FVFLAG$
DEFB 00H 00
VFLAG$ (Video Flag), 007FH: bits 3-0 the cursor blink rate, 4 the clock on the screen, 5 the phase of the blink, 6 the user asked for a solid cursor, 7 no blinking while the video driver is at work. 00H in the file.
0080WRINT$
DEFB 04H 04
WRINT$, 0080H = 04H: the interrupt enable mask the start-up code reads at 1E37H and sends to port E0H. Bits 1-0 the cassette edges, 2 the real time clock, 3 the I/O bus, 4 the RS-232 transmit, 5 the RS-232 receive, 6 an RS-232 error. 04H enables the clock and nothing else.
0081-0083
DEFB 00H, 00H, 00H 00 00 00
System flags X, Y and Z, 0081H-0083H, all 00H in the file and the last three of the 26. The source names none of them, which is worth saying because LS-DOS 6.3.1 makes 0082H YFLAG$ and ships FFH in it, a bit for each of drives 0 to 7 that uses the new style of directory dating: the new dating, and the flag that drives it, are both later than this release.
0084
DEFB 01H 01
0084H = 01H, the high byte of the address of the supervisor call table SVCTAB$ at 0100H. The handler does not read it: it carries the same 01H as the immediate operand of the LD H,01H at 1A51H. The byte is here for a program that wants to find the table.
0085OSVER$
DEFB 62H 62
OSVER$ (OS Version), 0085H = 62H: the version of the operating system, 6.2, read against the version byte of a diskette's GAT (62H on this release's own system diskette).
0086@ICNFG
RET C9
Return at once to the address on the stack: @ICNFG is the chain vector for the initialization of a configuration, called by the stub at 2066H, which it runs at 4360H, once a SYSGEN configuration has been loaded. A driver that came in with the configuration stores a JP here to its own start-up routine.
0087-0088
DEFW 0000H 00 00
0087H-0088H: the two operand bytes of the @ICNFG vector, 0000H until a JP is stored at 0086H.
0089@KITSK
RET C9
Return at once to the address on the stack: @KITSK is the chain vector of the keyboard task, called by the keyboard driver on every scan (CALL 0089H at 0925H on the BOOT/SYS page). A filter that wants to see each scan stores a JP here.
008A-008B
DEFW 0000H 00 00
008AH-008BH: the two operand bytes of the @KITSK vector, 0000H until a JP is stored at 0089H.
008C-008ESFCB$
DEFB 80H, 00H, 00H 80 00 00
SFCB$ (System File Control Block), 008CH-008EH: the control block the supervisor call handler reads the system overlays through. Byte 0 is 80H, an open file; byte 1 is 00H, which 1AB0H sets to 20H before each read; byte 2 is 00H.
008F-0090
DEFW 1D00H 00 1D
SFCB$+3, 008FH-0090H = 1D00H: the buffer of the system control block, SBUFF$, the system's own sector buffer.
0091
DEFB 00H 00
SFCB$+5, 0091H: the offset of the next byte in the buffer, 00H in the file.
0092-009F
DEFW 0000H, 0000H, 0000H, 0FFFFH, 0000H, 0FFFFH, 0FFFFH 00 00 00 00 00 00 FF FF 00 00 FF FF FF FF
SFCB$+6 to SFCB$+19, 0092H-009FH: drive 0 and a directory entry code of 00H, which 1AAAH sets to the overlay's own; an end of file offset of 00H and a logical record length of 00H, which is 256; a next record number of 0000H, which 1AB5H zeroes; an ending record number of FFFFH; and the first extent 0000H at 009AH-009BH with FFFFH in the two words after it, which 1ACBH fills in with the granule count and the second extent.
00A0-00BFDBGSV$
DEFS 32
DBGSV$ (Debugger Save Area), 00A0H-00BFH: the 32 bytes the debugger keeps the registers of the program it stopped in. Not loaded by this file.
00C0-00C2JFCB$
DEFB 00H, 00H, 00H 00 00 00
JFCB$ (JCL File Control Block), 00C0H-00C2H: the control block a job control file is read through, its first three bytes zero in the file.
00C3-00C4
DEFW 1D00H 00 1D
JFCB$+3, 00C3H-00C4H = 1D00H: the buffer of the job control block, SBUFF$, which it shares with the system control block.
00C5-00DF
DEFS 27
JFCB$+5 to JFCB$+31, 00C5H-00DFH: the rest of the job control block, not loaded.
00E0-00F0CFGFCB$
DEFM "CONFIG/SYS.CCC:0" / DEFB 03H 43 4F 4E 46 49 47 2F 53 59 53 2E 43 43 43 3A 30 03
CFGFCB$, 00E0H-00F0H: the control block the SYSGEN configuration is loaded through, which the file ships holding the file specification CONFIG/SYS.CCC:0, password CCC and drive 0, ended by the 03H the parser stops on. The start-up code points Register Pair DE at it at 2039H and jumps to @LOAD.
00F1-00FF
DEFS 15
CFGFCB$+17 to CFGFCB$+31, 00F1H-00FFH: the rest of the configuration control block, not loaded. The start-up code uses the last three bytes, 00FDH-00FFH, as the three fields of the date and then of the time it reads at the prompts, filling them downward from 00FFH at 20E8H.

0100H - SVCTAB$: The Supervisor Call Table

SVCTAB$, 0100H-01FFH, holds one address for each of the 128 supervisor call numbers. RST28 at 1A5BH doubles a number below 128 into the low byte of an address in page 01H, with the 01H of the high byte as an immediate operand at 1A51H, and jumps to the word it finds there with Register A loaded from Register C. Many of the words point at short stubs at 197BH-19B4H that pass the request on to a system overlay. Twenty-nine of the 128 numbers are unassigned and point at SVCERR at 1AF4H, which shows and logs Error 2BH (43, an SVC parameter error) and aborts the program: 23, 36 to 39, 84, 92, 95, 107 and 108 to 127. TRSDOS 6.2 answers 99 calls and LS-DOS 6.3.1 answers 107: the two the later release adds are 95 (@HEXD) and 107 (@VDPRT), and both of them hold the invalid word here. The names are those of SVCMAC/ASM, which gives a macro for each that assembles the LD A and the RST 28H.

0100-0107
DEFW 1BF2H, 0628H, 0642H, 0638H F2 1B 28 06 42 06 38 06
SVCTAB$+00H, 0100H-0107H: SVC 0 @IPL (reboot) at 1BF2H; SVC 1 @KEY (wait for a key) at 0628H; SVC 2 @DSP (show a character) at 0642H; SVC 3 @GET (get a byte from a device) at 0638H.
0108-010F
DEFW 0645H, 0623H, 063DH, 1979H 45 06 23 06 3D 06 79 19
SVCTAB$+08H, 0108H-010FH: SVC 4 @PUT (send a byte to a device) at 0645H; SVC 5 @CTL (control request to a device) at 0623H; SVC 6 @PRT (print a character) at 063DH; SVC 7 @WHERE (return the caller's address) at 1979H.
0110-0117
DEFW 0635H, 0585H, 052DH, 0503H 35 06 85 05 2D 05 03 05
SVCTAB$+10H, 0110H-0117H: SVC 8 @KBD (scan the keyboard) at 0635H; SVC 9 @KEYIN (read a line) at 0585H; SVC 10 @DSPLY (show a line) at 052DH; SVC 11 @LOGER (log a message) at 0503H.
0118-011F
DEFW 0500H, 0530H, 0528H, 0B99H 00 05 30 05 28 05 99 0B
SVCTAB$+18H, 0118H-011FH: SVC 12 @LOGOT (show and log a message) at 0500H; SVC 13 @MSG (send a message to a device) at 0530H; SVC 14 @PRINT (print a line) at 0528H; SVC 15 @VDCTL (video control) at 0B99H.
0120-0127
DEFW 0382H, 1987H, 07A8H, 078DH 82 03 87 19 A8 07 8D 07
SVCTAB$+20H, 0120H-0127H: SVC 16 @PAUSE (delay) at 0382H; SVC 17 @PARAM (parse parameters) at 1987H; SVC 18 @DATE (the date as text) at 07A8H, which is in the clock module of BOOT/SYS beside @TIME and not in this file, where LS-DOS 6.3.1 has @DATE at 1420H in the file and disk block and leaves 07A8H as the DATELO$ data its own symbol table names; SVC 19 @TIME (the time as text) at 078DH.
0128-012F
DEFW 0689H, 1B08H, 1B0BH, 1AF4H 89 06 08 1B 0B 1B F4 1A
SVCTAB$+28H, 0128H-012FH: SVC 20 @CHNIO (pass I/O down a device chain) at 0689H; SVC 21 @ABORT at 1B08H; SVC 22 @EXIT at 1B0BH; SVC 23 unassigned, SVCERR at 1AF4H.
0130-0137
DEFW 197EH, 197BH, 1B0FH, 19A0H 7E 19 7B 19 0F 1B A0 19
SVCTAB$+30H, 0130H-0137H: SVC 24 @CMNDI (run a command) at 197EH; SVC 25 @CMNDR (run a command and return) at 197BH; SVC 26 @ERROR (show an error) at 1B0FH; SVC 27 @DEBUG at 19A0H.
0138-013F
DEFW 1CF5H, 1CDAH, 1CD7H, 1CEBH F5 1C DA 1C D7 1C EB 1C
SVCTAB$+38H, 0138H-013FH: SVC 28 @CKTSK (check a task slot) at 1CF5H; SVC 29 @ADTSK (add a task) at 1CDAH; SVC 30 @RMTSK (remove a task) at 1CD7H; SVC 31 @RPTSK (replace the running task's vector) at 1CEBH.
0140-0147
DEFW 1CD0H, 1993H, 19AFH, 19ACH D0 1C 93 19 AF 19 AC 19
SVCTAB$+40H, 0140H-0147H: SVC 32 @KLTSK (end the running task) at 1CD0H; SVC 33 @CKDRV (check a drive) at 1993H; SVC 34 @DODIR (directory) at 19AFH; SVC 35 @RAMDIR (directory into memory) at 19ACH.
0148-014F
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+48H, 0148H-014FH: SVC 36 unassigned, SVCERR at 1AF4H; SVC 37 unassigned, SVCERR at 1AF4H; SVC 38 unassigned, SVCERR at 1AF4H; SVC 39 unassigned, SVCERR at 1AF4H.
0150-0157
DEFW 19B5H, 19BCH, 19C0H, 19C4H B5 19 BC 19 C0 19 C4 19
SVCTAB$+50H, 0150H-0157H: SVC 40 @DCSTAT (disk controller status) at 19B5H; SVC 41 @SLCT (select a drive) at 19BCH; SVC 42 @DCINIT (initialize the controller) at 19C0H; SVC 43 @DCRES (reset the controller) at 19C4H.
0158-015F
DEFW 19C8H, 19CCH, 19D0H, 19D4H C8 19 CC 19 D0 19 D4 19
SVCTAB$+58H, 0158H-015FH: SVC 44 @RSTOR (restore to cylinder 0) at 19C8H; SVC 45 @STEPI (step in) at 19CCH; SVC 46 @SEEK (seek a cylinder) at 19D0H; SVC 47 @RSLCT (reselect a drive) at 19D4H.
0160-0167
DEFW 19D8H, 19F4H, 19DCH, 19E0H D8 19 F4 19 DC 19 E0 19
SVCTAB$+60H, 0160H-0167H: SVC 48 @RDHDR (read a sector header) at 19D8H; SVC 49 @RDSEC (read a sector) at 19F4H; SVC 50 @VRSEC (verify a sector) at 19DCH; SVC 51 @RDTRK (read a track) at 19E0H.
0168-016F
DEFW 19E4H, 19E8H, 19ECH, 19F0H E4 19 E8 19 EC 19 F0 19
SVCTAB$+68H, 0168H-016FH: SVC 52 @HDFMT (format a hard drive) at 19E4H; SVC 53 @WRSEC (write a sector) at 19E8H; SVC 54 @WRSSC (write a system sector) at 19ECH; SVC 55 @WRTRK (write a track) at 19F0H.
0170-0177
DEFW 1996H, 19A6H, 198DH, 198AH 96 19 A6 19 8D 19 8A 19
SVCTAB$+70H, 0170H-0177H: SVC 56 @RENAM at 1996H; SVC 57 @REMOV at 19A6H; SVC 58 @INIT (open or create a file) at 198DH; SVC 59 @OPEN (open a file) at 198AH.
0178-017F
DEFW 1999H, 1486H, 158FH, 14B3H 99 19 86 14 8F 15 B3 14
SVCTAB$+78H, 0178H-017FH (every one of the fifteen file services 61 to 75 is at a different address in LS-DOS 6.3.1, which re-laid the whole block 1300H-15FFH): SVC 60 @CLOSE (close a file) at 1999H; SVC 61 @BKSP (back up one record) at 1486H; SVC 62 @CKEOF (check for end of file) at 158FH; SVC 63 @LOC (current record number) at 14B3H.
0180-0187
DEFW 14DEH, 14A2H, 1434H, 1513H DE 14 A2 14 34 14 13 15
SVCTAB$+80H, 0180H-0187H: SVC 64 @LOF (end of file record number) at 14DEH; SVC 65 @PEOF (position to end of file) at 14A2H; SVC 66 @POSN (position to a record) at 1434H; SVC 67 @READ (read a record) at 1513H.
0188-018F
DEFW 149BH, 1473H, 13ADH, 1421H 9B 14 73 14 AD 13 21 14
SVCTAB$+88H, 0188H-018FH: SVC 68 @REW (rewind) at 149BH; SVC 69 @RREAD (reread a record) at 1473H; SVC 70 @RWRIT (rewrite a sector) at 13ADH; SVC 71 @SEEKSC (seek a sector, a no-op) at 1421H.
0190-0197
DEFW 1430H, 1560H, 14ECH, 1531H 30 14 60 15 EC 14 31 15
SVCTAB$+90H, 0190H-0197H: SVC 72 @SKIP (skip a record) at 1430H; SVC 73 @VER (write and verify) at 1560H; SVC 74 @WEOF (write the end of file) at 14ECH; SVC 75 @WRITE (write a record) at 1531H.
0198-019F
DEFW 1B38H, 1B1DH, 1981H, 1984H 38 1B 1D 1B 81 19 84 19
SVCTAB$+98H, 0198H-019FH: SVC 76 @LOAD (load a program) at 1B38H; SVC 77 @RUN (load and run a program) at 1B1DH; SVC 78 @FSPEC (parse a filespec) at 1981H; SVC 79 @FEXT (default extension) at 1984H.
01A0-01A7
DEFW 199CH, 1A1EH, 1990H, 19B2H 9C 19 1E 1A 90 19 B2 19
SVCTAB$+A0H, 01A0H-01A7H: SVC 80 @FNAME (filespec of a directory entry) at 199CH; SVC 81 @GTDCT (drive code table address) at 1A1EH; SVC 82 @GTDCB (DCB address of a device) at 1990H; SVC 83 @GTMOD (find a memory module) at 19B2H.
01A8-01AF
DEFW 1AF4H, 18D8H, 1874H, 18BBH F4 1A D8 18 74 18 BB 18
SVCTAB$+A8H, 01A8H-01AFH: SVC 84 unassigned, SVCERR at 1AF4H; SVC 85 @RDSSC (read a system sector) at 18D8H; SVC 86 @GATRD (read the GAT) at 1874H; SVC 87 @DIRRD (read a directory sector) at 18BBH.
01B0-01B7
DEFW 1803H, 1875H, 190AH, 06C9H 03 18 75 18 0A 19 C9 06
SVCTAB$+B0H, 01B0H-01B7H: SVC 88 @DIRWR (write a directory sector) at 1803H; SVC 89 @GATWR (write the GAT) at 1875H; SVC 90 @MUL8 at 190AH; SVC 91 @MUL16 at 06C9H.
01B8-01BF
DEFW 1AF4H, 1927H, 06E3H, 1AF4H F4 1A 27 19 E3 06 F4 1A
SVCTAB$+B8H, 01B8H-01BFH: SVC 92 unassigned, SVCERR at 1AF4H; SVC 93 @DIV8 (divide 8 bits) at 1927H; SVC 94 @DIV16 (divide 16 bits) at 06E3H; SVC 95 unassigned, SVCERR at 1AF4H, where LS-DOS 6.3.1 puts @HEXD at 06F8H, a routine whose code stands in this release's BOOT/SYS with no call number of its own.
01C0-01C7
DEFW 03E1H, 06F6H, 07C2H, 07BDH E1 03 F6 06 C2 07 BD 07
SVCTAB$+C0H, 01C0H-01C7H: SVC 96 @DECHEX (decimal text to binary) at 03E1H; SVC 97 @HEXDEC (binary to decimal text) at 06F6H; SVC 98 @HEX8 (byte to hexadecimal text) at 07C2H; SVC 99 @HEX16 (word to hexadecimal text) at 07BDH.
01C8-01CF
DEFW 1948H, 196AH, 0877H, 196FH 48 19 6A 19 77 08 6F 19
SVCTAB$+C8H, 01C8H-01CFH: SVC 100 @HIGH$ (read or set HIGH$ or LOW$) at 1948H; SVC 101 @FLAGS (point to the system flags) at 196AH; SVC 102 @BANK (memory bank) at 0877H; SVC 103 @BREAK (BREAK vector) at 196FH.
01D0-01D7
DEFW 0392H, 0545H, 0553H, 1AF4H 92 03 45 05 53 05 F4 1A
SVCTAB$+D0H, 01D0H-01D7H: SVC 104 @SOUND (tone) at 0392H; SVC 105 @CLS (clear the screen) at 0545H; SVC 106 @CKBRKC (check and clear BREAK) at 0553H; SVC 107 unassigned, SVCERR at 1AF4H, where LS-DOS 6.3.1 puts @VDPRT at 0935H, the screen print, which in this release is reached only through the keyboard driver's own test at 092EH on the BOOT/SYS page.
01D8-01DF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+D8H, 01D8H-01DFH: SVC 108 unassigned, SVCERR at 1AF4H; SVC 109 unassigned, SVCERR at 1AF4H; SVC 110 unassigned, SVCERR at 1AF4H; SVC 111 unassigned, SVCERR at 1AF4H.
01E0-01E7
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+E0H, 01E0H-01E7H: SVC 112 unassigned, SVCERR at 1AF4H; SVC 113 unassigned, SVCERR at 1AF4H; SVC 114 unassigned, SVCERR at 1AF4H; SVC 115 unassigned, SVCERR at 1AF4H.
01E8-01EF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+E8H, 01E8H-01EFH: SVC 116 unassigned, SVCERR at 1AF4H; SVC 117 unassigned, SVCERR at 1AF4H; SVC 118 unassigned, SVCERR at 1AF4H; SVC 119 unassigned, SVCERR at 1AF4H.
01F0-01F7
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+F0H, 01F0H-01F7H: SVC 120 unassigned, SVCERR at 1AF4H; SVC 121 unassigned, SVCERR at 1AF4H; SVC 122 unassigned, SVCERR at 1AF4H; SVC 123 unassigned, SVCERR at 1AF4H.
01F8-01FF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+F8H, 01F8H-01FFH: SVC 124 unassigned, SVCERR at 1AF4H; SVC 125 unassigned, SVCERR at 1AF4H; SVC 126 unassigned, SVCERR at 1AF4H; SVC 127 unassigned, SVCERR at 1AF4H.

0380H - The Stack Guard, @PAUSE, @SOUND, @DECHEX and the Reboot Stub

SYS0/SYS loads 0380H-03FFH, the last 128 bytes of the system stack page, over what BOOT/SYS put there. The page holds four things that have nowhere else to live: the two word stack guard at the very bottom of the stack, the delay loop of @PAUSE (SVC 16), the tone generator of @SOUND (SVC 104) with its table of eight notes, the decimal to binary conversion of @DECHEX (SVC 96), and the five byte stub @IPL (SVC 0) copies to 4300H to restart the machine. The resting top of the stack is 0380H and STACK$ is 0300H, so a stack that grew more than 128 bytes would reach these routines: the two zero bytes at 0380H are what a program that overran the stack would overwrite first.

0380-0381
DEFW 0000H 00 00
0380H-0381H: the stack guard, the two bytes under the resting top of the system stack. ENADIS_DO_RAM on the BOOT/SYS page moves the stack to 0360H when it finds the Stack Pointer at F3FDH or above, which leaves 96 bytes above these two.
0382@PAUSE
PUSH BC C5
Save Register Pair BC, the count the caller asked to be delayed by, on the stack.
0383
LD A,(007CH) 3A 7C 00LD A,(SFLAG$)
Load Register A with 007CH (SFLAG$), the system flags.
0386
BIT 3,A CB 5F
Test bit 3 of Register A, SYSTEM (FAST): at 4 MHz every count has to be run twice for the same delay.
0388
If the machine is running fast, call CDLOOP at 038CH, which counts Register Pair BC down to zero once; the fall through at 038BH then does it a second time.
038B
POP BC C1
Restore Register Pair BC, the caller's count, from the stack, so that the second count starts from it again.
038CCDLOOP
DEC BC 0B
Decrement Register Pair BC, the count left to go.
038D
LD A,B 78
Load Register A with Register B, the high byte of the count.
038E
OR C B1
OR Register A with Register C, the low byte, which sets the Zero flag only when both bytes are zero.
038F
Loop back to CDLOOP at 038CH while the count has not reached zero.
0391
RET C9
Return to the caller with the delay run, Register Pair BC zero and Register A zero.
0392@SOUND
PUSH BC C5
Save Register Pair BC, the sound number and duration the caller asked for, on the stack.
0393
PUSH HL E5
Save Register Pair HL on the stack: the routine uses Register Pair HL for the table pointer and then for its two counters.
0394
LD A,B 78
Load Register A with Register B, the caller's sound byte: bits 2-0 the note, bits 7-3 the duration.
0395
AND 07H E6 07
AND Register A with 07H, leaving the note number 0 to 7.
0397
RLCA 07
Rotate Register A left, doubling the note number into an offset of two byte entries.
0398
LD HL,03D1H 21 D1 03LD HL,SNDTAB
Load Register Pair HL with 03D1H (SNDTAB), the table of eight notes.
039B
LD C,A 4F
Copy Register A, the offset, into Register C.
039C
LD A,B 78
Load Register A with Register B again, the sound byte, for the duration bits.
039D
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the offset alone.
039F
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, pointing at the note's two bytes in SNDTAB.
03A0
LD C,(HL) 4E
Load Register C with the first byte of the entry at Register Pair HL, the half cycle count that sets the pitch.
03A1
INC HL 23
Increment Register Pair HL to the second byte of the entry.
03A2
LD L,(HL) 6E
Load Register L with the second byte of the entry at Register Pair HL, the number of cycles in one unit of duration for this note, which overwrites the low byte of the table pointer and ends the use of Register Pair HL as a pointer; the longer the period of a note, the fewer cycles make the same length of time.
03A3
RRCA 0F
Rotate Register A right, the first of three that bring the duration bits down.
03A4
RRCA 0F
Rotate Register A right, the second of the three: the duration is now in bits 6-2 of Register A.
03A5
RRCA 0F
Rotate Register A right, the third, so that bits 7-3 of the caller's byte are now bits 4-0.
03A6
AND 1FH E6 1F
AND Register A with 1FH, leaving the duration 0 to 31 and clearing what the rotations brought round from the note number.
03A8
INC A 3C
Increment Register A, so that a duration of 0 still plays the note once.
03A9
LD H,A 67
Copy Register A into Register H, the outer counter of how many units of duration to play.
03AA
LD A,(007CH) 3A 7C 00LD A,(SFLAG$)
Load Register A with 007CH (SFLAG$), the system flags.
03AD
AND 08H E6 08
AND Register A with 08H, bit 3 of SFLAG$, which is SYSTEM (FAST) and tells the routine the clock is at 4 MHz.
03AF
If the machine is not running fast, jump to 03B7H and play the note as the table gives it.
03B1
SLA H CB 24
Shift Register H left, doubling the number of units of duration for the 4 MHz clock.
03B3
SLA L CB 25
Shift Register L left, doubling the cycles in a unit.
03B5
SLA C CB 21
Shift Register C left, doubling the half cycle count, which keeps the pitch the same at twice the clock rate.
03B7
DI F3
Disable interrupts: a clock interrupt in the middle of a half cycle would stretch it and sound as a click.
03B8
PUSH HL E5
Save Register Pair HL, the units of duration in Register H and the cycles in a unit in Register L, on the stack.
03B9
LD B,C 41
Load Register B with Register C, the half cycle count.
03BA
LD A,01H 3E 01
Load Register A with 01H, the bit that drives the sound port high.
03BC
OUT (90H),A D3 90
Send Register A (01H) to port 90H, the sound port, which starts the high half of the cycle.
03BE
Count Register B down to zero, jumping back to 03BEH itself until it reaches zero, which holds port 90H high for the length of the half cycle and so sets the pitch.
03C0
LD B,C 41
Load Register B with Register C again, the same count for the low half.
03C1
INC A 3C
Increment Register A to 02H, the bit that drives the port low.
03C2
OUT (90H),A D3 90
Send Register A (02H) to port 90H, the low half of the cycle.
03C4
Count Register B down to zero, jumping back to 03C4H itself until it reaches zero, which holds port 90H low for the same length and completes one cycle of the note.
03C6
DEC L 2D
Decrement Register L, the cycles left in this unit of duration.
03C7
Loop back to 03B9H for the next cycle while Register L has not reached zero.
03C9
POP HL E1
Restore Register Pair HL, the two counters, from the stack.
03CA
DEC H 25
Decrement Register H, the units of duration left.
03CB
Loop back to 03B8H for the next unit while Register H has not reached zero.
03CD
EI FB
Enable interrupts: the note is finished and the clock may have its ticks again.
03CE
POP HL E1
Restore Register Pair HL, the caller's value, from the stack.
03CF
POP BC C1
Restore Register Pair BC, the caller's sound byte, from the stack.
03D0
RET C9
Return to the caller with Register Pair BC and Register Pair HL as they were given.
03D1-03D4SNDTAB
DEFB 50H, 4CH, 56H, 48H 50 4C 56 48
SNDTAB, 03D1H-03D4H: notes 0 and 1, each a half cycle count and a cycles in a unit of duration. Note 0 is 50H and 4CH, the highest note; note 1 is 56H and 48H.
03D5-03D8
DEFB 5CH, 44H, 62H, 40H 5C 44 62 40
SNDTAB+4, 03D5H-03D8H: note 2 is 5CH and 44H; note 3 is 62H and 40H.
03D9-03DC
DEFB 6BH, 3CH, 72H, 38H 6B 3C 72 38
SNDTAB+8, 03D9H-03DCH: note 4 is 6BH and 3CH; note 5 is 72H and 38H.
03DD-03E0
DEFB 79H, 34H, 80H, 30H 79 34 80 30
SNDTAB+12, 03DDH-03E0H: note 6 is 79H and 34H; note 7 is 80H and 30H, the lowest note. The half cycle count rises and the cycles in a unit fall across the eight, which is what keeps a unit of duration the same length of time whatever note is played.
03E1@DECHEX
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value built so far: the caller points Register Pair HL at the first character.
03E4DEC1
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
03E5
SUB 30H D6 30
Subtract 30H from Register A, the code of the digit 0, which turns a decimal digit into its value and sets the Carry flag on anything below it.
03E7
RET C D8
Return with the Carry flag set and the value so far in Register Pair BC if the character was below the digit 0.
03E8
CP 0AH FE 0A
Compare Register A with 0AH (10), the first value no decimal digit gives.
03EA
RET NC D0
Return with no Carry if the character was above the digit 9, which ends the number on any other character.
03EB
PUSH BC C5
Save Register Pair BC, the value so far, on the stack.
03EC
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer points at, so that Register Pair HL becomes the value so far and the character pointer takes its place on the stack.
03ED
ADD HL,HL 29
Add Register Pair HL to itself, twice the value.
03EE
ADD HL,HL 29
Add Register Pair HL to itself, four times the value.
03EF
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, five times the value.
03F0
ADD HL,HL 29
Add Register Pair HL to itself, ten times the value.
03F1
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC can carry the new digit alone.
03F3
LD C,A 4F
Copy Register A, the new digit, into Register C.
03F4
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the value times ten plus the new digit.
03F5
LD B,H 44
Copy Register H into Register B, the new value to Register Pair BC.
03F6
LD C,L 4D
Copy Register L into Register C, which completes the move of the new value from Register Pair HL to Register Pair BC.
03F7
POP HL E1
Restore Register Pair HL, the character pointer, from the stack.
03F8
INC HL 23
Increment Register Pair HL to the next character.
03F9
Loop back to DEC1 at 03E4H for it. Nothing here guards against a value above FFFFH, so a number of more than five digits wraps round.
03FBBOOTCOD
DI F3
Disable interrupts. These five bytes are not run here: @IPL at 1BF2H copies them to 4300H and returns to them, because the first thing they do takes the memory they stand in out of the map.
03FC
XOR A AF
Clear Register A to 00H, the Operation Register value that puts the boot ROM back at 0000H.
03FD
OUT (84H),A D3 84
Send Register A (00H) to port 84H, the Operation Register, which maps the ROM in over the bottom of memory.
03FF
RST 00H C7
RST 00H, which is now the first byte of the boot ROM: the machine restarts and reads the system in again.

1300H - FILPOSN: @BYTEIO, Byte I/O to a File

SYS0/SYS loads 1300H-1CFFH, the resident file system, the system loader and the task processor (SYSRES), which stay in memory for the life of the system. It begins with the file positioning routines, FILPOSN. @BYTEIO is entered from @CHNIO (JP M,1300H at 0693H on the BOOT/SYS page) when a @GET, @PUT or @CTL is sent to a DCB that is an open file's FCB. Register B holds the request (1 get, 2 put, above 2 control), Register C the byte to put and Index Register IX the FCB. Throughout FILPOSN, FCB+1 bit 7 means byte or record I/O, bit 6 the end of file moves only when the file grows, bit 5 the buffer does not hold the current sector, bit 4 the buffer was changed, bit 3 the directory is updated on every write and bits 2-0 the access level; FCB+3/+4 is the buffer, +5 the offset of the next byte, +8 the end of file offset, +9 the LRL, +10/+11 the next record number (NRN) and +12/+13 the ending record number (ERN).

1300BYTEIO
PUSH IX DD E5
Save Index Register IX (the FCB) on the stack: BYTEIO is @BYTEIO in the system's symbol table.
1302
POP DE D1
Restore it into Register Pair DE: Register Pair DE points to the FCB, as CKOPEN@ expects.
1303
Call CKOPEN@ at 1568H: check that the FCB at Register Pair DE is open, point Index Register IX to it and save Register Pairs BC, DE, HL and IX for the return.
1306
SET 7,(IX+01H) DD CB 01 FE
Set bit 7 of FCB+1 (Index Register IX+01H): the file is now used for byte or record I/O, not only whole sectors.
130A
LD A,B 78
Copy Register B (the request: 1 get, 2 put, above 2 control) into Register A.
130B
CP 02H FE 02
Compare Register A with 02H, the put request.
130D
LD A,C 79
Load Register A with Register C, the byte to write for a put (the flags of the compare are kept).
130E
If the request is a put (Z), jump to 132FH (WRCHAR) to write Register A to the file.
1310
If the request is above 2 (No Carry), a control request, jump to 136AH (IORETZ) and return Z: files ignore @CTL.
1312RDCHAR
Call CKEOF1 at 1592H to test the position against the end of file: Z before it, NZ with Register A = 1CH or 1DH at or past it.
1315
RET NZ C0
Return with the end of file error in Register A if the file has no more bytes (NZ).
1316
BIT 5,(IX+01H) DD CB 01 6E
Test bit 5 of FCB+1 (Index Register IX+01H): set when the buffer does not hold the sector of the current position.
131A
If bit 5 is set, call NSEC1 at 1379H to read the next sector into the buffer.
131D
RET NZ C0
Return if the read failed, NZ with the error code in Register A.
131E
Call BFRPOS at 1413H: Register Pair DE = the buffer address plus the offset of the next byte.
1321
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE, the byte read from the file.
1322
INC (IX+05H) DD 34 05
Increment FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer.
1325
If the offset wrapped to 00H (Z), the sector is used up: call SET5 at 132AH to mark the buffer as not current.
1328
CP A BF
Compare Register A with itself: set the Z flag (no error) and keep the byte in Register A.
1329
RET C9
Return to the caller with the byte read in Register A and the Z flag set (no error).
132ASET5
SET 5,(IX+01H) DD CB 01 EE
Set bit 5 of FCB+1 (Index Register IX+01H): the buffer no longer holds the sector of the current position.
132E
RET C9
Return to the caller with the flags as they were before the SET (the SET instruction changes no flags).
132FWRCHAR
BIT 6,(IX+00H) DD CB 00 76
Test bit 6 of FCB+0 (Index Register IX+00H), set when the file was opened with UPDATE access or better.
1333
If bit 6 is clear (Z), the file may not be written: jump to 13C6H (RWRIT3) to return error 37.
1336
PUSH AF F5
Save Register Pair AF (Register A, the byte to write) on the stack.
1337
BIT 5,(IX+01H) DD CB 01 6E
Test bit 5 of FCB+1 (Index Register IX+01H), set when the buffer does not hold the current sector.
133B
If bit 5 is set, call WRCH2 at 136CH to read the sector to write into (NZ on an error).
133E
If the buffer is ready (Z), jump to 1343H (WRCH1) to put the byte in it.
1340
EX (SP),HL E3
Exchange Register Pair HL with the saved Register Pair AF on the stack (Stack Pointer), keeping the error code of the read in Register A.
1341
POP HL E1
Restore Register Pair HL from the stack, dropping the saved byte.
1342
RET C9
Return with the read error, NZ and the error code in Register A.
1343WRCH1
Call BFRPOS at 1413H: Register Pair DE = the buffer address plus the offset of the next byte.
1346
POP AF F1
Restore Register Pair AF from the stack: Register A is the byte to write.
1347
LD (DE),A 12
Store Register A into the buffer at Register Pair DE.
1348
SET 4,(IX+01H) DD CB 01 E6
Set bit 4 of FCB+1 (Index Register IX+01H): the buffer holds changed data and must be written back.
134C
INC (IX+05H) DD 34 05
Increment FCB+5 (Index Register IX+05H), the offset of the next byte.
134F
PUSH AF F5
Save Register Pair AF on the stack: the Z flag says the offset wrapped to 00H and the sector is full.
1350
If the offset wrapped (Z), call SET5 at 132AH to mark the buffer as not current.
1353
Call CKEOF1 at 1592H to compare the new position with the end of file (Register C = the offset).
1356
If the position is at or past the end of file (NZ), jump to 135EH (ATEOFW) to move the end of file to it.
1358
BIT 6,(IX+01H) DD CB 01 76
Test bit 6 of FCB+1 (Index Register IX+01H): when set, the end of file moves only when the file grows.
135C
If bit 6 is set, jump to 1367H (DNTSET) and leave the end of file where it is.
135EATEOFW
LD (IX+08H),C DD 71 08
Store Register C (the offset of the next byte) into FCB+8 (Index Register IX+08H), the end of file offset.
1361
LD (IX+0CH),L DD 75 0C
Store Register L (the low byte of the NRN, left by CKEOF1) into FCB+12 (Index Register IX+0CH), the ERN low byte.
1364
LD (IX+0DH),H DD 74 0D
Store Register H (the high byte of the NRN) into FCB+13 (Index Register IX+0DH), the ERN high byte.
1367DNTSET
POP AF F1
Restore Register Pair AF from the stack: Z when the sector was filled by this byte.
1368
If the sector is full (Z), jump to 13B0H (RWRIT1) to write it to the disk.
136AIORETZ
XOR A AF
Clear Register A to 00H and set the Z flag: no error.
136B
RET C9
Return to the caller with Register A = 00H and the Z flag set.
136CWRCH2
LD A,(IX+01H) DD 7E 01
Load Register A with FCB+1 (Index Register IX+01H), for its access level.
136F
AND 07H E6 07
Mask Register A with 07H, keeping bits 2-0, the access level (0 FULL to 7 NO ACCESS).
1371
CP 04H FE 04
Compare Register A with 04H, the UPDATE level.
1373
If the level is not UPDATE, jump to 1379H (NSEC1): the file may be extended, so the end of file is not checked.
1375NXTSECT
Call CKEOF1 at 1592H: Z if the position is before the end of file.
1378
RET NZ C0
Return NZ (Register A = 1CH or 1DH) at the end of file: in UPDATE mode a file cannot be extended, and @READ gets its end of file error here.
1379NSEC1
LD A,(IX+01H) DD 7E 01
Load Register A with FCB+1 (Index Register IX+01H), for its access level.
137C
AND 07H E6 07
Mask Register A with 07H, keeping bits 2-0, the access level of the file.
137E
CP 06H FE 06
Compare Register A with 06H, the EXECUTE level.
1380
If the level is EXECUTE or NO ACCESS (No Carry), the file may not be read: jump to 13C6H (RWRIT3) for error 37.
1382NSEC2
Call IOREC at 15CBH to work out the cylinder (Register D) and sector (Register E) of the record NRN, with the drive in Register C.
1385
RET NZ C0
Return if IOREC failed, NZ with the error code in Register A.
1386
RES 5,(IX+01H) DD CB 01 AE
Reset bit 5 of FCB+1 (Index Register IX+01H): the buffer will hold the current sector.
138A
LD L,(IX+03H) DD 6E 03
Load Register L with FCB+3 (Index Register IX+03H), the low byte of the buffer address.
138D
LD H,(IX+04H) DD 66 04
Load Register H with FCB+4 (Index Register IX+04H), the high byte: Register Pair HL = the buffer.
1390
Call @RDSEC at 19F4H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
1393
If the read was clean (Z), jump to 1398H (BUMPNRN).
1395
CP 06H FE 06
Compare Register A with 06H, the error of a sector with the system data mark, which the directory sectors carry: a file whose sectors are on the directory cylinder (DIR/SYS) can still be read.
1397
RET NZ C0
Return with any other read error, NZ and the code in Register A.
1398BUMPNRN
INC (IX+0AH) DD 34 0A
Increment FCB+10 (Index Register IX+0AH), the low byte of the NRN.
139B
If the low byte did not wrap to 00H, jump to 13A0H and return Z.
139D
INC (IX+0BH) DD 34 0B
Increment FCB+11 (Index Register IX+0BH), the high byte of the NRN.
13A0ZEROA@
XOR A AF
Clear Register A to 00H, which sets the Z flag: this is the no error return that the routines above fall into. LS-DOS 6.3.1 points @SEEKSC (SVC 71) here, so that the call does nothing at all, and its own update sheet says so; in this release @SEEKSC is a routine of its own at 1421H that seeks the drive to the record.
13A1
RET C9
Return to the caller with Register A = 00H and the Z flag set, which every caller above reads as no error.
13A2RWRIT@
LD A,(IX+01H) DD 7E 01
Load Register A with FCB+1 (Index Register IX+01H). RWRIT@ writes the buffer back when it holds changed data of a byte or record I/O file.
13A5
AND 90H E6 90
Mask Register A with 90H, keeping bit 7 (byte or record I/O) and bit 4 (buffer changed).
13A7
CP 90H FE 90
Compare Register A with 90H: Z when both bit 7 and bit 4 are set.
13A9
If both are set, jump to 13B0H (RWRIT1) to rewrite the sector.
13AB
Otherwise jump to 13A0H (ZEROA@) and return Z: nothing to write.
13AD@RWRIT
Call CKOPEN@ at 1568H to check the FCB at Register Pair DE and point Index Register IX to it. @RWRIT (SVC 70) writes the buffer back to the sector it came from.
13B0RWRIT1
Call GETNRN at 140CH: Register Pair HL = the NRN, one past the sector in the buffer.
13B3
LD A,H 7C
Copy Register H (the high byte of the NRN) into Register A.
13B4
OR L B5
OR Register L into Register A: Z when the NRN is 0000H.
13B5
RET Z C8
Return Z if the file is rewound (NRN 0): there is no sector before it to rewrite.
13B6
DEC HL 2B
Decrement Register Pair HL to the sector in the buffer.
13B7
LD (IX+0AH),L DD 75 0A
Store Register L into FCB+10 (Index Register IX+0AH), the NRN low byte, now pointing to the sector to rewrite.
13BA
LD (IX+0BH),H DD 74 0B
Store Register H into FCB+11 (Index Register IX+0BH), the NRN high byte.
13BDRWRIT2
LD A,(IX+01H) DD 7E 01
Load Register A with FCB+1 (Index Register IX+01H), for its access level. @WRITE of a 256 byte record enters here.
13C0
AND 07H E6 07
Mask Register A with 07H, keeping bits 2-0, the access level of the file.
13C2
CP 05H FE 05
Compare Register A with 05H, the READ level: Carry for FULL, REMOVE, RENAME, WRITE and UPDATE.
13C4
If the level is below READ (Carry: FULL to UPDATE), jump to 13CAH (RWRIT4): the file may be written.
13C6RWRIT3
LD A,25H 3E 25
Load Register A with 25H, error 37, Illegal access attempted to protected file.
13C8
OR A B7
OR Register A with itself to set the NZ flag for the error.
13C9
RET C9
Return with the error code in Register A and NZ.
13CARWRIT4
AND 04H E6 04
Mask Register A (the access level) with 04H: bit 2 is set only for the UPDATE level here.
13CC
If the level is FULL, REMOVE, RENAME or WRITE (Z), jump to 13D3H (RWRIT5): the file may grow.
13CE
Call CKEOF1 at 1592H: in UPDATE mode the record must lie before the end of file.
13D1
If the record is at or past the end of file (NZ), jump to 13C6H (RWRIT3) for error 37: UPDATE access cannot extend a file.
13D3RWRIT5
Call IOREC at 15CBH to work out the cylinder (Register D) and sector (Register E) of the record NRN, allocating space if the file must grow; Register C = the drive.
13D6
RET NZ C0
Return if IOREC failed (NZ, for example 1BH, disk space full).
13D7
LD L,(IX+03H) DD 6E 03
Load Register L with FCB+3 (Index Register IX+03H), the low byte of the buffer address.
13DA
LD H,(IX+04H) DD 66 04
Load Register H with FCB+4 (Index Register IX+04H): Register Pair HL = the buffer.
13DD
RES 4,(IX+01H) DD CB 01 A6
Reset bit 4 of FCB+1 (Index Register IX+01H): the buffer will match the disk once written.
13E1
SET 2,(IX+00H) DD CB 00 D6
Set bit 2 of FCB+0 (Index Register IX+00H): the file was written, so the directory's modified flag is set when it is closed.
13E5
Call @WRSEC at 19E8H to write the buffer at Register Pair HL to cylinder Register D, sector Register E of drive Register C.
13E8
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
13E9VEROP
LD A,00H 3E 00
Load Register A with the verify flag: the operand byte at 13EAH is stored by @WRITE (00H) or @VER (01H) at 1534H.
13EB
OR A B7
OR Register A with itself: NZ when the sector is to be verified.
13EC
If verify is on (NZ), call @VRSEC at 19DCH to read the sector back and check it.
13EF
RET NZ C0
Return if the verify failed, NZ with the error code in Register A.
13F0
Call BUMPNRN at 1398H to step the NRN past the sector just written.
13F3
Call CKEOF1 at 1592H: Register A = 00H before the end of file, 1CH at it, 1DH past it; Register Pair HL = the NRN.
13F6
DEC A 3D
Decrement Register A: FFH (bit 6 set) when the record is before the end of file, 1BH or 1CH (bit 6 clear) otherwise.
13F7
AND (IX+01H) DD A6 01
AND FCB+1 (Index Register IX+01H) into Register A, whose bit 6 says the end of file moves only when the file grows.
13FA
AND 40H E6 40
Mask Register A with 40H: NZ when the record is inside the file and bit 6 of FCB+1 is set.
13FC
In that case jump to 13A0H (ZEROA@) and return Z, leaving the end of file alone.
13FEYESEOF
LD (IX+0CH),L DD 75 0C
Store Register L (the NRN low byte) into FCB+12 (Index Register IX+0CH): the ERN follows the last sector written.
1401
LD (IX+0DH),H DD 74 0D
Store Register H (the NRN high byte) into FCB+13 (Index Register IX+0DH), the ERN high byte.
1404
BIT 3,(IX+01H) DD CB 01 5E
Test bit 3 of FCB+1 (Index Register IX+01H), set when the filespec ended with an exclamation mark: update the directory on every write.
1408
If bit 3 is set, jump to WEOF1 at 14F2H to write the end of file into the directory now. This release spends three bytes on a JP where LS-DOS 6.3.1 spends two on a JR, which is the one byte that puts GETNRN and BFRPOS below at 140CH and 1413H against its 140BH and 1412H.
140B
RET C9
Return to the caller with the Z flag from the BIT test at 1404H: the sector is written and the directory is left alone.
140CGETNRN
LD L,(IX+0AH) DD 6E 0A
Load Register L with FCB+10 (Index Register IX+0AH), the low byte of the next record number.
140F
LD H,(IX+0BH) DD 66 0B
Load Register H with FCB+11 (Index Register IX+0BH), the high byte, so that Register Pair HL is the next record number.
1412
RET C9
Return to the caller with the next record number in Register Pair HL.
1413BFRPOS
LD A,(IX+05H) DD 7E 05
Load Register A with FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer.
1416
ADD A,(IX+03H) DD 86 03
Add FCB+3 (Index Register IX+03H), the low byte of the buffer address, to Register A.
1419
LD E,A 5F
Copy Register A, the low byte of the byte's own address, into Register E.
141A
LD A,(IX+04H) DD 7E 04
Load Register A with FCB+4 (Index Register IX+04H), the high byte of the buffer address.
141D
ADC A,00H CE 00
Add 00H to Register A with the Carry flag of the addition at 1416H, which gives the high byte of the byte's own address.
141F
LD D,A 57
Copy Register A into Register D, so that Register Pair DE is the buffer address plus the offset.
1420
RET C9
Return to the caller with Register Pair DE pointing at the next byte in the buffer.

1421H - The Record Services: @SEEKSC to @VER

The fifteen record services, calls 61 to 75, are all in 1421H-1565H, and every one of them is at a different address in LS-DOS 6.3.1, which re-laid the whole of 1300H-15FFH: 255 of these 346 bytes differ between the two releases, where the band above and the band below are all but identical. The services share three routines of the band above: CKOPEN@ at 1568H, which finds the file control block and checks that it is open, RWRIT@ at 13A2H, which writes the buffer back if it has been changed, and CKEOF1 at 1592H, which compares the next record number with the end of file. Index Register IX points at the control block throughout.

1421@SEEKSC
Call CKOPEN@ at 1568H: point Index Register IX at the file control block Register Pair DE names and return NZ if the file is not open.
1424
Call CKEOF1 at 1592H: Register A = 00H before the end of file, and Register Pair HL = the next record number.
1427
If the record is not past the end of file, call IOREC at 15CBH, which turns the record number into a cylinder in Register D and a sector in Register E.
142A
RET NZ C0
Return NZ with the error in Register A if the record is past the end of file or the extents could not be read.
142B
Call @SEEK at 19D0H, which seeks the drive to cylinder Register D without reading anything.
142E
XOR A AF
Clear Register A to 00H: a seek error is not reported, because the read or write that follows will meet it again.
142F
RET C9
Return Z to the caller with the head over the cylinder the record is on. LS-DOS 6.3.1 has no routine here at all: it points call 71 at an OR A and a RET so that the call does nothing, which its own update sheet records.
1430@SKIP
Call @LOC at 14B3H, which returns the number of the record the file is positioned at in Register Pair BC.
1433
INC BC 03
Increment Register Pair BC past that record and fall into @POSN, which positions the file at it.
1434@POSN
Call CKOPEN@ at 1568H: Index Register IX = the control block of the file Register Pair DE names, and Register Pair BC the record to position at.
1437
SET 6,(IX+01H) DD CB 01 F6
Set bit 6 of FCB+1 (Index Register IX+01H): from here on the end of file moves only when the file grows past it, not when a record inside it is written.
143B
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of FCB+1 (Index Register IX+01H), which is set when the file is being read and written a byte at a time rather than a record at a time.
143F
If the file is working in whole sectors, jump to POSN1 at 145EH, where Register Pair BC is already the sector number.
1441
LD H,B 60
Copy Register B into Register H, the first half of moving the record number into Register Pair HL.
1442
LD L,C 69
Copy Register C into Register L: Register Pair HL is the record wanted.
1443
OR (IX+09H) DD B6 09
OR FCB+9 (Index Register IX+09H) into Register A, the logical record length, which also leaves the length in Register A for the multiply.
1446
If the record length is zero, which means 256 and so one record to a sector, jump to POSN1 at 145EH with Register Pair BC unchanged.
1448
Call @MUL16 at 06C9H, which multiplies Register Pair HL by Register A: Register Pair HL comes back as the sector the record starts in and Register A as its offset in that sector.
144B
LD B,H 44
Copy Register H into Register B, the first half of moving the sector number into Register Pair BC.
144C
LD C,L 4D
Copy Register L into Register C: Register Pair BC is the sector the record is in.
144D
LD (IX+05H),A DD 77 05
Store Register A, the offset of the record in the sector, into FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer.
1450
BIT 5,(IX+01H) DD CB 01 6E
Test bit 5 of FCB+1 (Index Register IX+01H), set when the buffer does not hold the sector wanted.
1454
If the buffer holds some other sector, jump to POSN2 at 1461H, which writes it back and reads the right one.
1456
Call GETNRN at 140CH: Register Pair HL = the next record number, which is the sector the buffer holds.
1459
SCF 37
Set the Carry flag, so that the subtraction below takes one more off.
145A
SBC HL,BC ED 42
Subtract Register Pair BC and the Carry flag from Register Pair HL: Z only when the buffer already holds the sector before the one wanted, which is what the next record number means.
145C
In that case jump to $CKEOF at 1470H, which only has to test the end of file: the buffer is right and no disk work is needed.
145EPOSN1
LD (IX+05H),A DD 77 05
Store Register A into FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer. Register A is zero on the path from 143FH and the end of file byte on the path from 1446H.
1461POSN2
PUSH BC C5
Save Register Pair BC, the sector wanted, on the stack.
1462POSN2A
Call RWRIT@ at 13A2H, which writes the buffer back to disk if bit 4 of FCB+1 says it has been changed.
1465
POP BC C1
Restore Register Pair BC, the sector wanted, from the stack.
1466
RET NZ C0
Return NZ with the error in Register A if the buffer could not be written.
1467
LD (IX+0AH),C DD 71 0A
Store Register C into FCB+10 (Index Register IX+0AH), the low byte of the next record number.
146A
LD (IX+0BH),B DD 70 0B
Store Register B into FCB+11 (Index Register IX+0BH), the high byte: the file is now positioned at the sector in Register Pair BC.
146D
Call SET5 at 132AH, which sets bit 5 of FCB+1 to say the buffer does not hold the sector wanted, so that the next read fetches it.
1470$CKEOF
Jump to CKEOF1 at 1592H, which compares the new next record number with the end of file and returns its answer to @POSN's caller: Register A = 00H inside the file, 1CH at the end and 1DH past it.
1473@RREAD
Call CKOPEN@ at 1568H: Index Register IX = the control block of the file Register Pair DE names.
1476
LD C,01H 0E 01
Load Register C with 01H, which is what makes ADJ2 below step the record forward before it steps back: a reread is a backspace and a read of the same record.
1478BKSP1
Call GETNRN at 140CH: Register Pair HL = the next record number.
147B
LD A,H 7C
Load Register A with Register H, the high byte of the record number.
147C
OR L B5
OR Register L into Register A: Z only when the record number is 0000H, which means the file is rewound.
147D
If the file is rewound, jump to BKSP0 at 1494H, which sets the byte offset to zero and does nothing else: there is nothing to back up over.
147F
DEC HL 2B
Decrement Register Pair HL, backing the record number up by one.
1480
Call ADJ2 at 15BAH, which returns at once for a file working in whole sectors, and otherwise steps the record forward when Register C is not zero and back when bit 5 of FCB+1 is clear.
1483
PUSH HL E5
Save Register Pair HL, the record number to position at, on the stack: POSN2A below pops it into Register Pair BC.
1484
Jump to POSN2A at 1462H, which writes the buffer back, stores the record number and marks the buffer stale.
1486@BKSP
Call CKOPEN@ at 1568H, which also leaves Register A at 00H when the file is open.
1489
LD C,A 4F
Copy Register A, which is zero, into Register C, so that ADJ2 does not step the record forward: a backspace is not a reread.
148A
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the logical record length.
148D
OR B B0
OR Register B into Register A to test it: Z when the length is zero, which means 256 and so one record to a sector.
148E
If the length is 256, jump to BKSP1 at 1478H and back the whole sector up.
1490
LD A,(IX+05H) DD 7E 05
Load Register A with FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer.
1493
SUB B 90
Subtract Register B, one record length, from Register A: the Carry flag is set when the offset has gone back past the start of the sector.
1494BKSP0
LD (IX+05H),A DD 77 05
Store Register A into FCB+5 (Index Register IX+05H), the new offset of the next byte in the buffer.
1497
If the subtraction carried, so the record before this one is in the sector before this one, jump to BKSP1 at 1478H to back the sector up as well.
1499
XOR A AF
Clear Register A to 00H, the no error return: the backspace was inside the buffer and no disk work was needed.
149A
RET C9
Return Z to the caller with Register A at 00H, the file backed up by one record.
149B@REW
Call CKOPEN@ at 1568H, which leaves Register A at 00H when the file is open.
149E
LD B,A 47
Copy Register A, which is zero, into Register B, the high byte of the record number to position at.
149F
LD C,A 4F
Copy Register A into Register C, so that Register Pair BC is 0000H, the first record of the file.
14A0
Jump to POSN1 at 145EH, which positions the file at record 0000H with a byte offset of zero.
14A2@PEOF
Call CKOPEN@ at 1568H, which leaves Register A at 00H when the file is open.
14A5
LD C,(IX+0CH) DD 4E 0C
Load Register C with FCB+12 (Index Register IX+0CH), the low byte of the ending record number.
14A8
LD B,(IX+0DH) DD 46 0D
Load Register B with FCB+13 (Index Register IX+0DH), the high byte: Register Pair BC is the sector the end of file is in.
14AB
OR (IX+08H) DD B6 08
OR FCB+8 (Index Register IX+08H) into Register A, the offset of the end of file in that sector.
14AE
If the offset is zero, so the end of file falls on a sector boundary, jump to POSN1 at 145EH and position at the ending record itself.
14B0
DEC BC 0B
Decrement Register Pair BC, which points at the sector before it: the end of file is inside that sector, not at the start of this one.
14B1
Jump to POSN1 at 145EH with Register A as the offset, which positions the file at the last byte of the file.
14B3@LOC
Call CKOPEN@ at 1568H: Index Register IX = the control block of the file Register Pair DE names.
14B6
Call GETNRN at 140CH: Register Pair HL = the next record number.
14B9
Call ADJUST at 15B7H, which returns the byte offset in Register C and steps the record number back when the buffer does not hold the sector.
14BCLOC1
LD E,(IX+09H) DD 5E 09
Load Register E with FCB+9 (Index Register IX+09H), the logical record length, which is the divisor below.
14BF
LD A,E 7B
Copy Register E, the record length, into Register A, both to test it and to be the divisor of the division below.
14C0
OR A B7
OR Register A with itself: Z when the record length is zero, which means 256 and so one record to a sector.
14C1
If the length is 256, jump to LOC3 at 14D9H: the sector number is already the record number and no division is needed.
14C3
INC C 0C
Increment Register C, the byte offset in the sector.
14C4
DEC C 0D
Decrement Register C again, which leaves it as it was and sets the Z flag when it is zero.
14C5
If the offset is zero, so the position is at the very start of a sector, jump to LOC2 at 14C8H without stepping the sector number back.
14C7
DEC HL 2B
Decrement Register Pair HL, the sector number, so that the division works on the bytes before the position and not past it.
14C8LOC2
Call @DIV16 at 06E3H, which divides Register Pair HL by Register A: the quotient comes back in Register Pair HL with the overflow in Register H and the remainder in Register A.
14CB
LD B,L 45
Copy Register L into Register B, keeping the high half of the first quotient.
14CC
LD D,H 54
Copy Register H into Register D, keeping the overflow of the first division for the return.
14CD
LD H,A 67
Copy Register A, the remainder, into Register H, the high byte of the second dividend.
14CE
LD L,C 69
Copy Register C, the byte offset in the sector, into Register L, the low byte of the second dividend: the remaining bytes of the part record.
14CF
LD A,E 7B
Copy Register E into Register A, the record length again, as the divisor of the second division.
14D0
Call @DIV16 at 06E3H for the second division, which turns those bytes into the records inside the sector.
14D3
LD H,B 60
Copy Register B into Register H, bringing the high half of the first quotient back: Register Pair HL is now the record number.
14D4
OR A B7
OR Register A with itself, the remainder of the second division: NZ when the position is part way through a record.
14D5
If there is no remainder, jump past the increment to 14D8H: the position is exactly on a record boundary.
14D7
INC HL 23
Increment Register Pair HL, rounding a part record up to the record it is in.
14D8
LD A,D 7A
Copy Register D into Register A, the overflow of the first division, which @LOC returns as the third byte of a record number above FFFFH.
14D9LOC3
POP BC C1
Restore Register Pair BC from the stack, which is the return address CKOPEN@ pushed to RESTREG.
14DA
EX (SP),HL E3
Exchange Register Pair HL, the record number, with the word the Stack Pointer points at, which is the caller's own Register Pair BC.
14DB
PUSH BC C5
Save Register Pair BC, the RESTREG return address, back on the stack: the record number now sits where RESTREG will pop the caller's Register Pair BC from.
14DCORARET@
OR A B7
OR Register A with itself. This is the two byte routine EXTDBG$ at 19A4H points at, the hook an extended debugger replaces.
14DD
RET C9
Return through RESTREG, which pops the record number into Register Pair BC for the caller.
14DE@LOF
Call CKOPEN@ at 1568H, which leaves Register A at 00H when the file is open.
14E1
LD L,(IX+0CH) DD 6E 0C
Load Register L with FCB+12 (Index Register IX+0CH), the low byte of the ending record number.
14E4
LD H,(IX+0DH) DD 66 0D
Load Register H with FCB+13 (Index Register IX+0DH), the high byte: Register Pair HL is the sector the end of file is in.
14E7
LD C,(IX+08H) DD 4E 08
Load Register C with FCB+8 (Index Register IX+08H), the offset of the end of file in that sector.
14EA
Jump to LOC1 at 14BCH, which turns that sector and offset into the number of the last record of the file by the same two divisions @LOC uses.
14EC@WEOF
Call CKOPEN@ at 1568H: Index Register IX = the control block of the file Register Pair DE names.
14EF
Call RWRIT@ at 13A2H, which writes the buffer back to disk if bit 4 of FCB+1 says it has been changed.
14F2WEOF1
LD B,(IX+07H) DD 46 07
Load Register B with FCB+7 (Index Register IX+07H), the directory entry code of the file's primary entry.
14F5
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
14F8
Call @DIRRD at 18BBH, which reads the directory sector the entry is in: Register Pair HL points at the entry in SBUFF$.
14FB
RET NZ C0
Return NZ with the error in Register A if the directory sector could not be read.
14FC
INC L 2C
Increment Register L, the first of three steps along the directory entry.
14FD
INC L 2C
Increment Register L, the second of the three steps along the directory entry.
14FE
INC L 2C
Increment Register L, the third, so that Register Pair HL points at byte 3 of the entry, the end of file offset.
14FF
LD A,(IX+08H) DD 7E 08
Load Register A with FCB+8 (Index Register IX+08H), the end of file offset the control block holds.
1502
LD (HL),A 77
Store Register A into the entry at Register Pair HL: the offset in the directory now matches the control block.
1503
LD DE,0011H 11 11 00
Load Register Pair DE with 0011H (17), the distance from byte 3 of the entry to byte 20, the ending record number.
1506
ADD HL,DE 19
Add Register Pair DE to Register Pair HL, which points at byte 20 of the entry.
1507
LD A,(IX+0CH) DD 7E 0C
Load Register A with FCB+12 (Index Register IX+0CH), the low byte of the ending record number.
150A
LD (HL),A 77
Store Register A into the entry at Register Pair HL.
150B
INC HL 23
Increment Register Pair HL to byte 21 of the entry.
150C
LD A,(IX+0DH) DD 7E 0D
Load Register A with FCB+13 (Index Register IX+0DH), the high byte of the ending record number.
150F
LD (HL),A 77
Store Register A into the entry at Register Pair HL: the directory now holds the length of the file.
1510
Jump to @DIRWR at 1803H, which writes the directory sector back and returns its answer to @WEOF's caller.
1513@READ
Call CKOPEN@ at 1568H: Index Register IX = the control block, Register Pair HL the caller's buffer.
1516
PUSH HL E5
Save Register Pair HL, the caller's buffer, on the stack.
1517
Call RWRIT@ at 13A2H, which writes this file's own buffer back if it has been changed.
151A
POP HL E1
Restore Register Pair HL, the caller's buffer, from the stack.
151B
RET NZ C0
Return NZ with the error in Register A if the buffer could not be written.
151C
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the logical record length and so the count of bytes to move.
151F
LD A,B 78
Copy Register B, the record length, into Register A so that it can be tested.
1520
OR A B7
OR Register A with itself: Z when the record length is zero, which means 256 and so a whole sector to a record.
1521
If a record is a whole sector, jump to NXTSECT at 1375H, which reads the sector straight into the control block's own buffer and moves nothing.
1524RDREC
PUSH HL E5
Save Register Pair HL, where the next byte goes, on the stack.
1525
PUSH BC C5
Save Register Pair BC, the count of bytes left, on the stack.
1526
Call RDCHAR at 1312H, which returns the next byte of the file in Register A and reads a new sector when the buffer runs out.
1529
POP BC C1
Restore Register Pair BC, the count, from the stack.
152A
POP HL E1
Restore Register Pair HL, the place for the byte, from the stack.
152B
RET NZ C0
Return NZ with the error in Register A if the byte could not be read.
152C
LD (HL),A 77
Store Register A, the byte, into the caller's buffer at Register Pair HL.
152D
INC HL 23
Increment Register Pair HL to the next place in the caller's buffer.
152E
Count Register B down and loop back to RDREC at 1524H until the whole record has been moved.
1530
RET C9
Return Z with the record in the caller's buffer.
1531@WRITE
Call CKOPEN@ at 1568H, which also leaves Register A at 00H when the file is open.
1534WRIT1
LD (13EAH),A 32 EA 13
Store Register A into 13EAH, the operand of the instruction at VEROP: 00H from @WRITE above leaves the write unverified and the 01H @VER sets at 1563H makes the sector be read back and compared.
1537
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the logical record length and so the count of bytes to move.
153A
LD A,B 78
Copy Register B, the record length, into Register A so that it can be tested.
153B
OR A B7
OR Register A with itself: Z when the record length is zero, which means 256 and so a whole sector to a record.
153C
If a record is a whole sector, jump to RWRIT2 at 13BDH, which writes the control block's own buffer and moves nothing.
153F
PUSH HL E5
Save Register Pair HL, the caller's buffer, on the stack.
1540
LD H,(IX+05H) DD 66 05
Load Register H with FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer, to be kept in case the write fails.
1543
LD L,(IX+08H) DD 6E 08
Load Register L with FCB+8 (Index Register IX+08H), the end of file offset, kept with it.
1546
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer points at, which puts those two control block bytes on the stack and brings the caller's buffer back into Register Pair HL.
1547WRREC
LD A,(HL) 7E
Load Register A with the byte of the record at Register Pair HL in the caller's buffer.
1548
INC HL 23
Increment Register Pair HL to the next byte of the caller's buffer.
1549
PUSH HL E5
Save Register Pair HL, where the next byte comes from, on the stack.
154A
PUSH BC C5
Save Register Pair BC, the count of bytes left, on the stack.
154B
Call WRCHAR at 132FH, which puts Register A into the file and writes a sector out when the buffer fills.
154E
POP BC C1
Restore Register Pair BC, the count, from the stack.
154F
POP HL E1
Restore Register Pair HL, the place of the next byte, from the stack.
1550
If the byte could not be written, jump to WRERROR at 1557H, which puts the two control block bytes back before it returns the error.
1552
Count Register B down and loop back to WRREC at 1547H until the whole record has been written.
1554
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer points at, which takes the two kept control block bytes off the stack and leaves the caller's buffer pointer in its place.
1555
POP HL E1
Restore Register Pair HL, the caller's buffer, from the stack.
1556
RET C9
Return Z to the caller with the whole record written and Register Pair HL past the end of it in the caller's buffer.
1557WRERROR
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer points at: Register Pair HL becomes the two control block bytes kept at 1546H and the stack takes the buffer pointer.
1558
LD (IX+05H),H DD 74 05
Store Register H into FCB+5 (Index Register IX+05H), putting the offset of the next byte back as it was before the record was begun.
155B
LD (IX+08H),L DD 75 08
Store Register L into FCB+8 (Index Register IX+08H), putting the end of file offset back with it, so that a failed write leaves the file where it was.
155E
POP HL E1
Restore Register Pair HL, the caller's buffer, from the stack.
155F
RET C9
Return with the error still in Register A and NZ.
1560@VER
Call CKOPEN@ at 1568H, which leaves Register A at 00H when the file is open.
1563
INC A 3C
Increment Register A to 01H, the value that turns the verify on.
1564
Jump to WRIT1 at 1534H, which stores the 01H into VEROP's operand and then writes the record exactly as @WRITE does, reading each sector back to compare it.

1566H - LNKFCB@ and CKOPEN@: Check an FCB and Save the Registers

Every file SVC calls CKOPEN@ first. It saves the FCB address in JDCB$ (0024H) and its own return address in JRET$ (0026H). For an FCB that is not open it drops the routine's return address and returns error 38 to the SVC's caller. For an open one it points Index Register IX to the FCB, saves Register Pairs HL, DE, BC and the caller's Index Register IX, and plants RESTREG (1589H) as the return address of the file routine, so that a plain RET restores them all. LNKFCB@ enters with the Carry flag set, which skips the open test.

1566LNKFCB@
SCF 37
Set the Carry flag: the FCB is treated as open, whatever its bit 7 says.
1567
DEFB 0D2H D2
1567H: the byte D2H, with the next two bytes the instruction JP NC,071AH. Entered from LNKFCB@ with Carry set, the jump is never taken and the processor goes on at 156AH, skipping the open test; CKOPEN@ itself starts at 1568H, where 1AH 07H are LD A,(DE) and RLCA.
1568CKOPEN@
LD A,(DE) 1A
Load Register A with FCB+0 at Register Pair DE, the type byte; bit 7 is set for an open file.
1569
RLCA 07
Rotate Register A left: bit 7 (the open bit) goes into the Carry flag.
156A
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL = the return address into the file routine.
156B
LD (0026H),HL 22 26 00LD (JRET$),HL
Store Register Pair HL (the return address) into 0026H (JRET$).
156E
LD (0024H),DE ED 53 24 00LD (JDCB$),DE
Store Register Pair DE (the FCB address) into 0024H (JDCB$).
1572
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack again (Stack Pointer): the return address is back and Register Pair HL is the caller's.
1573
If the FCB is not open (No Carry), jump to 1584H (NOTOPEN).
1575
POP AF F1
Restore Register Pair AF from the stack: Register Pair AF holds the return address into the file routine.
1576
PUSH DE D5
Save Register Pair DE (the FCB address) on the stack.
1577
EX (SP),IX DD E3
Exchange Index Register IX with the top of the stack (Stack Pointer): Index Register IX points to the FCB and the caller's Index Register IX is saved.
1579
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
157A
PUSH DE D5
Save Register Pair DE (the FCB address) on the stack.
157B
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack.
157C
PUSH HL E5
Save Register Pair HL on the stack once more, to make room for the RESTREG address.
157D
LD HL,1589H 21 89 15LD HL,RESTREG
Load Register Pair HL with 1589H (RESTREG), the routine that pops the saved registers.
1580
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): 1589H is now the return address of the file routine and Register Pair HL is restored.
1581
PUSH AF F5
Save Register Pair AF (the return address into the file routine) on the stack.
1582
XOR A AF
Clear Register A to 00H and set the Z flag; several routines use the 00H.
1583
RET C9
Return into the file routine with Index Register IX = the FCB.
1584NOTOPEN
POP AF F1
Restore Register Pair AF from the stack, dropping the return address into the file routine.
1585
LD A,26H 3E 26
Load Register A with 26H, error 38, File not open.
1587
OR A B7
OR Register A with itself to set the NZ flag.
1588
RET C9
Return straight to the caller of the SVC with the error code in Register A and NZ.
1589RESTREG
POP BC C1
Restore Register Pair BC (saved by CKOPEN@, or the record number put there by LOC3) from the stack.
158A
POP DE D1
Restore Register Pair DE (the FCB address) from the stack.
158B
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
158C
POP IX DD E1
Restore Index Register IX (the caller's value) from the stack.
158E
RET C9
Return to the caller of the SVC with the flags and Register A the file routine left.

158FH - @CKEOF and CKEOF1: Test for the End of File

CKEOF1 compares the current position with the end of file: the sector of the position (the NRN, adjusted by ADJUST for byte I/O) against the ERN, and in the same sector the offset against the end of file offset. It returns Z and Register A = 00H before the end of file, NZ and Register A = 1CH (error 28, End of file encountered) at it, and NZ and 1DH (error 29, Record number out of range) past it, with Register Pair HL = the NRN as it was and Register C = the offset. @CKEOF (SVC 62) is the same for a program.

158F@CKEOF
Call CKOPEN@ at 1568H to check the FCB at Register Pair DE, point Index Register IX to it and save the registers.
1592CKEOF1
Call GETNRN at 140CH: Register Pair HL = the NRN.
1595
PUSH HL E5
Save Register Pair HL (the NRN as it is) on the stack, to return it.
1596
Call 15B7H (ADJUST): Register C = the offset and Register Pair HL the sector of the position.
1599
LD A,H 7C
Copy Register H (the high byte of the sector) into Register A.
159A
CP (IX+0DH) DD BE 0D
Compare Register A with FCB+13 (Index Register IX+0DH), the high byte of the ERN.
159D
If the high bytes differ (NZ), jump to 15ADH (CKEOF2) with Carry when the position is below the end of file.
159F
LD A,L 7D
Copy Register L (the low byte of the sector) into Register A.
15A0
CP (IX+0CH) DD BE 0C
Compare Register A with FCB+12 (Index Register IX+0CH), the low byte of the ERN.
15A3
If the low bytes differ (NZ), jump to 15ADH (CKEOF2) with Carry when the position is below the end of file.
15A5
DEC C 0D
Decrement Register C (the offset), so an offset of 00H counts as 256.
15A6
LD A,(IX+08H) DD 7E 08
Load Register A with FCB+8 (Index Register IX+08H), the end of file offset.
15A9
DEC A 3D
Decrement Register A, so an end of file offset of 00H counts as 256.
15AA
SUB C 91
Subtract Register C from Register A: Z when the offset is at the end of file, Carry when it is past it.
15AB
CCF 3F
Complement the Carry flag: now Carry means before the end of file, the same sense as the compares above.
15AC
INC BC 03
Increment Register Pair BC, putting back the offset in Register C (no flags change).
15ADCKEOF2
POP HL E1
Restore Register Pair HL (the NRN as it was) from the stack.
15AE
LD A,1DH 3E 1D
Load Register A with 1DH, error 29, Record number out of range.
15B0
If the position is not exactly at the end of file (NZ), jump to 15B4H (CKEOF3).
15B2
DEC A 3D
Decrement Register A to 1CH, error 28, End of file encountered.
15B3
RET C9
Return with 1CH in Register A and NZ (the DEC left it non zero).
15B4CKEOF3
RET NC D0
Return with 1DH in Register A and NZ if the position is past the end of file (No Carry).
15B5
XOR A AF
Clear Register A to 00H and set the Z flag: the position is before the end of file.
15B6
RET C9
Return to the caller with Register A = 00H and Z.

15B7H - ADJUST: The Sector of a Byte Position

Entered at 15B7H with Register C loaded from the offset, or at 15BAH with the caller's Register C. For a file used by bytes or records (FCB+1 bit 7) it moves Register Pair HL (a sector number) forward by one when Register C is not zero and back by one when the buffer is current (FCB+1 bit 5 clear), so that Register Pair HL names the sector the position is in.

15B7
LD C,(IX+05H) DD 4E 05
Load Register C with FCB+5 (Index Register IX+05H), the offset of the next byte in the buffer.
15BA
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of FCB+1 (Index Register IX+01H), set for byte or record I/O.
15BE
RET Z C8
Return unchanged if the file is used only by whole sectors (Z).
15BF
LD A,C 79
Copy Register C (the offset, or the step flag from @RREAD) into Register A.
15C0
OR A B7
OR Register A with itself: Z when Register C is 00H.
15C1
If Register C is 00H, jump to 15C4H without stepping forward.
15C3
INC HL 23
Increment Register Pair HL, one sector forward.
15C4
BIT 5,(IX+01H) DD CB 01 6E
Test bit 5 of FCB+1 (Index Register IX+01H), set when the buffer does not hold the current sector.
15C8
RET NZ C0
Return if bit 5 is set (NZ), with Register Pair HL as it is now.
15C9
DEC HL 2B
Decrement Register Pair HL, one sector back: the buffer holds sector NRN-1.
15CA
RET C9
Return to the caller with Register Pair HL adjusted and Register C unchanged.

15CBH - IOREC: Find the Cylinder and Sector of a Record

IOREC turns the NRN into a cylinder (Register D) and sector (Register E) on the file's drive (Register C). It divides the NRN by the sectors per granule to get the file's granule number and the sector inside the granule, then looks for the extent that holds that granule among the first extent at FCB+14 and the four extent records at FCB+16 to FCB+31 (two bytes of granules counted before the extent, then the extent's cylinder and its allocation byte: starting granule in bits 7-5, granules less one in bits 4-0). A matching extent record is moved to the first position. When no extent in the FCB holds the granule, ALLOC at 1664H reads the directory and allocates space if the file must grow.

15CBIOREC
Call GETNRN at 140CH: Register Pair HL = the NRN, the record to find.
15CE
Call D@FBYT8 at 1A26H: Register C = the FCB's drive (FCB+6) and Register A = byte 8 of its drive code table entry.
15D1
AND 1FH E6 1F
Mask Register A with 1FH, keeping bits 4-0 of DCT+8, the sectors per granule less one.
15D3
INC A 3C
Increment Register A to the number of sectors per granule.
15D4
Call @DIV16 at 06E3H to divide Register Pair HL (the NRN) by Register A: Register Pair HL = the granule of the file, Register A = the sector inside it.
15D7
LD (1660H),A 32 60 16
Store Register A (the sector inside the granule) into 1660H, the operand of the ADD at CALS5.
15DA
PUSH IX DD E5
Save Index Register IX (the FCB) on the stack.
15DC
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL = the FCB and the stack holds the granule number.
15DD
LD BC,000EH 01 0E 00
Load Register Pair BC with 000EH, the offset of the first extent in the FCB.
15E0
ADD HL,BC 09
Add Register Pair BC (000EH) to Register Pair HL: Register Pair HL points to FCB+14, the first extent's cylinder.
15E1
POP BC C1
Restore Register Pair BC from the stack: Register Pair BC = the granule to find.
15E2
LD A,05H 3E 05
Load Register A with 05H, the number of extents to check (FCB+14 and the four records after it).
15E4
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the granules counted before the first extent.
15E7GREC1
PUSH AF F5
Save Register Pair AF (Register A, the extents left) on the stack.
15E8
LD A,(HL) 7E
Load Register A with the extent's starting cylinder at Register Pair HL.
15E9
INC HL 23
Increment Register Pair HL to the extent's allocation byte.
15EA
INC A 3C
Increment Register A: Z when the cylinder byte was FFH, an unused extent.
15EB
If the extent is unused, jump to 15F8H (GREC2) to the next one.
15ED
PUSH HL E5
Save Register Pair HL (the pointer to the allocation byte) on the stack.
15EE
LD H,D 62
Copy Register D (the high byte of the granules before this extent) into Register H.
15EF
LD L,E 6B
Copy Register E into Register L: Register Pair HL = the granules before this extent.
15F0
XOR A AF
Clear Register A and the Carry flag for the subtraction.
15F1
SBC HL,BC ED 42
Subtract Register Pair BC (the granule to find) from Register Pair HL: Carry when the granule lies past this extent's first granule, Z when it is the first.
15F3
If so (Carry), jump to 1603H (GREC3) to see if it lies inside this extent.
15F5
POP HL E1
Restore Register Pair HL (the pointer to the allocation byte) from the stack.
15F6
If the granule is exactly this extent's first (Z), jump to 1621H (CALCSEC) with Register A = 0, granule 0 of the extent.
15F8GREC2
INC HL 23
Increment Register Pair HL past the allocation byte, to the next extent record.
15F9
POP AF F1
Restore Register Pair AF (Register A, the extents left) from the stack.
15FA
DEC A 3D
Decrement Register A, the count of extents still to check.
15FB
If all five are checked (Z), jump to 1616H (GREC4): the granule is not in the FCB.
15FD
LD E,(HL) 5E
Load Register E with the low byte of the granules before the next extent, at Register Pair HL.
15FE
INC HL 23
Increment Register Pair HL to the high byte of the granule count of the next extent record.
15FF
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the granules before the next extent.
1600
INC HL 23
Increment Register Pair HL to the next extent's cylinder byte.
1601
Loop back to 15E7H (GREC1) to check that extent.
1603GREC3
INC H 24
Increment Register H (the high byte of the negative difference): Z when the granule is less than 256 past the extent's start.
1604
LD A,L 7D
Copy Register L (the low byte of the difference, negative) into Register A.
1605
POP HL E1
Restore Register Pair HL (the pointer to the allocation byte) from the stack.
1606
If the granule is 256 or more past the extent's start (NZ), jump to 15F8H (GREC2): an extent holds at most 32.
1608
PUSH DE D5
Save Register Pair DE (the granules before this extent) on the stack.
1609
LD E,A 5F
Copy Register A (the negative difference) into Register E.
160A
LD A,(HL) 7E
Load Register A with the extent's allocation byte at Register Pair HL.
160B
AND 1FH E6 1F
Mask Register A with 1FH, keeping the granules in the extent less one.
160D
ADD A,E 83
Add Register E (the negative difference) to Register A: Carry when the granule lies inside this extent.
160E
LD A,E 7B
Copy Register E (the negative difference) into Register A.
160F
POP DE D1
Restore Register Pair DE (the granules before this extent) from the stack.
1610
If the granule lies past the end of the extent (No Carry), jump to 15F8H (GREC2) to the next one.
1612
NEG ED 44
Negate Register A: the granule's position inside the extent, 0 to 31.
1614
Jump to 1621H (CALCSEC) to work out its cylinder and sector.
1616GREC4
Call ALLOC at 1664H to find the granule's extent in the directory, allocating space if needed: Register A = the granule inside it, Register Pair DE = the granules before it.
1619
RET NZ C0
Return if the directory could not be read or space allocated, NZ with the error code in Register A.
161A
LD (1650H),A 32 50 16
Store Register A (the granule inside the extent) into 1650H, the operand of the ADD at CALS4.
161D
If the extent is already in the FCB (No Carry), jump to 1649H (CALS3) with Register H = its allocation byte and Register L = its cylinder.
161F
Otherwise jump to 1640H (CALS1) to store the new extent (Register C cylinder, Register B allocation byte, Register Pair DE the granules before it) in the first extent record at Register Pair HL.
1621CALCSEC
LD (1650H),A 32 50 16
Store Register A (the granule inside the extent) into 1650H, the operand of the ADD at CALS4.
1624
LD B,(HL) 46
Load Register B with the extent's allocation byte at Register Pair HL.
1625
DEC HL 2B
Decrement Register Pair HL to the extent's cylinder byte.
1626
LD C,(HL) 4E
Load Register C with the extent's starting cylinder at Register Pair HL.
1627
INC HL 23
Increment Register Pair HL back to the allocation byte.
1628
POP AF F1
Restore Register Pair AF from the stack: Register A = the extents left when the match was found (5 for FCB+14, 4 for the first record, and so on).
1629
CPL 2F
Complement Register A, the extents left count, for the test below.
162A
ADD A,04H C6 04
Add 04H to Register A: No Carry for the first extent and the first extent record, Carry for records 2 to 4.
162C
If the extent is FCB+14 or already the first record (No Carry), jump to 1647H (CALS2): nothing to move.
162E
INC A 3C
Increment Register A: 1, 2 or 3 for the second, third or fourth record.
162F
RLCA 07
Rotate Register A left: 2, 4 or 6, on the way to the byte count.
1630
RLCA 07
Rotate Register A left again: 4, 8 or 12, the bytes of the records in front of the matching one.
1631
PUSH BC C5
Save Register Pair BC (the extent's allocation byte and cylinder) on the stack.
1632
PUSH DE D5
Save Register Pair DE (the granules before the extent) on the stack.
1633
LD C,A 4F
Copy Register A (the bytes to move) into Register C.
1634
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the bytes to move.
1636
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the matching record's allocation byte, the last byte to overwrite.
1637
LD HL,0FFFCH 21 FC FF
Load Register Pair HL with FFFCH, minus 4, the size of one extent record.
163A
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: Register Pair HL points to the allocation byte of the record in front.
163B
LDDR ED B8
Copy Register Pair BC bytes downward from Register Pair HL to Register Pair DE: the records in front each move up one place over the matching one.
163D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = FCB+19, the allocation byte of the first record.
163E
POP DE D1
Restore Register Pair DE (the granules before the extent) from the stack.
163F
POP BC C1
Restore Register Pair BC (the allocation byte in Register B, the cylinder in Register C) from the stack.
1640CALS1
LD (HL),B 70
Store Register B (the allocation byte) at Register Pair HL, FCB+19.
1641
DEC HL 2B
Decrement Register Pair HL to FCB+18, the first record's cylinder byte.
1642
LD (HL),C 71
Store Register C (the starting cylinder) at Register Pair HL, FCB+18.
1643
DEC HL 2B
Decrement Register Pair HL to FCB+17, the high byte of its granule count.
1644
LD (HL),D 72
Store Register D (the high byte of the granules before the extent) at Register Pair HL, FCB+17.
1645
DEC HL 2B
Decrement Register Pair HL to FCB+16, the low byte of its granule count.
1646
LD (HL),E 73
Store Register E (the low byte of the granules before the extent) at Register Pair HL, FCB+16.
1647CALS2
LD H,B 60
Copy Register B (the allocation byte) into Register H.
1648
LD L,C 69
Copy Register C (the starting cylinder) into Register L.
1649CALS3
LD A,H 7C
Copy Register H (the allocation byte) into Register A.
164A
RLCA 07
Rotate Register A left: the starting granule, bits 7-5, moves toward bit 0.
164B
RLCA 07
Rotate Register A left a second time, moving the starting granule on toward bit 0.
164C
RLCA 07
Rotate Register A left a third time: the starting granule is now in bits 2-0.
164D
AND 07H E6 07
Mask Register A with 07H, the extent's starting granule in its cylinder.
164FCALS4
ADD A,00H C6 00
Add the granule inside the extent to Register A: the operand at 1650H is stored at 161AH or 1621H. Register A = the granule counted from the extent's starting cylinder.
1651
Call RELCYL at 1919H: Register A = the cylinders past the starting one, Register E = the granule inside that cylinder, Register B = DCT+8, Register C = the drive.
1654
ADD A,L 85
Add Register L (the extent's starting cylinder) to Register A: the granule's cylinder.
1655
LD D,A 57
Copy Register A (the cylinder) into Register D.
1656
LD A,B 78
Load Register A with Register B, byte 8 of the drive code table.
1657
AND 1FH E6 1F
Mask Register A with 1FH, keeping the sectors per granule less one.
1659
INC A 3C
Increment Register A to the sectors per granule.
165A
PUSH DE D5
Save Register Pair DE (Register D, the cylinder) on the stack.
165B
Call @MUL8 at 190AH to multiply Register A (sectors per granule) by Register E (the granule in the cylinder): Register A = the granule's first sector.
165E
POP DE D1
Restore Register Pair DE (Register D, the cylinder) from the stack.
165FCALS5
ADD A,00H C6 00
Add the sector inside the granule to Register A: the operand at 1660H is stored at 15D7H.
1661
LD E,A 5F
Copy Register A (the sector) into Register E: Register D = cylinder, Register E = sector.
1662
XOR A AF
Clear Register A to 00H and set the Z flag: no error.
1663
RET C9
Return to the caller with the cylinder in Register D, the sector in Register E and the drive in Register C.

1664H - ALLOC: Find a Granule's Extent in the Directory

ALLOC is called by IOREC when none of the extents in the FCB holds the granule Register Pair BC. CYL_GRN at 16AEH finds the extent in the file's directory entries (allocating space first if the file must grow); ALLOC then works out the granule's position inside that extent and looks for the extent among the FCB's five extent fields. It returns Z with Register A = the granule inside the extent and Register Pair DE = the granules before it, and either No Carry with Register H = the allocation byte and Register L = the starting cylinder (the extent was in the FCB; its allocation byte is refreshed), or Carry with Register C = the cylinder, Register B = the allocation byte and Register Pair HL = FCB+19, after the extent records were moved up to make room for it.

1664ALLOC
Call CYL_GRN at 16AEH to find the directory extent that holds granule Register Pair BC: Register L = its cylinder, Register H = its allocation byte, Register Pair DE = the granules before it.
1667
RET NZ C0
Return if the directory could not be read or space allocated, NZ with the error code in Register A.
1668
PUSH HL E5
Save Register Pair HL (the extent's cylinder and allocation byte) on the stack.
1669
LD H,B 60
Copy Register B (the high byte of the granule wanted) into Register H.
166A
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the granule wanted.
166B
XOR A AF
Clear Register A and the Carry flag for the subtraction.
166C
SBC HL,DE ED 52
Subtract Register Pair DE (the granules before the extent) from Register Pair HL: the granule's position inside the extent.
166E
LD A,L 7D
Copy Register L (the position, below 32) into Register A.
166F
LD (16A7H),A 32 A7 16
Store Register A into 16A7H, the operand of the LD A at ALL6, returned to the caller.
1672
POP HL E1
Restore Register Pair HL (the extent's cylinder and allocation byte) from the stack.
1673
PUSH DE D5
Save Register Pair DE (the granules before the extent) on the stack.
1674
PUSH IX DD E5
Save Index Register IX (the FCB) on the stack.
1676
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL = the FCB, the stack holds the extent.
1677
LD DE,000EH 11 0E 00
Load Register Pair DE with 000EH, the offset of the first extent in the FCB.
167A
ADD HL,DE 19
Add Register Pair DE (000EH) to Register Pair HL: Register Pair HL points to FCB+14.
167B
POP DE D1
Restore Register Pair DE from the stack: Register E = the extent's starting cylinder, Register D = its allocation byte.
167C
LD B,05H 06 05
Load Register B with 05H, the number of extent fields in the FCB to check.
167EALL1
LD A,(HL) 7E
Load Register A with the cylinder of the FCB extent field at Register Pair HL.
167F
INC HL 23
Increment Register Pair HL to that field's allocation byte.
1680
CP E BB
Compare Register A with Register E, the extent's starting cylinder.
1681
If the cylinders differ (NZ), jump to 1689H (ALL2) to the next field.
1683
LD A,(HL) 7E
Load Register A with the field's allocation byte at Register Pair HL.
1684
XOR D AA
Exclusive OR Register D (the extent's allocation byte) into Register A, to compare the starting granules.
1685
AND 0E0H E6 E0
Mask Register A with E0H, keeping bits 7-5, the starting granule: zero when both start at the same granule.
1687
If the field is the same extent (Z), jump to 16A2H (ALL4).
1689ALL2
DEC B 05
Decrement Register B, the fields left to check.
168A
If all five fields are checked (Z), jump to 1691H (ALL3): the extent is not in the FCB.
168C
INC HL 23
Increment Register Pair HL past the allocation byte.
168D
INC HL 23
Increment Register Pair HL past the low byte of the next record's granule count.
168E
INC HL 23
Increment Register Pair HL past the high byte, to the next record's cylinder byte.
168F
Loop back to 167EH (ALL1) to check that field.
1691ALL3
PUSH DE D5
Save Register Pair DE (the extent's cylinder and allocation byte) on the stack.
1692
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = FCB+31, the allocation byte of the fourth record, the last byte to overwrite.
1693
LD HL,0FFFCH 21 FC FF
Load Register Pair HL with FFFCH, minus 4, the size of one extent record.
1696
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: Register Pair HL = FCB+27, the allocation byte of the third record.
1697
LD BC,000CH 01 0C 00
Load Register Pair BC with 000CH, the 12 bytes of the first three records.
169A
LDDR ED B8
Copy Register Pair BC bytes downward from Register Pair HL to Register Pair DE: records 1 to 3 move to positions 2 to 4 and record 4 is dropped.
169C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = FCB+19, the allocation byte of the first record, now free.
169D
POP BC C1
Restore Register Pair BC from the stack: Register C = the extent's cylinder, Register B = its allocation byte.
169E
XOR A AF
Clear Register A to 00H and set the Z flag: no error.
169F
SCF 37
Set the Carry flag: the extent was not in the FCB and must be stored at Register Pair HL.
16A0
Jump to 16A5H (ALL5) to restore Register Pair DE and return.
16A2ALL4
LD (HL),D 72
Store Register D (the extent's allocation byte, which may now count more granules) into the FCB field at Register Pair HL.
16A3
EX DE,HL EB
Exchange Register Pairs DE and HL: Register H = the allocation byte, Register L = the starting cylinder.
16A4
XOR A AF
Clear Register A to 00H, setting the Z flag and clearing the Carry flag: the extent is in the FCB.
16A5ALL5
POP DE D1
Restore Register Pair DE (the granules before the extent) from the stack.
16A6ALL6
LD A,00H 3E 00
Load Register A with the granule's position inside the extent, the operand at 16A7H stored at 166FH.
16A8
RET C9
Return to IOREC with Register A, Register Pair DE and the Carry flag as described above.
16A9CG06
Call CG07 at 16F2H to allocate granules up to the one wanted, extending the last extent or starting a new one.
16AC
POP BC C1
Restore Register Pair BC (the granule wanted) from the stack.
16AD
RET NZ C0
Return if the allocation failed, NZ with the error code in Register A; otherwise fall into CYL_GRN and look for the granule again.

16AEH - CYL_GRN: Find the Directory Extent of a Granule

CYL_GRN reads the file's directory entries, starting with the primary entry (FCB+7) and following the links to its extended entries, and counts the granules extent by extent until it reaches the extent that holds granule Register Pair BC. Each directory entry has five extent fields at +16H to +1FH: a cylinder and an allocation byte (starting granule in bits 7-5, granules less one in bits 4-0); FFH marks an unused field and FEH a link, whose second byte is the directory entry code of the next entry. If the granule lies past the last extent, CG07 allocates space and the search starts again. It returns Z with Register L = the cylinder, Register H = the allocation byte and Register Pair DE = the granules before the extent.

16AECYL_GRN
PUSH BC C5
Save Register Pair BC (the granule wanted) on the stack.
16AF
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the granules counted so far.
16B2
LD B,(IX+07H) DD 46 07
Load Register B with FCB+7 (Index Register IX+07H), the directory entry code (DEC) of the file's primary entry.
16B5CG01
LD A,B 78
Copy Register B (the DEC of the entry to read) into Register A.
16B6
LD (17ACH),A 32 AC 17
Store Register A into 17ACH, the operand of the LD B at STUFDEC: the entry last read, written back by CG23.
16B9
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
16BC
Call @DIRRD at 18BBH to read the directory sector of entry Register B: Register Pair HL points to the entry in SBUFF$.
16BF
LD BC,0016H 01 16 00
Load Register Pair BC with 0016H, the offset of the first extent field in a directory entry.
16C2
ADD HL,BC 09
Add Register Pair BC (0016H) to Register Pair HL: Register Pair HL points to the entry's first extent field.
16C3
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the extent field, Register Pair HL = the granules counted so far.
16C4
POP BC C1
Restore Register Pair BC (the granule wanted) from the stack.
16C5
RET NZ C0
Return if the directory read failed, NZ with the error code in Register A.
16C6CG02
LD A,(DE) 1A
Load Register A with the extent field's cylinder byte at Register Pair DE.
16C7
CP 0FEH FE FE
Compare Register A with FEH, the link marker.
16C9
If the byte is FEH (a link) or FFH (unused), jump to 16EAH (CG05).
16CB
INC DE 13
Increment Register Pair DE to the extent's allocation byte.
16CC
LD A,(DE) 1A
Load Register A with the allocation byte at Register Pair DE.
16CD
PUSH HL E5
Save Register Pair HL (the granules before this extent) on the stack.
16CE
AND 1FH E6 1F
Mask Register A with 1FH, keeping the granules in the extent less one.
16D0
INC A 3C
Increment Register A to the number of granules in the extent.
16D1
ADD A,L 85
Add Register L (the low byte of the count) to Register A.
16D2
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the granules up to the end of this extent.
16D3
If the addition did not carry, jump to 16D6H (CG03).
16D5
INC H 24
Increment Register H, the high byte of the count.
16D6CG03
PUSH HL E5
Save Register Pair HL (the granules up to the end of this extent) on the stack.
16D7
DEC HL 2B
Decrement Register Pair HL to the number of the extent's last granule.
16D8
XOR A AF
Clear Register A and the Carry flag for the subtraction.
16D9
SBC HL,BC ED 42
Subtract Register Pair BC (the granule wanted) from Register Pair HL: No Carry when the granule is in this extent.
16DB
POP HL E1
Restore Register Pair HL (the granules up to the end of this extent) from the stack.
16DC
If the granule is in this extent (No Carry), jump to 16E2H (CG04).
16DE
INC DE 13
Increment Register Pair DE to the next extent field.
16DF
POP AF F1
Restore Register Pair AF from the stack, dropping the count before this extent.
16E0
Loop back to 16C6H (CG02) with Register Pair HL = the granules before the next extent.
16E2CG04
POP HL E1
Restore Register Pair HL (the granules before this extent) from the stack.
16E3
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the granules before the extent, Register Pair HL = its allocation byte.
16E4
LD A,(HL) 7E
Load Register A with the allocation byte at Register Pair HL.
16E5
DEC HL 2B
Decrement Register Pair HL to the extent's cylinder byte.
16E6
LD L,(HL) 6E
Load Register L with the extent's starting cylinder at Register Pair HL.
16E7
LD H,A 67
Copy Register A (the allocation byte) into Register H.
16E8
XOR A AF
Clear Register A to 00H and set the Z flag: found.
16E9
RET C9
Return with Register L = the cylinder, Register H = the allocation byte and Register Pair DE = the granules before the extent.
16EACG05
PUSH BC C5
Save Register Pair BC (the granule wanted) on the stack.
16EB
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the granules counted, Register Pair HL = the extent field.
16EC
If the field is unused (FFH, NZ from the compare with FEH), jump to 16A9H (CG06) to allocate space.
16EE
INC HL 23
Increment Register Pair HL to the link's second byte, the DEC of the extended entry.
16EF
LD B,(HL) 46
Load Register B with the DEC of the extended entry at Register Pair HL.
16F0
Loop back to 16B5H (CG01) to read that entry and go on counting.

16F2H - CG07: Allocate Granules to a File

Reached when the file must grow to hold granule Register Pair BC. Register Pair HL points to the first unused extent field and Register Pair DE holds the granules already allocated. CG07 reads the GAT into DIRBUF$ (2300H) and allocates one granule at a time: it extends the last extent when the granule after it is free on the disk, otherwise it starts a new extent at the first cylinder with free space, searching up from the cylinder in Register L (AFLAG$ (006AH) for a file's first extent, otherwise the cylinder where the previous extent ended or the last granule was allocated) and then from cylinder 0. When the fifth extent field is needed it writes the GAT and the entry and gets an extended directory entry (NEWHIT). At the end it writes the GAT and the directory entry back.

16F2CG07
PUSH BC C5
Save Register Pair BC (the granule wanted) on the stack.
16F3
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
16F6
Call @GATRD at 1874H to read the GAT of drive Register C into 2300H (DIRBUF$).
16F9
POP BC C1
Restore Register Pair BC (the granule wanted) from the stack.
16FA
RET NZ C0
Return if the GAT could not be read, NZ with error 20 in Register A.
16FB
PUSH HL E5
Save Register Pair HL (the unused extent field in SBUFF$) on the stack.
16FC
LD H,B 60
Copy Register B (the high byte of the granule wanted) into Register H.
16FD
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the granule wanted.
16FE
XOR A AF
Clear Register A and the Carry flag for the subtraction.
16FF
SBC HL,DE ED 52
Subtract Register Pair DE (the granules already allocated) from Register Pair HL.
1701
LD B,H 44
Copy Register H (the high byte of the difference) into Register B.
1702
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the difference.
1703
INC BC 03
Increment Register Pair BC: the number of granules to allocate.
1704
POP DE D1
Restore Register Pair DE from the stack: the unused extent field's cylinder byte.
1705
INC DE 13
Increment Register Pair DE to its allocation byte.
1706
LD H,23H 26 23
Load Register H with 23H, the page of the GAT at 2300H.
1708
LD A,(006AH) 3A 6A 00LD A,(AFLAG$)
Load Register A with 006AH (AFLAG$), the cylinder where the search for free space starts.
170B
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the GAT byte of that cylinder.
170C
PUSH BC C5
Save Register Pair BC (the granules to allocate) on the stack.
170D
LD A,E 7B
Copy Register E (the low byte of the allocation byte's address) into Register A.
170E
AND 1EH E6 1E
Mask Register A with 1EH, the position of the field in the entry.
1710
CP 16H FE 16
Compare Register A with 16H, the first extent field.
1712
If the unused field is the first one, the file has no space yet: jump to 1756H (CG14) to start an extent.
1714
DEC E 1D
Decrement Register E, back to the unused field's own cylinder byte.
1715
DEC E 1D
Decrement Register E again, to the previous field's allocation byte.
1716CG12
LD A,(DE) 1A
Load Register A with the allocation byte at Register Pair DE.
1717
AND 1FH E6 1F
Mask Register A with 1FH, the granules in the extent less one.
1719
INC A 3C
Increment Register A to the number of granules in the extent.
171A
LD C,A 4F
Copy Register A (the granules in the previous extent) into Register C.
171B
CP 20H FE 20
Compare Register A with 20H (32), the most granules one extent can hold.
171D
If the extent is full (Z), jump to 173FH (CG13) to use the next field.
171F
LD A,(DE) 1A
Load Register A with the allocation byte at Register Pair DE again.
1720
AND 0E0H E6 E0
Mask Register A with E0H, keeping bits 7-5, the starting granule.
1722
RLCA 07
Rotate Register A left, moving the starting granule toward bit 0.
1723
RLCA 07
Rotate Register A left a second time, moving the starting granule on toward bit 0.
1724
RLCA 07
Rotate Register A left a third time: the starting granule is in bits 2-0.
1725
ADD A,C 81
Add Register C (the count) to Register A: the granule after the extent's last, counted from its starting cylinder.
1726
PUSH DE D5
Save Register Pair DE (the allocation byte's address) on the stack.
1727
Call RELCYL at 1919H: Register A = the cylinders past the starting one, Register E = the granule inside that cylinder.
172A
LD B,A 47
Copy Register A (the cylinders to add) into Register B.
172B
LD C,E 4B
Copy Register E (the granule inside the cylinder) into Register C.
172C
POP DE D1
Restore Register Pair DE (the allocation byte's address) from the stack.
172D
DEC DE 1B
Decrement Register Pair DE to the extent's cylinder byte.
172E
LD A,(DE) 1A
Load Register A with the extent's starting cylinder at Register Pair DE.
172F
INC DE 13
Increment Register Pair DE back to the allocation byte.
1730
ADD A,B 80
Add Register B (the cylinders to add) to Register A: the cylinder of the next granule.
1731
LD L,A 6F
Copy Register A into Register L, the low byte of the GAT address.
1732
LD H,23H 26 23
Load Register H with 23H: Register Pair HL points to that cylinder's GAT byte.
1734
CP 0CBH FE CB
Compare Register A with CBH, the first cylinder the GAT sector cannot describe.
1736
If the cylinder is CBH or more (No Carry), jump to 173FH (CG13): the extent cannot grow.
1738
LD A,C 79
Copy Register C (the granule inside the cylinder) into Register A.
1739
LD B,(HL) 46
Load Register B with the cylinder's GAT byte at Register Pair HL.
173A
Call TSTBIT at 185BH to test bit Register A of Register B: Z when the granule is free.
173D
If the granule is free (Z), jump to 178AH (CG21) to allocate it, extending the extent.
173FCG13
INC E 1C
Increment Register E, from the previous field to the unused field's cylinder byte.
1740
INC E 1C
Increment Register E again, to the unused field's allocation byte.
1741
LD A,E 7B
Copy Register E (the low byte of the field's address) into Register A.
1742
AND 1EH E6 1E
Mask Register A with 1EH, the position of the field in the entry.
1744
CP 1EH FE 1E
Compare Register A with 1EH, the fifth field, which a full entry needs for its link.
1746
If the field is not the fifth (NZ), jump to 1756H (CG14) to start a new extent in it.
1748
Call CG23 at 17A4H to write the GAT and this directory entry back to the disk.
174B
POP BC C1
Restore Register Pair BC (the granules to allocate) from the stack.
174C
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
174D
PUSH BC C5
Save Register Pair BC (the granules to allocate) on the stack again.
174E
Call NEWHIT at 17AFH to get an extended directory entry and link it into the fifth field.
1751
POP BC C1
Restore Register Pair BC (the granules to allocate) from the stack.
1752
RET NZ C0
Return if no extended entry could be made, NZ with the error code (30, Directory full) in Register A.
1753
Jump to 16AEH (CYL_GRN) to follow the new link and go on allocating.
1756CG14
Call MAXCYL at 18FEH: Register A = the number of cylinders on the file's drive. Bug T6: unlike the test at 1734H, this search has no limit at CBH, the end of the GAT's cylinder map. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B4.
1759
LD (1760H),A 32 60 17
Store Register A into 1760H, the operand of the CP at CG17.
175C
LD B,02H 06 02
Load Register B with 02H, two passes: from the cylinder in Register L up (AFLAG$ for a file's first extent, otherwise where the previous extent ended), then from cylinder 0.
175ECG16
LD A,L 7D
Copy Register L (the cylinder to test) into Register A.
175FCG17
CP 00H FE 00
Compare Register A with the number of cylinders, the operand at 1760H stored at 1759H.
1761
If the cylinder is past the last one (No Carry), jump to 176AH (CG18).
1763
LD A,(HL) 7E
Load Register A with the cylinder's GAT byte at Register Pair HL.
1764
INC A 3C
Increment Register A: Z only when the byte was FFH, every granule in use.
1765
If the cylinder has a free granule (NZ), jump to 1777H (CG19).
1767
INC L 2C
Increment Register L to the next cylinder's GAT byte.
1768
Loop back to 175EH (CG16) to test the next cylinder.
176ACG18
LD L,00H 2E 00
Load Register L with 00H, cylinder 0, for the second pass.
176C
Decrement Register B and loop back to 175EH (CG16) for the second pass.
176E
POP BC C1
Restore Register Pair BC (the granules to allocate) from the stack.
176F
Call CG23 at 17A4H to write the GAT and the directory entry back, keeping what was allocated.
1772
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
1773
LD A,1BH 3E 1B
Load Register A with 1BH, error 27, Disk space full.
1775
OR A B7
OR Register A with itself to set the NZ flag.
1776
RET C9
Return with the error code in Register A and NZ.
1777CG19
LD A,0FFH 3E FF
Load Register A with FFH, the starting value of the new extent's allocation byte.
1779
LD (DE),A 12
Store Register A (FFH) into the new extent's allocation byte at Register Pair DE.
177A
LD C,00H 0E 00
Load Register C with 00H, the first granule of the cylinder to test.
177C
LD B,(HL) 46
Load Register B with the cylinder's GAT byte at Register Pair HL.
177DCG20
LD A,C 79
Copy Register C (the granule to test) into Register A.
177E
Call TSTBIT at 185BH to test bit Register A of Register B: Z when the granule is free.
1781
If the granule is free (Z), jump to 178AH (CG21) to allocate it.
1783
LD A,(DE) 1A
Load Register A with the new allocation byte at Register Pair DE.
1784
ADD A,20H C6 20
Add 20H to Register A, one more in the starting granule field (bits 7-5): FFH becomes 1FH as granule 0 is passed, 3FH as granule 1 is passed, and so on.
1786
LD (DE),A 12
Store Register A back into the allocation byte at Register Pair DE.
1787
INC C 0C
Increment Register C to the next granule of the cylinder.
1788
Loop back to 177DH (CG20) to test the next granule of the cylinder.
178ACG21
LD A,C 79
Copy Register C (the free granule) into Register A.
178B
Call SETBIT at 1868H: Register A = a mask with bit Register A set.
178E
OR (HL) B6
OR the cylinder's GAT byte at Register Pair HL into Register A.
178F
LD (HL),A 77
Store Register A back into the GAT at Register Pair HL: the granule is in use.
1790
DEC E 1D
Decrement Register E to the extent's cylinder byte.
1791
LD A,(DE) 1A
Load Register A with the extent's cylinder byte at Register Pair DE.
1792
INC A 3C
Increment Register A: Z when the byte was FFH, a new extent.
1793
If the extent already has its cylinder (NZ), jump to 1797H (CG22).
1795
LD A,L 7D
Copy Register L (the cylinder) into Register A.
1796
LD (DE),A 12
Store Register A into the new extent's cylinder byte at Register Pair DE.
1797CG22
INC E 1C
Increment Register E to the extent's allocation byte.
1798
LD A,(DE) 1A
Load Register A with the allocation byte at Register Pair DE.
1799
INC A 3C
Increment Register A: one more granule. For a new extent the 1FH in bits 4-0 overflows into bits 7-5, making the starting granule Register C and the count one.
179A
LD (DE),A 12
Store Register A back into the allocation byte at Register Pair DE.
179B
POP BC C1
Restore Register Pair BC (the granules to allocate) from the stack.
179C
DEC BC 0B
Decrement Register Pair BC: one granule allocated.
179D
PUSH BC C5
Save Register Pair BC (the granules still to allocate) on the stack again.
179E
LD A,B 78
Copy Register B (the high byte of the count) into Register A.
179F
OR C B1
OR Register C into Register A: Z when no more granules are needed.
17A0
If more are needed (NZ), jump to 1716H (CG12) to extend this extent or start the next.
17A3
POP BC C1
Restore Register Pair BC (the count, now zero) from the stack.
17A4CG23
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
17A7
Call @GATWR at 1875H to write the GAT at 2300H back to drive Register C.
17AA
RET NZ C0
Return if the GAT could not be written, NZ with error 21 in Register A.
17ABSTUFDEC
LD B,00H 06 00
Load Register B with the DEC of the directory entry in SBUFF$, the operand at 17ACH stored at 16B6H.
17AD
Jump to 1803H (@DIRWR) to write the directory sector back, which returns to the caller.

17AFH - NEWHIT: Get an Extended Directory Entry

When all four extent fields of a directory entry are used, the fifth becomes a link to an extended entry (FXDE). NEWHIT reads the Hash Index Table (HIT) into SBUFF$, finds a free slot with @SCNHIT, gives it the file's hash code, writes the HIT back, and makes the new entry: attributes 90H (extended, in use), a link back to the entry before it, twenty zero bytes and five unused extent fields. It then writes FEH and the new entry's code into the fifth field of the entry before it.

17AFNEWHIT
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
17B2
Call @HITRD at 1897H to read the HIT of drive Register C into SBUFF$ (1D00H).
17B5
RET NZ C0
Return if the HIT could not be read, NZ with error 22 in Register A.
17B6
LD A,(IX+07H) DD 7E 07
Load Register A with FCB+7 (Index Register IX+07H), the DEC of the file's primary entry.
17B9
AND 1FH E6 1F
Mask Register A with 1FH: the slot of entry 0 in the same directory sector, the first slot to try.
17BB
Call @SCNHIT at 181FH to find a free HIT slot from slot Register A on: Z with Register Pair HL pointing to it.
17BE
LD A,1EH 3E 1E
Load Register A with 1EH, error 30, Directory full, for the case of no free slot.
17C0
RET NZ C0
Return with error 30 if no slot is free (NZ).
17C1
LD B,L 45
Copy Register L (the free slot, the new entry's DEC) into Register B, for the directory read below.
17C2
LD A,L 7D
Copy Register L (the new DEC) into Register A.
17C3
LD (1802H),A 32 02 18
Store Register A into 1802H, the operand of the LD (HL) at NHIT3: the link written into the entry before.
17C6
LD D,H 54
Copy Register H (1DH, the page of the HIT) into Register D.
17C7
LD E,(IX+07H) DD 5E 07
Load Register E with FCB+7 (Index Register IX+07H): Register Pair DE points to the primary entry's HIT slot.
17CA
LD A,(DE) 1A
Load Register A with the file's hash code at Register Pair DE.
17CB
LD (HL),A 77
Store Register A (the hash code) into the new slot at Register Pair HL.
17CC
Call @HITWR at 1898H to write the HIT back to drive Register C.
17CF
If the HIT was written (Z), call @DIRRD at 18BBH to read the directory sector of entry Register B (the new DEC); Register Pair HL points to the entry.
17D2
RET NZ C0
Return if either failed, NZ with the error code in Register A.
17D3
LD (HL),90H 36 90
Store 90H into the new entry's attribute byte at Register Pair HL: bit 7 an extended entry, bit 4 in use.
17D5
INC L 2C
Increment Register L to the new entry's byte 1, the link back to the entry before it.
17D6
PUSH BC C5
Save Register Pair BC (Register B the new DEC, Register C the drive) on the stack.
17D7
LD A,(17ACH) 3A AC 17
Load Register A with the DEC of the entry before, the operand at 17ACH (STUFDEC) stored at 16B6H.
17DA
LD (HL),A 77
Store Register A into the new entry's byte 1 at Register Pair HL: the link back to the entry before.
17DB
INC L 2C
Increment Register L to the new entry's byte 2, the first of the bytes to clear.
17DC
LD B,14H 06 14
Load Register B with 14H (20), the bytes to clear, the entry's bytes 2 to 15H.
17DENHIT1
LD (HL),00H 36 00
Store 00H at Register Pair HL, clearing one byte of the new entry.
17E0
INC L 2C
Increment Register L to the next byte of the entry.
17E1
Decrement Register B and loop back to 17DEH (NHIT1) until twenty bytes are zero.
17E3
PUSH HL E5
Save Register Pair HL (the entry's byte 16H, the first extent field) on the stack.
17E4
LD B,0AH 06 0A
Load Register B with 0AH (10), the bytes of the five extent fields.
17E6NHIT2
LD (HL),0FFH 36 FF
Store FFH at Register Pair HL: an unused extent field.
17E8
INC L 2C
Increment Register L to the next byte of the entry.
17E9
Decrement Register B and loop back to 17E6H (NHIT2) until all ten bytes are FFH.
17EB
POP DE D1
Restore Register Pair DE (the first extent field) from the stack.
17EC
INC DE 13
Increment Register Pair DE to the first field's allocation byte.
17ED
POP BC C1
Restore Register Pair BC (Register B the new DEC, Register C the drive) from the stack.
17EE
Call @DIRWR at 1803H to write the new entry's directory sector.
17F1
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
17F2
LD A,(17ACH) 3A AC 17
Load Register A with the DEC of the entry before, the operand at 17ACH (STUFDEC).
17F5
LD B,A 47
Copy Register A (the DEC of the entry before) into Register B for the directory read.
17F6
Call @DIRRD at 18BBH to read the directory sector of entry Register B; Register Pair HL points to the entry.
17F9
RET NZ C0
Return if the read failed, NZ with error 17 in Register A.
17FA
LD A,L 7D
Copy Register L (the offset of the entry) into Register A.
17FB
ADD A,1EH C6 1E
Add 1EH to Register A, the offset of the fifth extent field.
17FD
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the fifth field.
17FE
LD (HL),0FEH 36 FE
Store FEH at Register Pair HL: the field is a link to an extended entry.
1800
INC L 2C
Increment Register L to the link's second byte.
1801NHIT3
LD (HL),00H 36 00
Store the new entry's DEC at Register Pair HL: the operand at 1802H was stored at 17C3H. Fall into @DIRWR to write the sector.

1803H - @DIRWR, @SCNHIT, TSTBIT and SETBIT

@DIRWR (SVC 88) writes SBUFF$ to the directory sector of entry Register B (its DEC) on drive Register C, with the system data mark, and reads it back; it tries twice. A verify returns error 6 for a sector with the system data mark, so error 6 is success. It returns error 18 (Directory write error), or 15 for a write protected disk. @SCNHIT finds a free slot in the HIT in SBUFF$. TSTBIT and SETBIT build a BIT n,B or SET n,A instruction for granule n of a GAT byte.

1803@DIRWR
Call DIRWR at 1807H for the first try at writing and verifying the directory sector.
1806
RET Z C8
Return if the sector was written (Z); otherwise fall into DIRWR for a second try.
1807DIRWR
PUSH DE D5
Save Register Pair DE on the stack; CALCDIR loads it with the cylinder and sector.
1808
Call CALCDIR at 18CAH: Register D = the directory cylinder, Register E = the sector of entry Register B.
180B
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL = 1D00H, the start of SBUFF$.
180D
Call @WRSSC at 19ECH to write SBUFF$ to cylinder Register D, sector Register E of drive Register C with the system data mark.
1810
If the write was clean (Z), call @VRSEC at 19DCH to read the sector back.
1813
SUB 06H D6 06
Subtract 06H from Register A: Z when the verify returned error 6, the system data mark, which is success.
1815
POP DE D1
Restore Register Pair DE (the caller's value) from the stack.
1816
RET Z C8
Return Z if the sector was written and verified.
1817
CP 09H FE 09
Compare Register A (the error less 6) with 09H: Z when the error was 15, Write protected disk.
1819
LD A,12H 3E 12
Load Register A with 12H, error 18, Directory write error.
181B
RET NZ C0
Return with error 18 for any other failure (NZ).
181C
SUB 03H D6 03
Subtract 03H from Register A: 0FH, error 15, Write protected disk, with NZ.
181E
RET C9
Return with error 15, Write protected disk, in Register A and NZ.
181FNHIT4
PUSH AF F5
Save Register Pair AF, whose Register A is the DEC of the entry to try first, on the stack. The source of this release names the routine NHIT4; LS-DOS 6.3.1 calls the same address @SCNHIT.
1820
LD A,07H 3E 07
Load Register A with 07H, the drive code table byte that holds the highest sector.
1822
Call @DCTBYT at 1A2BH: Register A = DCT+7 of drive Register C (bits 7-5 the heads less one, bits 4-0 the highest sector).
1825
PUSH DE D5
Save Register Pair DE (the caller's value) on the stack while the sector count is worked out.
1826
LD D,A 57
Copy Register A (DCT+7) into Register D, to recover bits 7-5 below.
1827
AND 1FH E6 1F
Mask Register A with 1FH, the highest sector of a track.
1829
LD E,A 5F
Copy Register A (the highest sector of a track) into Register E.
182A
INC E 1C
Increment Register E: the number of sectors on one track.
182B
XOR D AA
Exclusive OR Register D into Register A: only bits 7-5 of DCT+7 are left.
182C
RLCA 07
Rotate Register A left, moving bits 7-5 toward bit 0.
182D
RLCA 07
Rotate Register A left a second time, moving the heads field on toward bit 0.
182E
RLCA 07
Rotate Register A left a third time: the heads less one, in bits 2-0.
182F
INC A 3C
Increment Register A: the number of heads, 1 for a floppy drive.
1830
Call @MUL8 at 190AH: Register A = Register A (heads) times Register E (sectors per track).
1833
Call CKDBLBIT at 193BH to double Register A if the diskette is two sided: the sectors of a cylinder.
1836
POP DE D1
Restore Register Pair DE (the caller's value) from the stack.
1837
SUB 02H D6 02
Subtract 02H from Register A, for the GAT and HIT sectors: the number of directory sectors.
1839
LD (1849H),A 32 49 18
Store Register A into 1849H, the operand of the CP at NHIT7.
183C
POP AF F1
Restore Register Pair AF from the stack: Register A = the first slot to try.
183D
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to that HIT slot (Register H = 1DH).
183E
Call NHIT6 at 1845H to test the slot: Z when it is free.
1841
RET Z C8
Return Z with Register Pair HL at the slot if it is free.
1842
LD L,3FH 2E 3F
Load Register L with 3FH. The entry the file already had is taken, so the search for a free one starts here: NHIT5 below increments Register L to 40H, which is the DEC of entry 2 of directory sector 0, past BOOT/SYS at DEC 00H and DIR/SYS at DEC 20H. LS-DOS 6.3.1 re-laid the whole of 1842H-185AH and loads Register L with 01H here, so the two releases walk the HIT in different orders.
1844NHIT5
INC L 2C
Increment Register L, which from 3FH gives 40H and after each wrap at 1853H gives the first entry of the next directory sector.
1845NHIT6
LD A,L 7D
Copy Register L, the DEC in hand, into Register A.
1846
AND 1FH E6 1F
AND Register A with 1FH, leaving bits 4-0 of the DEC, which are the directory sector the entry is in.
1848NHIT7
CP 00H FE 00
Compare Register A with 00H, the operand 1839H stored the number of directory sectors into.
184A
If the sector is at or past the number the drive has, jump to NHIT9 at 1859H: the HIT holds no free entry.
184C
LD A,(HL) 7E
Load Register A with the hash code at Register Pair HL, the HIT byte of this DEC.
184D
OR A B7
OR Register A with itself to test it: a hash code of 00H is a free entry.
184E
RET Z C8
Return with the Z flag set and the free DEC in Register L.
184FNHIT8
LD A,L 7D
Copy Register L, the DEC in hand, into Register A.
1850
ADD A,20H C6 20
Add 20H to Register A, which steps bits 7-5 to the next of the eight entries of the same directory sector.
1852
LD L,A 6F
Copy Register A back into Register L, the next DEC to test.
1853
While the addition did not carry out of Register A, jump back to NHIT6 at 1845H and test that entry.
1855
CP 1FH FE 1F
The addition carried, so the eight entries of this sector are done: compare Register A with 1FH, which it holds only when Register L had reached FFH, the last entry of the last sector the HIT can hold.
1857
If Register A is not 1FH, jump back to NHIT5 at 1844H, which increments Register L to entry 0 of the next directory sector.
1859NHIT9
OR A B7
OR Register A with itself, which sets NZ because Register A is 1FH or the sector number that ran past the drive's count.
185A
RET C9
Return NZ: every entry of the HIT is taken and the file cannot be given one.
185BTSTBIT
AND 07H E6 07
Mask Register A (the granule number) with 07H.
185D
RLCA 07
Rotate Register A left, moving the bit number toward bits 5-3.
185E
RLCA 07
Rotate Register A left a second time, moving the bit number on toward bits 5-3.
185F
RLCA 07
Rotate Register A left a third time: the bit number is in bits 5-3.
1860
OR 40H F6 40
OR 40H into Register A: the second byte of BIT n,B (CB 40H plus 8 times n).
1862
LD (1866H),A 32 66 18
Store Register A into 1866H, the second byte of the BIT instruction at TBIT1.
1865TBIT1
BIT 0,B CB 40
Test bit n of Register B (the GAT byte); the instruction was built at 1862H, BIT 0,B in the file.
1867
RET C9
Return Z when the granule's bit is clear (free), NZ when it is in use.
1868SETBIT
RLCA 07
Rotate Register A (the granule number, 0 to 7) left, moving it toward bits 5-3.
1869
RLCA 07
Rotate Register A left a second time, moving the bit number on toward bits 5-3.
186A
RLCA 07
Rotate Register A left a third time: the bit number is in bits 5-3.
186B
OR 0C7H F6 C7
OR C7H into Register A: the second byte of SET n,A (CB C7H plus 8 times n).
186D
LD (1872H),A 32 72 18
Store Register A into 1872H, the second byte of the SET instruction at SBIT1.
1870
XOR A AF
Clear Register A to 00H, so the SET leaves only the one bit.
1871SBIT1
SET 0,A CB C7
Set bit n of Register A; the instruction was built at 186DH, SET 0,A in the file.
1873
RET C9
Return with Register A = the mask of the granule's bit.

1874H - @GATRD, @GATWR, @HITRD and @HITWR

@GATRD (SVC 86) reads the Granule Allocation Table, sector 0 of the directory cylinder, into DIRBUF$ (2300H); @GATWR (SVC 89) writes it back with the system data mark and verifies it. @HITRD and @HITWR do the same for the Hash Index Table, sector 1, in SBUFF$ (1D00H). Each read entry is one byte before the write entry: the byte F6H makes an OR AFH that sets NZ, while the write entry's XOR A sets Z. They return Z on success, or NZ with error 20, 21, 22 or 23.

1874@GATRD
DEFB 0F6H F6
@GATRD, 1874H: the byte F6H, which with the AFH at 1875H is the instruction OR AFH: entered here, Register A becomes non zero and the NZ flag marks a read. @GATWR at 1875H is the XOR A alone.
1875@GATWR
XOR A AF
Clear Register A to 00H and set the Z flag, which marks a write.
1876
PUSH DE D5
Save Register Pair DE (the caller's value) on the stack.
1877
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1878
PUSH AF F5
Save Register Pair AF (the Z or NZ flag: write or read) on the stack.
1879
Call @DIRCYL at 18F7H: Register D = the directory cylinder of drive Register C.
187C
LD HL,2300H 21 00 23LD HL,DIRBUF$
Point Register Pair HL to 2300H (DIRBUF$), the GAT buffer.
187F
LD E,L 5D
Copy Register L (00H) into Register E: sector 0, the GAT.
1880
POP AF F1
Restore Register Pair AF: the flag says write (Z) or read (NZ).
1881
For a write (Z), jump to 188AH (GATRW1) to write the GAT.
1883
Call @RDSSC at 18D8H to read cylinder Register D, sector Register E into Register Pair HL: Z for a sector with the system data mark.
1886
LD A,14H 3E 14
Load Register A with 14H, error 20, GAT read error (the flags of the read are kept).
1888
Jump to 1894H (GATRW2) to restore the registers and return.
188AGATRW1
Call @WRSSC at 19ECH to write the GAT at Register Pair HL with the system data mark.
188D
If the write was clean (Z), call @VRSEC at 19DCH to read it back.
1890
CP 06H FE 06
Compare Register A with 06H: Z when the verify found the system data mark, a good write.
1892
LD A,15H 3E 15
Load Register A with 15H, error 21, GAT write error (the flags of the compare are kept).
1894GATRW2
POP HL E1
Restore Register Pair HL from the stack.
1895
POP DE D1
Restore Register Pair DE (the caller's value) from the stack.
1896
RET C9
Return Z on success, or NZ with the error code in Register A.
1897@HITRD
DEFB 0F6H F6
@HITRD, 1897H: the byte F6H, with the AFH at 1898H the instruction OR AFH, which sets NZ for a read; @HITWR at 1898H is the XOR A alone, which sets Z for a write.
1898@HITWR
XOR A AF
Clear Register A to 00H and set the Z flag, which marks a write.
1899
PUSH BC C5
Save Register Pair BC (the caller's value, Register C the drive) on the stack.
189A
PUSH DE D5
Save Register Pair DE (the caller's value) on the stack.
189B
PUSH AF F5
Save Register Pair AF (the Z or NZ flag: write or read) on the stack.
189C
Call @DIRCYL at 18F7H: Register D = the directory cylinder of drive Register C.
189F
LD E,01H 1E 01
Load Register E with 01H, sector 1 of the directory cylinder, the HIT.
18A1
LD HL,1D00H 21 00 1DLD HL,SBUFF$
Point Register Pair HL to 1D00H (SBUFF$), the HIT buffer; Register Pair HL is returned pointing there.
18A4
POP AF F1
Restore Register Pair AF: the flag says write (Z) or read (NZ).
18A5
For a write (Z), jump to 18AEH (HITRW1) to write the HIT.
18A7
Call @RDSSC at 18D8H to read cylinder Register D, sector Register E into Register Pair HL.
18AA
LD A,16H 3E 16
Load Register A with 16H, error 22, HIT read error (the flags of the read are kept).
18AC
Jump to 18B8H (HITRW2) to restore the registers and return.
18AEHITRW1
Call @WRSSC at 19ECH to write the HIT at Register Pair HL with the system data mark.
18B1
If the write was clean (Z), call @VRSEC at 19DCH to read it back.
18B4
CP 06H FE 06
Compare Register A with 06H: Z when the verify found the system data mark, a good write.
18B6
LD A,17H 3E 17
Load Register A with 17H, error 23, HIT write error (the flags of the compare are kept).
18B8HITRW2
POP DE D1
Restore Register Pair DE from the stack.
18B9
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
18BA
RET C9
Return Z on success, or NZ with the error code in Register A.

18BBH - @DIRRD, CALCDIR, @RDSSC and @DIRCYL: Directory Reads

@DIRRD (SVC 87) reads the directory sector that holds entry Register B (a DEC: bits 7-5 the entry in the sector, bits 4-0 the sector less 2) of drive Register C into SBUFF$ and returns Register Pair HL pointing to the entry. @RDSSC (SVC 85) reads a sector that must carry the system data mark; when it does not, the diskette may have been changed, so it reads the boot sector (cylinder 0, sector 1), takes the directory cylinder from its byte 2, stores it in the drive code table (DCT+9) and tries again.

18BB@DIRRD
PUSH DE D5
Save Register Pair DE (the caller's value) on the stack.
18BC
Call CALCDIR at 18CAH: Register D = the directory cylinder, Register E = the sector, Register Pair HL = the entry's place in SBUFF$.
18BF
PUSH HL E5
Save Register Pair HL (the entry's address) on the stack.
18C0
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL = 1D00H, the start of SBUFF$.
18C2
Call @RDSSC at 18D8H to read cylinder Register D, sector Register E of drive Register C into SBUFF$.
18C5
POP HL E1
Restore Register Pair HL (the entry's address) from the stack.
18C6
LD A,11H 3E 11
Load Register A with 11H, error 17, Directory read error (the flags of the read are kept).
18C8
POP DE D1
Restore Register Pair DE (the caller's value) from the stack.
18C9
RET C9
Return Z with Register Pair HL at the entry, or NZ with error 17.
18CACALCDIR
Call @DIRCYL at 18F7H: Register D = the directory cylinder of drive Register C.
18CD
LD A,B 78
Copy Register B (the DEC of the entry) into Register A.
18CE
AND 0E0H E6 E0
Mask Register A with E0H, keeping bits 7-5, the entry in the sector times 32.
18D0
LD L,A 6F
Copy Register A into Register L: the entry's offset in the sector.
18D1
LD H,1DH 26 1D
Load Register H with 1DH: Register Pair HL points to the entry in SBUFF$ (1D00H).
18D3
XOR B A8
Exclusive OR Register B into Register A: only bits 4-0 of the DEC are left.
18D4
ADD A,02H C6 02
Add 02H to Register A: the directory sector, past the GAT (sector 0) and the HIT (sector 1).
18D6
LD E,A 5F
Copy Register A (the sector) into Register E.
18D7
RET C9
Return with Register D = the cylinder, Register E = the sector, Register Pair HL = the entry.
18D8@RDSSC
Call READIR at 18F1H to read cylinder Register D, sector Register E into Register Pair HL: Z when the sector has the system data mark.
18DB
RET Z C8
Return Z if the sector was read as a system sector.
18DC
PUSH DE D5
Save Register Pair DE (the cylinder and sector) on the stack.
18DD
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H: cylinder 0, sector 1, the boot sector.
18E0
Call @RDSEC at 19F4H to read the boot sector into the buffer at Register Pair HL.
18E3
POP DE D1
Restore Register Pair DE (the cylinder and sector) from the stack.
18E4
RET NZ C0
Return if the boot sector could not be read, NZ with the error code in Register A.
18E5
PUSH HL E5
Save Register Pair HL (the buffer) on the stack.
18E6
INC HL 23
Increment Register Pair HL to the boot sector's byte 1.
18E7
INC HL 23
Increment Register Pair HL to byte 2, the operand of the boot code's CP, the directory cylinder.
18E8
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the directory cylinder of the diskette now in the drive.
18E9
LD H,09H 26 09
Load Register H with 09H, the drive code table field of the directory cylinder.
18EB
Call DCTFLD@ at 1A34H: Register A = the low byte of DCT+9 of drive Register C, Register H = 04H.
18EE
LD L,A 6F
Copy Register A into Register L: Register Pair HL = DCT+9.
18EF
LD (HL),D 72
Store Register D (the directory cylinder) into DCT+9 at Register Pair HL.
18F0
POP HL E1
Restore Register Pair HL (the buffer) from the stack, and fall into READIR to read the sector again.
18F1READIR
Call @RDSEC at 19F4H to read cylinder Register D, sector Register E of drive Register C into Register Pair HL.
18F4
SUB 06H D6 06
Subtract 06H from Register A: Z when the read returned error 6, a sector with the system data mark.
18F6
RET C9
Return Z for a system sector, NZ for anything else.
18F7@DIRCYL
LD A,09H 3E 09
Load Register A with 09H, the drive code table field of the directory cylinder.
18F9
Call @DCTBYT at 1A2BH: Register A = DCT+9 of drive Register C.
18FC
LD D,A 57
Copy Register A (the directory cylinder) into Register D.
18FD
RET C9
Return with the directory cylinder in Register D.
18FEMAXCYL
LD A,06H 3E 06
Load Register A with 06H, the drive code table field of the highest cylinder.
1900
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack.
1901
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the file's drive.
1904
Call @DCTBYT at 1A2BH: Register A = DCT+6, the highest cylinder of drive Register C.
1907
INC A 3C
Increment Register A: the number of cylinders.
1908
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
1909
RET C9
Return with the number of cylinders in Register A.

190AH - @MUL8, RELCYL, @DIV8 and CKDBLBIT

@MUL8 (SVC 90) multiplies Register A by Register E and returns the low byte of the product in Register A. @DIV8 (SVC 93) divides Register E by Register A and returns the quotient in Register A and the remainder in Register E. RELCYL turns a granule number (Register A) into cylinders (Register A) and the granule in that cylinder (Register E), using the granules per cylinder of the FCB's drive; CKDBLBIT doubles Register A for a two sided diskette.

190A@MUL8
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack; Register B counts the bits.
190B
LD D,A 57
Copy Register A (the multiplicand) into Register D.
190C
XOR A AF
Clear Register A to 00H, the product so far, before the eight passes.
190D
LD B,08H 06 08
Load Register B with 08H, the eight bits of the multiplier.
190FMEA1
ADD A,A 87
Add Register A to itself: the product so far times 2.
1910
SLA E CB 23
Shift Register E (the multiplier) left: its top bit goes into the Carry flag.
1912
If the bit was 0 (No Carry), jump to 1915H (MEA2).
1914
ADD A,D 82
Add Register D (the multiplicand) to Register A.
1915MEA2
Decrement Register B and loop back to 190FH (MEA1) for all eight bits.
1917
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
1918
RET C9
Return with the product in Register A, the multiplicand in Register D and Register E = 00H.
1919RELCYL
LD E,A 5F
Copy Register A (the granule number) into Register E, the dividend.
191A
Call D@FBYT8 at 1A26H: Register C = the FCB's drive, Register A = DCT+8 (granules per track less one in bits 7-5).
191D
LD B,A 47
Copy Register A (DCT+8) into Register B, returned to the caller.
191E
RLCA 07
Rotate Register A left, moving bits 7-5 toward bit 0.
191F
RLCA 07
Rotate Register A left a second time, moving bits 7-5 on toward bit 0.
1920
RLCA 07
Rotate Register A left a third time: the granules per track less one, in bits 2-0.
1921
AND 07H E6 07
Mask Register A with 07H, keeping the granules per track less one.
1923
INC A 3C
Increment Register A: the granules per track.
1924
Call CKDBLBIT at 193BH to double Register A for a two sided diskette (the granules per cylinder); it returns to @DIV8, which divides.
1927@DIV8
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack; Register B counts the bits.
1928
LD C,A 4F
Copy Register A (the divisor) into Register C.
1929
LD B,08H 06 08
Load Register B with 08H, the eight bits of the dividend.
192B
XOR A AF
Clear Register A to 00H, the remainder so far.
192CDEA1
SLA E CB 23
Shift Register E (the dividend) left: its top bit goes into the Carry flag.
192E
RLA 17
Rotate Register A left through the Carry flag: the bit joins the remainder.
192F
CP C B9
Compare Register A (the remainder) with Register C (the divisor).
1930
If the remainder is smaller (Carry), jump to 1934H (DEA2).
1932
SUB C 91
Subtract Register C (the divisor) from Register A.
1933
INC E 1C
Increment Register E: a 1 bit of the quotient enters at bit 0.
1934DEA2
Decrement Register B and loop back to 192CH (DEA1) for all eight bits.
1936
LD C,A 4F
Copy Register A (the remainder) into Register C.
1937
LD A,E 7B
Copy Register E (the quotient) into Register A.
1938
LD E,C 59
Copy Register C (the remainder) into Register E.
1939
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
193A
RET C9
Return with the quotient in Register A and the remainder in Register E.
193BCKDBLBIT
LD D,A 57
Copy Register A (the value to adjust) into Register D.
193C
LD A,04H 3E 04
Load Register A with 04H, the drive code table field with the two sided bit.
193E
Call @DCTBYT at 1A2BH: Register A = DCT+4 of drive Register C.
1941
BIT 5,A CB 6F
Test bit 5 of Register A, set for a two sided diskette.
1943
LD A,D 7A
Copy Register D (the value) back into Register A (the flags are kept).
1944
If the diskette is one sided (Z), jump to 1947H and return Register A as it is.
1946
ADD A,A 87
Add Register A to itself: the value doubled for two sides.
1947
RET C9
Return with Register A, doubled for a two sided diskette.

1948H - @HIGH$, @FLAGS, @BREAK and @WHERE

The start of LOADER, the system loader and its small SVCs. @HIGH$ (SVC 100) reads (Register Pair HL = 0) or sets (Register Pair HL = the new value) HIGH$ (040EH) when Register B is 0, or LOW$ (001EH) when it is not; neither HIGH$ nor LOW$ can be set while CFLAG$ bit 0 is set. @FLAGS (SVC 101) points Index Register IY to the system flags. @BREAK (SVC 103) swaps the BREAK vector. @WHERE (SVC 7) returns the address after the caller's RST 28H.

1948@HIGH$
LD A,H 7C
Copy Register H into Register A, to test Register Pair HL for zero.
1949
OR L B5
OR Register L into Register A: Z when Register Pair HL is 0000H, a request to read the value.
194A
If Register Pair HL is zero, jump to 195EH (GETHILO) to read HIGH$ or LOW$.
194C
LD A,(006CH) 3A 6C 00LD A,(CFLAG$)
Load Register A with 006CH (CFLAG$), whose bit 0 says HIGH$ cannot be changed.
194F
RRCA 0F
Rotate Register A right: bit 0 goes into the Carry flag.
1950
LD A,2BH 3E 2B
Load Register A with 2BH, error 43, SVC parameter error (the flags of the rotate are kept).
1952
RET C D8
Return with error 43 (NZ from the code) if HIGH$ and LOW$ are locked (Carry).
1953
INC B 04
Increment Register B, to test it for zero without changing it.
1954
DEC B 05
Decrement Register B back: Z when Register B is 0, a request for HIGH$.
1955
If Register B is not zero (NZ), jump to 1965H (PUTLO) to set LOW$.
1957
LD (040EH),HL 22 0E 04LD (HIGH$),HL
Store Register Pair HL (the new value) into 040EH (HIGH$).
195AGETHI
LD HL,(040EH) 2A 0E 04LD HL,(HIGH$)
Load Register Pair HL with 040EH (HIGH$), the highest address free for programs.
195D
RET C9
Return with HIGH$ in Register Pair HL and the Z flag set (no error).
195EGETHILO
INC B 04
Increment Register B, to test it for zero without changing it.
195F
DEC B 05
Decrement Register B back: Z when Register B is 0, a request for HIGH$.
1960
If the request is for HIGH$ (Z), jump to 195AH (GETHI).
1962
LD HL,(001EH) 2A 1E 00LD HL,(LOW$)
Load Register Pair HL with 001EH (LOW$), the low limit of the memory for programs (2FFFH after an @EXIT).
1965PUTLO
LD (001EH),HL 22 1E 00LD (LOW$),HL
Store Register Pair HL into 001EH (LOW$): the new value, or the same value when it was only read.
1968
XOR A AF
Clear Register A to 00H and set the Z flag: no error.
1969
RET C9
Return with LOW$ in Register Pair HL and the Z flag set (no error).
196A@FLAGS
LD IY,006AH FD 21 6A 00LD IY,FLGTAB$
Point Index Register IY to 006AH (FLGTAB$), the 26 system flags A to Z.
196E
RET C9
Return with Index Register IY at the flags table.
196F@BREAK
PUSH HL E5
Save Register Pair HL (the new BREAK vector) on the stack.
1970
LD HL,(1C88H) 2A 88 1CLD HL,(BRKVEC$)
Load Register Pair HL with 1C88H, the current BREAK vector, the operand of the LD HL at 1C87H that the interrupt handler tests.
1973
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the old vector is saved and Register Pair HL is the new one.
1974
LD (1C88H),HL 22 88 1CLD (BRKVEC$),HL
Store Register Pair HL (the new vector) into 1C88H.
1977
POP HL E1
Restore Register Pair HL from the stack: the old vector is returned.
1978
RET C9
Return with the old BREAK vector in Register Pair HL.
1979@WHERE
POP HL E1
Restore Register Pair HL from the stack: the return address, the byte after the caller's RST 28H.
197A
JP (HL) E9
Jump to Register Pair HL, returning to the caller with that address in Register Pair HL.

197BH - The Overlay Stubs: SVCs Served by System Overlays

Each of these SVCs loads Register A with an overlay request and issues RST 28H again. A request has bit 7 set; bits 3-0 name the overlay (2 to 7 for SYS0 to SYS5, 8 to 15 for SYS6 to SYS13) and bits 6-4 the function inside it. RST28 drops the stub's return address, so the overlay returns straight to the program.

197B@CMNDR
LD A,0A3H 3E A3
Load Register A with A3H: overlay 3 (SYS1), function 2, run a command and return.
197D
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which loads SYS1 if needed and runs it with the request in Register A.
197E@CMNDI
LD A,0B3H 3E B3
Load Register A with B3H: overlay 3 (SYS1), function 3, run a command.
1980
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS1.
1981@FSPEC
LD A,0C3H 3E C3
Load Register A with C3H: overlay 3 (SYS1), function 4, parse a filespec.
1983
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS1.
1984@FEXT
LD A,0D3H 3E D3
Load Register A with D3H: overlay 3 (SYS1), function 5, supply a default extension.
1986
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS1.
1987@PARAM
LD A,0E3H 3E E3
Load Register A with E3H: overlay 3 (SYS1), function 6, the parameter scanner.
1989
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS1.
198A@OPEN
LD A,94H 3E 94
Load Register A with 94H: overlay 4 (SYS2), function 1, open a file.
198C
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS2.
198D@INIT
LD A,0A4H 3E A4
Load Register A with A4H: overlay 4 (SYS2), function 2, open or create a file.
198F
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS2.
1990@GTDCB
LD A,0B4H 3E B4
Load Register A with B4H: overlay 4 (SYS2), function 3, find a device's DCB.
1992
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS2.
1993@CKDRV
LD A,0C4H 3E C4
Load Register A with C4H: overlay 4 (SYS2), function 4, check a drive.
1995
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS2.
1996@RENAME
LD A,0F4H 3E F4
Load Register A with F4H: overlay 4 (SYS2), function 7, rename a file.
1998
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS2.
1999@CLOSE
LD A,95H 3E 95
Load Register A with 95H: overlay 5 (SYS3), function 1, close a file.
199B
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS3.
199C@FNAME
LD A,0A5H 3E A5
Load Register A with A5H: overlay 5 (SYS3), function 2, recover a filespec.
199E
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS3.
199F@DBGHK
RET C9
Return to the caller: the DEBUG hook. While the debugger is on this byte is 00H (NOP) and the code falls into @DEBUG; RST28 (1A68H) and the BREAK handler (1C75H) store C9H here.
19A0@DEBUG
PUSH AF F5
Save Register Pair AF on the stack for the debugger. @DEBUG (SVC 27, and RST 30H) enters the system debugger.
19A1
LD A,97H 3E 97
Load Register A with 97H: overlay 7 (SYS5), function 1, the debugger.
19A3
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the debugger in SYS5.
19A4-19A5EXTDBG$
DEFW 14DCH DC 14
EXTDBG$, 19A4H-19A5H = 14DCH, which is the OR A and RET at the tail of LOC3 that the source calls ORARET@: the hook an extended debugger puts its own address in. The two bytes are never run as code, because the dispatcher does not return to the stub above them. LS-DOS 6.3.1 has the same hook pointing at its own OR A and RET at 1503H.
19A6@REMOVE
LD A,9CH 3E 9C
Load Register A with 9CH: overlay 12 (SYS10), function 1, remove a file or device.
19A8
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS10.
19A9@DOKEY
LD A,0CDH 3E CD
Load Register A with CDH: overlay 13 (SYS11), function 4, DO execution.
19AB
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS11.
19AC@RAMDIR
LD A,9EH 3E 9E
Load Register A with 9EH: overlay 14 (SYS12), function 1, directory data into memory.
19AE
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS12.
19AF@DODIR
LD A,0AEH 3E AE
Load Register A with AEH: overlay 14 (SYS12), function 2, directory data.
19B1
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS12.
19B2@GTMOD
LD A,0BEH 3E BE
Load Register A with BEH: overlay 14 (SYS12), function 3, find a memory module.
19B4
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS12.

19B5H - The Disk SVCs: IOFUNC

SVCs 40 to 55 load Register A with the driver function (0 to 15) and go to IOFUNC, which switches memory bank 0 in, stores the drive (Register C) in LDRV$, points Index Register IY to the drive's code table entry and calls its first three bytes: a JP to the driver, or a RET (with Register A = 20H, error 32, Illegal drive number, and NZ) when the drive is disabled. Afterwards it restores the bank that was in use. The driver gets Register B = the function, Register C = the drive and Index Register IY = the drive code table.

19B5@DCSTAT
XOR A AF
Clear Register A to 00H, driver function 0, controller status.
19B6
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19B8TAPDRV
LD A,(0023H) 3A 23 00LD A,(LDRV$)
Load Register A with 0023H (LDRV$), the drive of the last disk request. The BREAK handler calls here (1C64H) after SHIFT BREAK.
19BB
LD C,A 4F
Copy Register A (the drive) into Register C, and fall into @SLCT to reselect it.
19BC@SLCT
LD A,01H 3E 01
Load Register A with 01H, driver function 1, select the drive.
19BE
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19C0@DCINIT
LD A,02H 3E 02
Load Register A with 02H, driver function 2, initialize the controller.
19C2
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19C4@DCRES
LD A,03H 3E 03
Load Register A with 03H, driver function 3, reset the controller.
19C6
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19C8@RSTOR
LD A,04H 3E 04
Load Register A with 04H, driver function 4, restore the head to cylinder 0.
19CA
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19CC@STEPI
LD A,05H 3E 05
Load Register A with 05H, driver function 5, step the head in one cylinder.
19CE
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19D0@SEEK
LD A,06H 3E 06
Load Register A with 06H, driver function 6, seek a cylinder.
19D2
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19D4@RSLCT
LD A,07H 3E 07
Load Register A with 07H, driver function 7, reselect the drive and test it.
19D6
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19D8@RDHDR
LD A,08H 3E 08
Load Register A with 08H, driver function 8, read a sector header.
19DA
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19DC@VRSEC
LD A,0AH 3E 0A
Load Register A with 0AH, driver function 10, verify a sector.
19DE
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19E0@RDTRK
LD A,0BH 3E 0B
Load Register A with 0BH, driver function 11, read a track.
19E2
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19E4@HDFMT
LD A,0CH 3E 0C
Load Register A with 0CH, driver function 12, format a hard drive.
19E6
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19E8@WRSEC
LD A,0DH 3E 0D
Load Register A with 0DH, driver function 13, write a sector.
19EA
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19EC@WRSSC
LD A,0EH 3E 0E
Load Register A with 0EH, driver function 14, write a sector with the system data mark.
19EE
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19F0@WRTRK
LD A,0FH 3E 0F
Load Register A with 0FH, driver function 15, write a track.
19F2
Jump to 19F6H (IOFUNC) to call the driver with the function in Register A.
19F4@RDSEC
LD A,09H 3E 09
Load Register A with 09H, driver function 9, read a sector, and fall into IOFUNC.
19F6IOFUNC
PUSH BC C5
Save Register Pair BC (the caller's value, Register C the drive) on the stack.
19F7
LD B,A 47
Copy Register A (the driver function) into Register B.
19F8
PUSH BC C5
Save Register Pair BC (Register B the function, Register C the drive) on the stack.
19F9
XOR A AF
Clear Register A to 00H, for the @BANK function and bank below.
19FA
LD B,A 47
Copy Register A into Register B: @BANK function 0, select a bank.
19FB
LD C,A 4F
Copy Register A into Register C: bank 0, the bank the system runs in.
19FC
Call @BANK at 0877H to bring bank 0 into the memory map; Register C returns the bank that was in use.
19FF
POP AF F1
Restore Register Pair AF from the stack: Register A = the function, the flags byte = the drive.
1A00
PUSH BC C5
Save Register Pair BC (the bank that was in use) on the stack.
1A01
PUSH AF F5
Save Register Pair AF (the function and the drive) on the stack.
1A02
POP BC C1
Restore Register Pair BC from the stack: Register B = the function, Register C = the drive.
1A03
LD A,C 79
Copy Register C (the drive) into Register A, to store it below.
1A04
LD (0023H),A 32 23 00LD (LDRV$),A
Store Register A (the drive) into 0023H (LDRV$).
1A07
PUSH IY FD E5
Save Index Register IY (the caller's value) on the stack.
1A09
Call @GTDCT at 1A1EH: Index Register IY = the drive code table entry of drive Register C.
1A0C
LD A,20H 3E 20
Load Register A with 20H, error 32, Illegal drive number, for a disabled drive.
1A0E
OR A B7
OR Register A with itself to set the NZ flag with the error.
1A0F
Call GODOIO at 1A1CH, which jumps to the entry's JP (or RET for a disabled drive).
1A12
POP IY FD E1
Restore Index Register IY (the caller's value) from the stack.
1A14
POP BC C1
Restore Register Pair BC from the stack: Register C = the bank that was in use.
1A15
PUSH AF F5
Save Register Pair AF (the result of the disk request) on the stack.
1A16
LD A,66H 3E 66
Load Register A with 66H, SVC 102, @BANK, to put the old bank back.
1A18
RST 28H EF
Issue RST 28H: @BANK function 0 (Register B = 00H) brings back the bank in Register C; it cannot fail here.
1A19
POP AF F1
Restore Register Pair AF (the result of the disk request) from the stack.
1A1A
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
1A1B
RET C9
Return with the driver's result: Z, or NZ with the error code in Register A.
1A1CGODOIO
JP (IY) FD E9
Jump to Index Register IY, the drive code table entry, whose first three bytes are a JP to the driver or a RET.

1A1EH - @GTDCT and the Drive Code Table Field Routines

The drive code table DCT$ at 0470H has ten bytes for each of drives 0 to 7. @GTDCT (SVC 81) points Index Register IY to the entry of drive Register C. DCTFLD@ works out the entry's address (0470H plus ten times the drive) and, with field number Register H, the low byte of the field's address. @DCTBYT returns field Register A of drive Register C; D@FBYT8 and DCTBYT8@ return field 8 (the granule layout) of the FCB's drive or of drive Register C.

1A1E@GTDCT
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1A1F
Call DCTFLD@ at 1A34H: Register Pair HL = the drive code table entry of drive Register C.
1A22
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the entry is on the stack and Register Pair HL is the caller's.
1A23
POP IY FD E1
Restore Index Register IY from the stack: Index Register IY = the drive code table entry.
1A25
RET C9
Return with Index Register IY at the entry of drive Register C.
1A26D@FBYT8
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the FCB's drive.
1A29DCTBYT8@
LD A,08H 3E 08
Load Register A with 08H, the field with the granules per track and the sectors per granule.
1A2B@DCTBYT
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1A2C
LD H,A 67
Copy Register A (the field number) into Register H, for DCTFLD@.
1A2D
Call DCTFLD@ at 1A34H: Register A = the low byte of the field's address, Register H = 04H.
1A30
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the field.
1A31
LD A,(HL) 7E
Load Register A with the field at Register Pair HL.
1A32
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
1A33
RET C9
Return with the drive code table byte in Register A.
1A34DCTFLD@
LD A,C 79
Copy Register C (the drive) into Register A.
1A35
AND 07H E6 07
Mask Register A with 07H, the drive number 0 to 7.
1A37
ADD A,A 87
Add Register A to itself: Register A = the drive times 2.
1A38
LD L,A 6F
Copy Register A (the drive times 2) into Register L.
1A39
ADD A,A 87
Add Register A to itself: Register A = the drive times 4.
1A3A
ADD A,A 87
Add Register A to itself: Register A = the drive times 8.
1A3B
ADD A,L 85
Add Register L (the drive times 2) to Register A: the drive times 10.
1A3C
ADD A,70H C6 70
Add 70H to Register A, the low byte of DCT$ (0470H): the low byte of the drive's entry.
1A3E
LD L,A 6F
Copy Register A into Register L, the low byte of the entry's address.
1A3F
ADD A,H 84
Add Register H (the field number) to Register A: the low byte of the field's address.
1A40
LD H,04H 26 04
Load Register H with 04H: Register Pair HL = the drive's entry in DCT$.
1A42
RET C9
Return with Register Pair HL at the entry and Register A at the field's low byte.

1A43H - RST28: The SVC Dispatcher

RST 28H jumps here (0028H). An SVC number below 128 (bit 7 clear) is a supervisor call: SVCUSER saves its number in LSVC$ and the return address in SVCRET$ (except for @ERROR), takes the routine's address from SVCTAB$ at 0100H plus twice the number, copies Register C into Register A and jumps there, so every SVC routine receives the caller's Register C in Register A. A number with bit 7 set is a request for a system overlay: RST28 drops the return address of the RST, turns the debugger hook off while the overlay runs, loads the overlay through CKMOD@ if it is not resident and calls it with the request in Register A.

1A43SVCUSER
CP 1AH FE 1A
Compare Register A (the SVC number) with 1AH, SVC 26, @ERROR.
1A45
If the SVC is @ERROR (Z), jump to 1A4FH (ERRSVC): the record of the failing SVC is kept.
1A47
LD (000DH),A 32 0D 00LD (LSVC$),A
Store Register A (the SVC number) into 000DH (LSVC$).
1A4A
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL = the return address after the caller's RST 28H.
1A4B
LD (000BH),HL 22 0B 00LD (SVCRET$),HL
Store Register Pair HL (the return address) into 000BH (SVCRET$).
1A4E
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack again (Stack Pointer): the return address is back and Register Pair HL is the caller's.
1A4FERRSVC
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack, to make room for the routine's address.
1A50
RLCA 07
Rotate Register A left: the SVC number times 2, the offset of its word in the table.
1A51
LD H,01H 26 01
Load Register H with 01H, the page of SVCTAB$ (0100H).
1A53
LD L,A 6F
Copy Register A (the offset) into Register L: Register Pair HL points to the SVC's word.
1A54
LD A,(HL) 7E
Load Register A with the low byte of the routine's address at Register Pair HL.
1A55
INC L 2C
Increment Register L to the high byte of the routine's address in the table.
1A56
LD H,(HL) 66
Load Register H with the high byte of the routine's address at Register Pair HL.
1A57
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the routine's address.
1A58
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the routine's address is on the stack and Register Pair HL is the caller's again.
1A59
LD A,C 79
Copy Register C into Register A: the routines expect the caller's Register C in Register A (a byte to @PUT, a code for @CTL, a multiplier).
1A5A
RET C9
Return, which jumps to the SVC routine; it returns straight to the caller.
1A5BRST28
OR A B7
OR Register A (the SVC number or overlay request) with itself, to test bit 7.
1A5C
If bit 7 is clear (P, a number below 128), jump to 1A43H (SVCUSER).
1A5F
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the RST's return address is taken off and the caller's Register Pair HL is saved in its place.
1A60
PUSH AF F5
Save Register Pair AF (the request) on the stack.
1A61
LD HL,199FH 21 9F 19LD HL,@DBGHK
Point Register Pair HL to 199FH (@DBGHK), the debugger hook.
1A64
LD A,(HL) 7E
Load Register A with the hook byte at Register Pair HL: C9H when the debugger is off, 00H when it is on.
1A65
LD (1A79H),A 32 79 1ALD (SET@EXEC),A
Store Register A into 1A79H, the operand of the LD A at 1A78H, to put the hook back afterwards.
1A68
LD (HL),0C9H 36 C9
Store C9H (RET) into the hook at Register Pair HL: the debugger does not stop inside the overlay.
1A6A
POP AF F1
Restore Register Pair AF (the request) from the stack.
1A6B
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
1A6CHKRES$
Call CKMOD@ at 1A7FH to load the overlay if it is not resident and set its entry address at 1A75H.
1A6F
LD A,00H 3E 00
Load Register A with the request, the operand at 1A70H stored by CKMOD@ at 1A98H (for SYS6, SYS7 and SYS8 it keeps the code of the overlay still at 1E00H).
1A71
LD (0069H),A 32 69 00LD (OVRLY$),A
Store Register A into 0069H (OVRLY$), the overlay now resident.
1A74TRANSFR
CALL 0000H CD 00 00
Call the overlay's entry, the operand at 1A75H stored by CKMOD@ at 1ADAH (1E00H for SYS1 to SYS5 and SYS9 to SYS13, the member's entry for a library); 0000H in the file.
1A77
PUSH AF F5
Save Register Pair AF (the overlay's result) on the stack.
1A78
LD A,00H 3E 00
Load Register A with the saved debugger hook byte, the operand at 1A79H stored at 1A65H.
1A7A
LD (199FH),A 32 9F 19LD (@DBGHK),A
Store Register A back into 199FH (@DBGHK): the debugger is on again if it was before.
1A7D
POP AF F1
Restore Register Pair AF (the overlay's result) from the stack.
1A7E
RET C9
Return to the program that issued the SVC, with the overlay's result.

1A7FH - CKMOD@: Load a System Overlay

CKMOD@ makes sure the overlay named by the request in Register A is in memory. SYS1 to SYS5 and SYS9 to SYS13 run at 1E00H; if OVRLY$ shows the overlay is already there nothing is read. A request 88H, 89H or 8AH (SYS6, SYS7 or SYS8 with function 0, the libraries, loaded at 2400H) is always read, with Register B naming the library member. The overlay's directory entry code is the overlay number (2 to 7 for SYS0 to SYS5) or the number plus 18H (20H to 27H for SYS6 to SYS13). The entry is read on drive 0 and must be a system file in use; its first two extents go into SFCB$ (008CH) and LOADER reads the file. An error goes to SYSERR.

1A7FCKMOD@
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1A80
LD H,A 67
Copy Register A (the request) into Register H.
1A81
LD A,B 78
Copy Register B (the library member, for SYS6 to SYS8) into Register A.
1A82
LD (1AD2H),A 32 D2 1A
Store Register A into 1AD2H, the operand of the LD B at EXOVR2, the member for LOADER.
1A85
LD A,H 7C
Copy Register H (the request) into Register A.
1A86
OR 01H F6 01
OR 01H into Register A, so that 88H and 89H both become 89H.
1A88
CP 89H FE 89
Compare Register A with 89H: Z for a request to SYS6 (88H) or SYS7 (89H) with function 0.
1A8A
LD A,H 7C
Copy Register H (the request) back into Register A (the flags are kept).
1A8B
If the request is for SYS6 or SYS7 (Z), jump to 1AA0H (EXOVR) to read the library.
1A8D
CP 8AH FE 8A
Compare Register A with 8AH, a request to SYS8.
1A8F
If the request is for SYS8 (Z), jump to 1AA0H (EXOVR) to read the library.
1A91
LD A,(0069H) 3A 69 00LD A,(OVRLY$)
Load Register A with 0069H (OVRLY$), the overlay resident at 1E00H.
1A94
XOR H AC
Exclusive OR Register H (the request) into Register A.
1A95
AND 0FH E6 0F
Mask Register A with 0FH: zero when the resident overlay is the one requested.
1A97
LD A,H 7C
Copy Register H (the request) into Register A (the flags are kept).
1A98
LD (1A70H),A 32 70 1ALD (OVRLYOLD),A
Store Register A into 1A70H, the operand of the LD A at 1A6FH: the new value of OVRLY$.
1A9B
LD HL,1E00H 21 00 1ELD HL,OVERLAY
Load Register Pair HL with 1E00H, the entry of the overlays that run at 1E00H.
1A9E
If the overlay is already resident (Z), jump to 1ADAH (EXOVR3) to use the entry at 1E00H.
1AA0EXOVR
PUSH DE D5
Save Register Pair DE (the caller's value) on the stack.
1AA1
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack.
1AA2
AND 0FH E6 0F
Mask Register A with 0FH, the overlay number (2 to 15).
1AA4
BIT 3,A CB 5F
Test bit 3 of Register A: set for SYS6 to SYS13 (8 to 15).
1AA6
If bit 3 is clear (SYS0 to SYS5), jump to 1AAAH (EXOVR1): the number is the DEC.
1AA8
ADD A,18H C6 18
Add 18H to Register A: overlays 8 to 15 have DECs 20H to 27H.
1AAAEXOVR1
LD (0093H),A 32 93 00
Store Register A (the DEC) into 0093H, SFCB$+7, the system FCB's directory entry code.
1AAD
LD B,A 47
Copy Register A (the DEC) into Register B, for the directory read.
1AAE
LD A,20H 3E 20
Load Register A with 20H, bit 5 of FCB+1: the buffer does not hold the current sector.
1AB0
LD (008DH),A 32 8D 00
Store Register A into 008DH, SFCB$+1, the system FCB's status byte, so the first read fetches a sector.
1AB3
SBC HL,HL ED 62
Subtract Register Pair HL and the Carry flag (clear here) from Register Pair HL: Register Pair HL = 0000H.
1AB5
LD (0096H),HL 22 96 00
Store Register Pair HL (0000H) into 0096H-0097H, SFCB$+10, the NRN: read from the start.
1AB8
LD C,H 4C
Copy Register H (00H) into Register C: drive 0, where the system files are.
1AB9
Call @DIRRD at 18BBH to read the directory entry Register B of drive 0; Register Pair HL points to it.
1ABC
If the read failed (NZ), jump to 1AD8H (EXERR) with the error code in Register A.
1ABE
LD A,(HL) 7E
Load Register A with the entry's attribute byte at Register Pair HL.
1ABF
AND 50H E6 50
Mask Register A with 50H, keeping bit 6 (system file) and bit 4 (in use).
1AC1
XOR 50H EE 50
Exclusive OR 50H into Register A: zero only when both bits are set.
1AC3
LD A,07H 3E 07
Load Register A with 07H, error 7, the code for a missing or purged overlay (the flags are kept).
1AC5
If the entry is not an active system file (NZ), jump to 1AD8H (EXERR) with error 7.
1AC7
LD A,L 7D
Copy Register L (the entry's offset) into Register A.
1AC8
ADD A,16H C6 16
Add 16H to Register A, the offset of the entry's first extent field.
1ACA
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the first extent.
1ACB
LD DE,009AH 11 9A 00
Point Register Pair DE to 009AH, SFCB$+14, the extent fields of the system FCB.
1ACE
Call PAT1 at 1AE1H to copy the first extent, its granule count and the second extent into SFCB$+14 to +19.
1AD1EXOVR2
LD B,00H 06 00
Load Register B with the library member, the operand at 1AD2H stored at 1A82H (00H for an overlay that is not a library).
1AD3
LD E,8CH 1E 8C
Load Register E with 8CH: Register Pair DE = 008CH (SFCB$), the system FCB.
1AD5
Call LOADER at 1B56H to read the overlay through the FCB at Register Pair DE; Register Pair HL returns its transfer address.
1AD8EXERR
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
1AD9
POP DE D1
Restore Register Pair DE (the caller's value) from the stack.
1ADAEXOVR3
LD (1A75H),HL 22 75 1A
Store Register Pair HL (the overlay's entry) into 1A75H, the operand of the CALL at TRANSFR.
1ADD
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
1ADE
RET Z C8
Return Z when the overlay is ready, its entry set at 1A75H.
1ADF
Jump to 1AF7H (SYSERR) to report the error in Register A: the system cannot go on without its overlay.
1AE1PAT1
Call PAT1A at 1AECH to copy the two bytes of the first extent from Register Pair HL to Register Pair DE.
1AE4
AND 1FH E6 1F
Mask Register A (the extent's allocation byte) with 1FH, the granules less one.
1AE6
INC A 3C
Increment Register A: the granules in the first extent.
1AE7
LD (DE),A 12
Store Register A at Register Pair DE (SFCB$+16), the granules before the second extent, low byte.
1AE8
INC DE 13
Increment Register Pair DE to SFCB$+17, the high byte of the count.
1AE9
XOR A AF
Clear Register A to 00H, the high byte of the count.
1AEA
LD (DE),A 12
Store Register A (00H) at Register Pair DE (SFCB$+17).
1AEB
INC DE 13
Increment Register Pair DE to SFCB$+18, and fall into PAT1A to copy the second extent there.
1AECPAT1A
Call PAT1B at 1AEFH to copy one byte, then fall into PAT1B for the second.
1AEFPAT1B
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, part of a directory extent.
1AF0
LD (DE),A 12
Store Register A at Register Pair DE, in the system FCB.
1AF1
INC HL 23
Increment Register Pair HL to the next byte of the directory entry.
1AF2
INC DE 13
Increment Register Pair DE to the next byte of the FCB.
1AF3
RET C9
Return with the last byte copied in Register A.

1AF4H - SVCERR, SYSERR, @ABORT, @EXIT and @ERROR

SVCERR serves the unassigned SVC numbers with error 43. SYSERR shows and logs Error xxH for an error the system cannot recover from, resets the stack and aborts. @ABORT (SVC 21) and @EXIT (SVC 22) return to the system through SYS1, @ABORT with the return code FFFFH. @ERROR (SVC 26) shows the message of the error code in Register C (in Register A after the dispatcher) through SYS4.

1AF4SVCERR
LD A,2BH 3E 2B
Load Register A with 2BH, error 43, SVC parameter error.
1AF6
NOP 00
No operation (a spare byte); the code falls into SYSERR with error 43.
1AF7SYSERR
AND 3FH E6 3F
Mask Register A with 3FH, keeping the error number and dropping the flag bits 7 and 6.
1AF9
LD HL,1B19H 21 19 1BLD HL,ERRNUM
Point Register Pair HL to 1B19H (ERRNUM), the xx of the message.
1AFC
Call @HEX8 at 07C2H to write Register A as two hex digits at Register Pair HL.
1AFF
LD HL,1B13H 21 13 1BLD HL,SYSERR$
Point Register Pair HL to 1B13H (SYSERR$), the message Error xxH.
1B02
Call @LOGOT at 0500H to show the message at Register Pair HL and log it.
1B05
LD SP,0380H 31 80 03LD SP,STACK$
Load the Stack Pointer with 0380H (STACK$): the system stack is reset, dropping whatever the failed request left on it.
1B08@ABORT
LD HL,0FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the return code of an aborted program, and fall into @EXIT.
1B0B@EXIT
LD A,93H 3E 93
Load Register A with 93H: overlay 3 (SYS1), function 1, the return to the system.
1B0D
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS1; it does not come back.
1B0EPOPERR
POP HL E1
Restore Register Pair HL from the stack, dropping the transfer address @RUN put there, and fall into @ERROR.
1B0F@ERROR
PUSH AF F5
Save Register Pair AF (Register A, the error code) on the stack for SYS4.
1B10
LD A,96H 3E 96
Load Register A with 96H: overlay 6 (SYS4), function 1, show an error message.
1B12
RST 28H EF
Issue RST 28H to RST28 at 1A5BH, which runs the request in Register A in SYS4.
1B13-1B18SYSERR$
DEFM "Error " 45 72 72 6F 72 20
SYSERR$, 1B13H-1B18H: the text Error and a space, the start of the message SYSERR shows. RST28 does not return to 1B13H, so these bytes are only data.
1B19-1B1CERRNUM
DEFM "xxH" / DEFB 0DH 78 78 48 0D
ERRNUM, 1B19H-1B1CH: two hex digits (xx in the file, written by SYSERR at 1AFCH), the letter H and 0DH (ENTER), which ends the message.

1B1DH - @RUN and @LOAD: Load a Program

@LOAD (SVC 76) opens the program file whose FCB is at Register Pair DE with the system buffer SBUFF$ (1D00H) and reads its load records into memory; it returns Register Pair HL = the transfer address. Its errors return with bits 7 and 6 set (return to the caller and short message), and File not in directory becomes Program not found. @RUN (SVC 77) loads the program and jumps to it with Register Pair BC pointing to the command line, through the debugger when SFLAG$ bit 7 asks for it.

1B1D@RUN
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1B1E
LD HL,007CH 21 7C 00LD HL,SFLAG$
Point Register Pair HL to 007CH (SFLAG$), the system flags.
1B21
SET 2,(HL) CB D6
Set bit 2 of SFLAG$ at Register Pair HL: @RUN may load a file with EXECUTE access only.
1B23
Call @LOAD at 1B38H to load the program: Register Pair HL returns its transfer address.
1B26
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the transfer address is on the stack and Register Pair HL is the caller's value again.
1B27
If the load failed (NZ), jump to 1B0EH (POPERR) to drop the address and show the error.
1B29
LD BC,0420H 01 20 04LD BC,INBUF$
Point Register Pair BC to 0420H (INBUF$), the command line, for the program.
1B2C
LD A,(007CH) 3A 7C 00LD A,(SFLAG$)
Load Register A with 007CH (SFLAG$), the system flags.
1B2F
BIT 1,A CB 4F
Test bit 1 of Register A, set when the file opened has EXECUTE access only.
1B31
RET NZ C0
If so (NZ), return into the program at the transfer address: the debugger may not see it.
1B32
BIT 7,A CB 7F
Test bit 7 of Register A, set when the debugger is to run after the load.
1B34
If bit 7 is set (NZ), jump to 0030H (@RST30), the debugger, with the program's transfer address as its return address.
1B37
RET C9
Return into the program at the transfer address on the stack.
1B38@LOAD
LD B,00H 06 00
Load Register B with 00H, the logical record length for the open: 256.
1B3A
LD HL,007CH 21 7C 00LD HL,SFLAG$
Point Register Pair HL to 007CH (SFLAG$), the system flags.
1B3D
SET 0,(HL) CB C6
Set bit 0 of SFLAG$ at Register Pair HL: the open does not set the file's open bit in the directory.
1B3F
LD HL,1D00H 21 00 1DLD HL,SBUFF$
Point Register Pair HL to 1D00H (SBUFF$), the buffer for the open.
1B42
Call @OPEN at 198AH to open the file whose FCB is at Register Pair DE.
1B45
PUSH DE D5
Save Register Pair DE (the FCB) on the stack.
1B46
If the open worked (Z), call LOADER at 1B56H to read the file's load records (Register B = 00H, not a library member).
1B49
POP DE D1
Restore Register Pair DE (the FCB) from the stack.
1B4A
RET Z C8
Return Z with the transfer address in Register Pair HL if the program loaded.
1B4B
LD L,A 6F
Copy Register A (the error code) into Register L.
1B4C
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the error code, for a return code.
1B4E
OR 0C0H F6 C0
OR C0H into Register A: bit 7 (return to the caller) and bit 6 (short message) for @ERROR.
1B50
CP 0D8H FE D8
Compare Register A with D8H, error 24 (File not in directory) with both bits.
1B52
RET NZ C0
Return with the error in Register A and NZ if it is any other error.
1B53
ADD A,07H C6 07
Add 07H to Register A: DFH, error 31, Program not found, with both bits.
1B55
RET C9
Return with the error in Register A and NZ (the ADD leaves it non zero).

1B56H - LOADER: Read the Load Records of a File

LOADER reads the file of the FCB at Register Pair DE through the buffer at 1D00H, one byte at a time with LDR15, and acts on each record: 01H a load block (length, address, bytes), 02H the transfer address (which ends the load), 04H the end of a library member, 08H a library member header, 0AH the end of the member headers (the member was not found, error 34), any other type below 20H skipped with its length, and 20H or above error 34, Load file format error. For a library, Register B names the member: its header gives the transfer address, the record number and the offset where the member starts, and LOADER positions the file there and reads on.

1B56LOADER
LD A,B 78
Copy Register B (the library member, or 00H) into Register A.
1B57
LD (1BB3H),A 32 B3 1B
Store Register A into 1BB3H, the operand of the CP at LDR14.
1B5A
PUSH DE D5
Save Register Pair DE (the FCB) on the stack.
1B5B
EX (SP),IX DD E3
Exchange Index Register IX with the top of the stack (Stack Pointer): Index Register IX = the FCB, and the caller's Index Register IX is saved.
1B5D
LD DE,1DFFH 11 FF 1D
Point Register Pair DE to 1DFFH, the last byte of the buffer, so the first byte fetched reads a sector.
1B60
Call LDR01 at 1B6FH to read the records until the transfer address or an error.
1B63
POP IX DD E1
Restore Index Register IX (the caller's value) from the stack.
1B65
RET C9
Return with Register Pair HL = the transfer address and Z, or NZ with the error code in Register A.
1B66LDR05
Call LDR15 at 1BD6H to fetch the length byte of a record that is skipped.
1B69
LD B,A 47
Copy Register A (the length) into Register B.
1B6ALDR06
Call LDR15 at 1BD6H to fetch the next byte of the skipped record, and drop it.
1B6D
Decrement Register B and loop back to 1B6AH (LDR06) until the record is skipped.
1B6FLDR01
Call LDR15 at 1BD6H to fetch the record type into Register A.
1B72LDR02
CP 01H FE 01
Compare Register A with 01H, a load block.
1B74
If it is a load block (Z), jump to 1B95H (LDR08).
1B76
CP 02H FE 02
Compare Register A with 02H, the transfer address.
1B78LDR03
If it is the transfer address (Z), jump to 1B8EH (LDR07).
1B7A
CP 04H FE 04
Compare Register A with 04H, the end of a library member.
1B7C
If it is the end of a member (Z), jump to 1BA8H (LDR12).
1B7E
CP 08H FE 08
Compare Register A with 08H, a library member header.
1B80
If it is a member header (Z), jump to 1BAAH (LDR13).
1B82
CP 0AH FE 0A
Compare Register A with 0AH, the end of the member headers.
1B84
If the headers end without the member wanted (Z), jump to 1B8AH (LDR04) for error 34.
1B86
CP 20H FE 20
Compare Register A with 20H, the first type that is not a control record.
1B88
If the type is below 20H (Carry), jump to 1B66H (LDR05) to skip the record.
1B8ALDR04
LD A,22H 3E 22
Load Register A with 22H, error 34, Load file format error.
1B8C
OR A B7
OR Register A with itself to set the NZ flag.
1B8D
RET C9
Return with error 34, Load file format error, in Register A and NZ.
1B8ELDR07
Call LDR15 at 1BD6H to fetch the record's length byte (02H) and drop it.
1B91
Call GETADR at 1BE8H: Register Pair HL = the transfer address.
1B94
RET C9
Return with the transfer address in Register Pair HL, Z from GETADR (NZ only on a read error).
1B95LDR08
Call LDR15 at 1BD6H to fetch the block's length byte, the address and data bytes that follow.
1B98
LD B,A 47
Copy Register A (the length) into Register B.
1B99
Call GETADR at 1BE8H: Register Pair HL = the address where the block loads.
1B9C
RET NZ C0
Return if the address could not be read, NZ with the error code in Register A.
1B9D
DEC B 05
Decrement Register B, for the low byte of the address.
1B9E
DEC B 05
Decrement Register B, for the high byte: Register B = the data bytes (a length of 0, 1 or 2 gives 254, 255 or 256).
1B9FLDR09
Call LDR15 at 1BD6H to fetch the next data byte of the block.
1BA2
LD (HL),A 77
Store Register A (the data byte) at Register Pair HL, its place in memory.
1BA3
INC HL 23
Increment Register Pair HL to the next address.
1BA4
Decrement Register B and loop back to 1B9FH (LDR09) until the block is loaded.
1BA6
Jump back to 1B6FH (LDR01) for the next record.
1BA8LDR12
POP HL E1
Restore Register Pair HL from the stack: the member's transfer address saved at 1BB9H.
1BA9
RET C9
Return to LOADER with the member's transfer address in Register Pair HL and Z.
1BAALDR13
Call LDR15 at 1BD6H to fetch the length of the member header.
1BAD
LD B,A 47
Copy Register A (the length) into Register B.
1BAE
Call LDR15 at 1BD6H to fetch the header's member number (the request code of its command).
1BB1
DEC B 05
Decrement Register B: the byte just read is counted.
1BB2LDR14
CP 00H FE 00
Compare Register A with the member wanted, the operand at 1BB3H stored at 1B57H.
1BB4
If this header is for another member (NZ), jump to 1B6AH (LDR06) to skip the rest of it.
1BB6
Call GETADR at 1BE8H: Register Pair HL = the member's transfer address.
1BB9
PUSH HL E5
Save Register Pair HL (the member's transfer address) on the stack, for LDR12.
1BBA
If the first GETADR worked (Z), call GETADR at 1BE8H again: Register Pair HL = the record number where the member starts. After a read error (NZ, back from LODERR) the call is skipped and the JR NZ below goes to LODERR.
1BBD
If the read failed (NZ), jump to 1BE6H (LODERR).
1BBF
Call LDR15 at 1BD6H to fetch the offset of the member in that record.
1BC2
LD E,A 5F
Copy Register A (the offset) into Register E: the buffer pointer will point there.
1BC3
PUSH BC C5
Save Register Pair BC (Register B, the bytes left of the header) on the stack.
1BC4
LD B,H 44
Copy Register H (the high byte of the record number) into Register B.
1BC5
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the record number of the member.
1BC6
PUSH DE D5
Save Register Pair DE (the buffer pointer) on the stack.
1BC7
PUSH IX DD E5
Save Index Register IX (the FCB) on the stack.
1BC9
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the FCB.
1BCA
Call @POSN at 1434H to position the file at record Register Pair BC.
1BCD
POP DE D1
Restore Register Pair DE (the buffer pointer) from the stack.
1BCE
POP BC C1
Restore Register Pair BC (the bytes left of the header) from the stack.
1BCF
If the position failed (NZ), jump to 1BE6H (LODERR).
1BD1
Call LDR17 at 1BDBH to read that sector and fetch the byte at the member's offset, its first record type.
1BD4
Jump back to 1B72H (LDR02) to act on the member's first record.
1BD6LDR15
INC E 1C
Increment Register E, the offset in the buffer.
1BD7
If Register E wrapped to 00H (Z), the buffer is used up: jump to 1BDBH (LDR17) to read the next sector.
1BD9LDR16
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE in the buffer.
1BDA
RET C9
Return with the byte fetched from the buffer in Register A.
1BDBLDR17
PUSH HL E5
Save Register Pair HL (the caller's value) on the stack.
1BDC
PUSH DE D5
Save Register Pair DE (the buffer pointer) on the stack.
1BDD
PUSH BC C5
Save Register Pair BC (the caller's value) on the stack.
1BDE
Call NXTSECT at 1375H to read the next sector of the file into its buffer.
1BE1
POP BC C1
Restore Register Pair BC (the caller's value) from the stack.
1BE2
POP DE D1
Restore Register Pair DE (the buffer pointer) from the stack.
1BE3
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
1BE4
If the sector was read (Z), jump to 1BD9H (LDR16) to fetch the byte.
1BE6LODERR
POP BC C1
Restore Register Pair BC from the stack, dropping one return address: the routine that wanted the byte returns at once with the error.
1BE7
RET C9
Return NZ with the error code of the read in Register A, one level up.
1BE8GETADR
Call LDR15 at 1BD6H to fetch the low byte of an address.
1BEB
LD L,A 6F
Copy Register A (the low byte of the address) into Register L.
1BEC
Call LDR15 at 1BD6H to fetch the high byte of the address.
1BEF
LD H,A 67
Copy Register A into Register H: Register Pair HL = the address.
1BF0
CP A BF
Compare Register A with itself: set the Z flag.
1BF1
RET C9
Return with the address in Register Pair HL and Z.

1BF2H - @IPL: Restart the Machine

@IPL (SVC 0) copies the five byte stub BOOTCOD (03FBH-03FFH) to 4300H and jumps there; the stub selects the Model III memory map with the ROM at 0000H and restarts through RST 00H.

1BF2@IPL
LD HL,03FBH 21 FB 03LD HL,BOOTCOD
Point Register Pair HL to 03FBH (BOOTCOD), the restart stub.
1BF5
LD DE,4300H 11 00 43LD DE,MOD3BUF
Point Register Pair DE to 4300H, where the stub runs, out of the way of the ROM that it maps in at 0000H.
1BF8
PUSH DE D5
Save Register Pair DE (4300H) on the stack as the return address, so the RET below jumps to the stub.
1BF9
LD BC,0005H 01 05 00LD BC,BOOTLEN
Load Register Pair BC with 0005H, the length of the stub.
1BFC
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE: the stub is now at 4300H-4304H.
1BFE
RET C9
Return, which jumps to the stub at 4300H, the address pushed at 1BF8H.

1BFFH - RST38@: The Interrupt Handler and Task Processor

RST 38H (interrupt mode 1) comes here through the JP 1BFFH that SYS0/SYS loads at 0038H. The handler saves the interrupted program counter in PCSAVE$ (07AFH) for SYSTEM (TRACE), marks the task processor active in NFLAG$, switches to logical bank 0 and to the all RAM memory map with bank 0 (Operation Register bits 6-4 cleared, bits 1-0 = 11), reads the interrupt latch from port E0H (active low on the Model 4, so it is inverted) and calls the vector in INTVC$ (003EH) of each latched bit that INTMSK$ allows, with Register Pairs AF, BC, DE and HL and Index Register IX saved (not Index Register IY or the alternate set). It then checks the keyboard for BREAK, restores the memory map and the bank and returns.

1BFFRST38@
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL = the interrupted program counter.
1C00
LD (07AFH),HL 22 AF 07LD (PCSAVE$),HL
Store Register Pair HL (the interrupted program counter) into 07AFH (PCSAVE$), which the TRACE task shows and the BREAK check tests.
1C03
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack again (Stack Pointer): the return address is back and Register Pair HL is the program's.
1C04
PUSH HL E5
Save Register Pair HL (the program's value) on the stack.
1C05
PUSH AF F5
Save Register Pair AF (the program's value) on the stack.
1C06
LD HL,0077H 21 77 00LD HL,NFLAG$
Point Register Pair HL to 0077H (NFLAG$), the network flag.
1C09
SET 6,(HL) CB F6
Set bit 6 of NFLAG$ at Register Pair HL: the task processor is running.
1C0B
LD HL,0202H 21 02 02LD HL,LBANK$
Point Register Pair HL to 0202H (LBANK$), the logical bank in use.
1C0E
LD A,(HL) 7E
Load Register A with the logical bank at Register Pair HL.
1C0F
LD (HL),00H 36 00
Store 00H into LBANK$ at Register Pair HL: the interrupt code runs in logical bank 0.
1C11
PUSH AF F5
Save Register Pair AF (Register A, the program's logical bank) on the stack.
1C12
LD HL,0078H 21 78 00LD HL,OPREG$
Point Register Pair HL to 0078H (OPREG$), the copy of the Operation Register.
1C15
LD A,(HL) 7E
Load Register A with the program's memory configuration at Register Pair HL.
1C16
PUSH AF F5
Save Register Pair AF (Register A, the program's configuration) on the stack.
1C17
AND 8CH E6 8C
Mask Register A with 8CH, keeping bits 7, 3 and 2 (the video page, inverse video and the 80 by 24 display) and clearing the memory map and bank bits.
1C19
OR 03H F6 03
OR 03H into Register A: bits 1-0 = 11, RAM at every address, with bank 0 in the upper 32K.
1C1B
LD (HL),A 77
Store Register A (the new configuration) into OPREG$ at Register Pair HL.
1C1C
OUT (84H),A D3 84
Send Register A to port 84H, the Operation Register: the regular 64K of memory is mapped in.
1C1E
IN A,(0E0H) DB E0
Read port E0H, the interrupt latch, into Register A: on the Model 4 a 0 bit is a device asking for service.
1C20
CPL 2F
Complement Register A, so a set bit is a device asking for service.
1C21
LD HL,003CH 21 3C 00LD HL,INTIM$
Point Register Pair HL to 003CH (INTIM$), the interrupt image.
1C24
LD (HL),A 77
Store Register A (the latched interrupts) into INTIM$ at Register Pair HL.
1C25
INC L 2C
Increment Register L to 003DH (INTMSK$), the mask of the interrupts the task processor serves.
1C26
AND (HL) A6
AND INTMSK$ at Register Pair HL into Register A: only the served interrupts are left.
1C27
If no served device asked (Z), jump to 1C31H (TSTBRK).
1C29NXTVCT
INC L 2C
Increment Register L to the low byte of the next vector in INTVC$ (003EH for bit 0, then 0040H and on).
1C2A
RRA 1F
Rotate Register A right: the next latch bit goes into the Carry flag.
1C2B
If that device interrupted (Carry), jump to 1C49H (ACTVTSK) to call its vector at Register Pair HL.
1C2DNXTMSK
INC L 2C
Increment Register L to the high byte of the vector just passed.
1C2E
OR A B7
OR Register A with itself: Z when no latched bit is left.
1C2F
If bits are left (NZ), loop back to 1C29H (NXTVCT).
1C31TSTBRK
Call KCK@ at 07D6H to check the BREAK, pause and ENTER keys: NZ when BREAK is down, with Carry when SHIFT is down too.
1C34
If BREAK was found (NZ), jump to 1C60H (BREAK?).
1C36TSKEXIT
POP AF F1
Restore Register Pair AF from the stack: Register A = the program's memory configuration.
1C37
LD (0078H),A 32 78 00LD (OPREG$),A
Store Register A (the program's configuration) back into 0078H (OPREG$).
1C3A
OUT (84H),A D3 84
Send Register A to port 84H, the Operation Register: the program's memory map is back.
1C3C
POP AF F1
Restore Register Pair AF from the stack: Register A = the program's logical bank.
1C3D
LD (0202H),A 32 02 02LD (LBANK$),A
Store Register A (the program's logical bank) back into 0202H (LBANK$).
1C40
LD HL,0077H 21 77 00LD HL,NFLAG$
Point Register Pair HL to 0077H (NFLAG$), the network flag.
1C43
RES 6,(HL) CB B6
Reset bit 6 of NFLAG$ at Register Pair HL: the task processor is no longer running.
1C45
POP AF F1
Restore Register Pair AF (the program's value) from the stack.
1C46
POP HL E1
Restore Register Pair HL (the program's value) from the stack.
1C47
EI FB
Enable interrupts again for the program, which goes on where it was stopped.
1C48RETINST
RET C9
Return to the interrupted program. INTVC$ points the vectors of unused interrupts to this RET.
1C49ACTVTSK
PUSH AF F5
Save Register Pair AF (Register A, the latch bits still to serve) on the stack.
1C4A
PUSH BC C5
Save Register Pair BC on the stack, for the device routine to use.
1C4B
PUSH DE D5
Save Register Pair DE on the stack, for the device routine to use.
1C4C
PUSH HL E5
Save Register Pair HL (the position in INTVC$) on the stack.
1C4D
PUSH IX DD E5
Save Index Register IX on the stack, for the device routine to use.
1C4F
LD DE,1C58H 11 58 1CLD DE,POPREGS
Point Register Pair DE to 1C58H (POPREGS), where the device routine returns.
1C52
PUSH DE D5
Save Register Pair DE (1C58H) on the stack as the device routine's return address.
1C53
LD E,(HL) 5E
Load Register E with the low byte of the vector at Register Pair HL.
1C54
INC L 2C
Increment Register L to the high byte of the vector.
1C55
LD D,(HL) 56
Load Register D with the high byte of the vector at Register Pair HL: Register Pair DE = the device routine.
1C56
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the device routine.
1C57
JP (HL) E9
Jump to Register Pair HL, the device routine of this interrupt.
1C58POPREGS
POP IX DD E1
Restore Index Register IX from the stack.
1C5A
POP HL E1
Restore Register Pair HL (the position in INTVC$) from the stack.
1C5B
POP DE D1
Restore Register Pair DE (saved at 1C4BH) from the stack.
1C5C
POP BC C1
Restore Register Pair BC (saved at 1C4AH) from the stack.
1C5D
POP AF F1
Restore Register Pair AF (Register A, the latch bits still to serve) from the stack.
1C5E
Jump back to 1C2DH (NXTMSK) to look at the next latch bit.
1C60BREAK?
If SHIFT was not down (No Carry), jump to 1C6AH (GOTBRK): plain BREAK.
1C62
PUSH BC C5
Save Register Pair BC on the stack: SHIFT BREAK was pressed.
1C63
DI F3
Disable interrupts while the drive is reselected.
1C64
Call TAPDRV at 19B8H to reselect the drive of the last disk request (LDRV$).
1C67
POP BC C1
Restore Register Pair BC (saved at 1C62H) from the stack.
1C68
Jump to 1C36H (TSKEXIT) to return to the program.
1C6AGOTBRK
LD A,(007CH) 3A 7C 00LD A,(SFLAG$)
Load Register A with 007CH (SFLAG$), the system flags.
1C6D
AND 10H E6 10
Mask Register A with 10H, bit 4, set when BREAK is disabled.
1C6F
If BREAK is disabled (NZ), jump to 1C36H (TSKEXIT): neither the debugger nor a BREAK vector is entered.
1C71
LD HL,199FH 21 9F 19LD HL,@DBGHK
Point Register Pair HL to 199FH (@DBGHK), the debugger hook.
1C74
OR (HL) B6
OR the hook byte at Register Pair HL into Register A (00H): Z when the hook is 00H, the debugger is on.
1C75
LD (HL),0C9H 36 C9
Store C9H (RET) into the hook at Register Pair HL, turning the debugger hook off.
1C77
INC HL 23
Increment Register Pair HL to 19A0H (@DEBUG).
1C78
If the debugger is on (Z), jump to 1C8EH (EXITBRK) to enter it at Register Pair HL.
1C7A
LD A,(07B0H) 3A B0 07
Load Register A with 07B0H, the high byte of PCSAVE$, the interrupted program counter.
1C7D
CP 24H FE 24
Compare Register A with 24H: Carry when the program counter is below 2400H, in the resident system or an overlay.
1C7F
If the system was interrupted (Carry), jump to 1C36H (TSKEXIT): BREAK is not passed to a vector there.
1C81
LD HL,040FH 21 0F 04
Point Register Pair HL to 040FH, the high byte of HIGH$ (040EH).
1C84
CP (HL) BE
Compare Register A (the program counter's high byte) with the high byte of HIGH$ at Register Pair HL.
1C85
If the program counter is at or above HIGH$ (No Carry), jump to 1C36H (TSKEXIT): a driver or filter in high memory was interrupted.
1C87
LD HL,0000H 21 00 00
Load Register Pair HL with the BREAK vector, the operand at 1C88H (BRKVEC$) set by @BREAK; 0000H in the file.
1C8A
LD A,H 7C
Copy Register H into Register A, to test the vector for zero.
1C8B
OR L B5
OR Register L into Register A: Z when no BREAK vector is set.
1C8C
If there is no vector (Z), jump to 1C36H (TSKEXIT).
1C8EEXITBRK
POP AF F1
Restore Register Pair AF from the stack, dropping the saved memory configuration: the all RAM map of bank 0 stays. Bug T7: the saved configuration is not sent back to port 84H, LBANK$ is not restored and NFLAG$ bit 6 stays set. The same instructions stand in LS-DOS 6.3.1, where Part 13 numbers it B5.
1C8F
POP AF F1
Restore Register Pair AF from the stack, dropping the saved logical bank: LBANK$ stays 0.
1C90
POP AF F1
Restore Register Pair AF (the program's value) from the stack.
1C91
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL is the program's value again and the stack holds the vector.
1C92
EI FB
Enable interrupts, since the RET below does not go back through TSKEXIT.
1C93
RET C9
Return, which jumps to the debugger or the BREAK vector with the interrupted program counter as its return address.

1C94H - RTCPROC and RTCTASK: The Clock Interrupt and the Tasks

RTCPROC is the vector of interrupt bit 2, the real time clock. On every clock interrupt it runs task 11. When the bit rotated out of TIMSL$ is 1 (every second interrupt with 55H) it also runs tasks 8, 9 and 10, counts TIMER$, runs one of tasks 0 to 7 picked by the low three bits of TIMER$, and then the clock and cursor task TIMTSK$ (0713H), whose address it puts on the stack as the return address of the last task. RTCTASK runs the task of slot Register A: the slot in TCB$ (004EH) holds the address of the task's control block, the first word of the control block is the task's entry, and the task gets Index Register IX = its control block. RTCTASK stores the slot's address at 1CECH, for @RPTSK and @KLTSK.

1C94RTCPROC
IN A,(0ECH) DB EC
Read port ECH into Register A: reading it clears the real time clock interrupt.
1C96
LD A,0BH 3E 0B
Load Register A with 0BH, task slot 11, run on every clock interrupt.
1C98
Call RTCTASK at 1CBBH to run the task of slot 11.
1C9B
LD HL,002BH 21 2B 00LD HL,TIMSL$
Point Register Pair HL to 002BH (TIMSL$), the time slice pattern.
1C9E
RLC (HL) CB 06
Rotate TIMSL$ at Register Pair HL left: its top bit comes out in the Carry flag and goes round to bit 0.
1CA0
RET NC D0
Return to the interrupt handler if the bit was 0 (No Carry): nothing more on this interrupt.
1CA1
LD DE,0713H 11 13 07LD DE,TIMTSK$
Point Register Pair DE to 0713H (TIMTSK$), the clock and cursor task in BOOT/SYS.
1CA4
PUSH DE D5
Save Register Pair DE (0713H) on the stack: the last task below returns into TIMTSK$.
1CA5
LD A,08H 3E 08
Load Register A with 08H, task slot 8, run on every clock tick.
1CA7
Call RTCTASK at 1CBBH to run the task of slot 8.
1CAA
LD A,09H 3E 09
Load Register A with 09H, task slot 9, run on every clock tick.
1CAC
Call RTCTASK at 1CBBH to run the task of slot 9.
1CAF
LD A,0AH 3E 0A
Load Register A with 0AH, task slot 10 (TYPTSK$, the type-ahead task).
1CB1
Call RTCTASK at 1CBBH to run the task of slot 10.
1CB4
LD HL,002CH 21 2C 00LD HL,TIMER$
Point Register Pair HL to 002CH (TIMER$), the heartbeat counter.
1CB7
INC (HL) 34
Increment TIMER$ at Register Pair HL, the count of clock ticks.
1CB8
LD A,(HL) 7E
Load Register A with the new value of TIMER$ at Register Pair HL.
1CB9
AND 07H E6 07
Mask Register A with 07H: the slot of tasks 0 to 7 to run this time, and fall into RTCTASK.
1CBBRTCTASK
RLCA 07
Rotate Register A (the slot number) left: the slot times 2, the offset of its word in TCB$.
1CBC
ADD A,4EH C6 4E
Add 4EH, the low byte of TCB$ (004EH), to Register A.
1CBE
LD L,A 6F
Copy Register A (the low byte of the slot's address) into Register L.
1CBF
LD H,00H 26 00
Load Register H with 00H: Register Pair HL points to the slot in TCB$.
1CC1
LD (1CECH),HL 22 EC 1C
Store Register Pair HL (the slot's address) into 1CECH, the operand of the LD HL at @RPTSK.
1CC4
LD E,(HL) 5E
Load Register E with the low byte of the control block's address at Register Pair HL.
1CC5
INC L 2C
Increment Register L to the high byte of the slot's word.
1CC6
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the task's control block.
1CC7
PUSH DE D5
Save Register Pair DE (the control block) on the stack.
1CC8
POP IX DD E1
Restore Index Register IX from the stack: Index Register IX points to the task's control block.
1CCA
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the control block.
1CCB
LD E,(HL) 5E
Load Register E with the low byte of the task's entry at Register Pair HL.
1CCC
INC HL 23
Increment Register Pair HL to the high byte of the task's entry.
1CCD
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the task's entry.
1CCE
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the task's entry.
1CCF
JP (HL) E9
Jump to Register Pair HL, the task; it returns to the caller of RTCTASK.

1CD0H - The Task SVCs: @KLTSK, @RMTSK, @ADTSK, @RPTSK and @CKTSK

@ADTSK (SVC 29) puts the control block at Register Pair DE into slot Register C (passed in Register A); @RMTSK (SVC 30) puts NOTASK there; @KLTSK (SVC 32), called by a running task, removes that task and ends it; @RPTSK (SVC 31), called by a running task, makes the address after its call the task's new entry and ends this run; @CKTSK (SVC 28) returns Z when slot Register A is free. Slots above 11 are refused. NOTASK (1CE9H) is the control block of an empty slot: its entry word points to the RET at 1CE8H.

1CD0@KLTSK
POP DE D1
Restore Register Pair DE from the stack, dropping the return address into the task: the RET below returns to the task processor.
1CD1
LD A,(1CECH) 3A EC 1C
Load Register A with 1CECH, the low byte of the address of the slot last run, stored by RTCTASK.
1CD4
SUB 4EH D6 4E
Subtract 4EH, the low byte of TCB$, from Register A: the slot's offset.
1CD6
RRCA 0F
Rotate Register A right: the slot number, and fall into @RMTSK.
1CD7@RMTSK
LD DE,1CE9H 11 E9 1CLD DE,NOTASK
Point Register Pair DE to 1CE9H (NOTASK), the control block of an empty slot.
1CDA@ADTSK
CP 0CH FE 0C
Compare Register A (the slot number) with 0CH.
1CDC
RET NC D0
Return if the slot is 12 or more (No Carry): there are only slots 0 to 11.
1CDD
RLCA 07
Rotate Register A left: the slot number times 2, its offset in TCB$.
1CDE
ADD A,4EH C6 4E
Add 4EH, the low byte of TCB$ (004EH), to Register A.
1CE0
LD L,A 6F
Copy Register A (the low byte of the slot's address) into Register L.
1CE1
LD H,00H 26 00
Load Register H with 00H: Register Pair HL points to the slot in TCB$.
1CE3CHGTASK
DI F3
Disable interrupts: the slot must not be used while half written.
1CE4
LD (HL),E 73
Store Register E (the low byte of the control block's address) into the slot at Register Pair HL.
1CE5
INC L 2C
Increment Register L to the slot's high byte.
1CE6
LD (HL),D 72
Store Register D (the high byte) into the slot at Register Pair HL.
1CE7
EI FB
Enable interrupts again: the slot is complete.
1CE8
RET C9
Return to the caller (or, from @KLTSK and @RPTSK, to the task processor). NOTASK's entry word points to this RET.
1CE9-1CEANOTASK
DEFW 1CE8H E8 1C
NOTASK, 1CE9H-1CEAH = 1CE8H: the control block of an empty task slot, whose entry is the RET at 1CE8H.
1CEB@RPTSK
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the slot last run, the operand at 1CECH stored by RTCTASK at 1CC1H; 0000H in the file.
1CEE
LD E,(HL) 5E
Load Register E with the low byte of the task's control block address at Register Pair HL.
1CEF
INC HL 23
Increment Register Pair HL to the high byte of the control block address.
1CF0
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the control block.
1CF1
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the control block, whose first word is the task's entry.
1CF2
POP DE D1
Restore Register Pair DE from the stack: the return address after the task's RST 28H, the task's new entry.
1CF3
Jump to 1CE3H (CHGTASK) to store Register Pair DE as the entry in the control block at Register Pair HL and return to the task processor.
1CF5@CKTSK
RLCA 07
Rotate Register A (the slot number) left: the slot times 2.
1CF6
ADD A,4FH C6 4F
Add 4FH to Register A, the high byte of the slot in TCB$ (004EH plus 1).
1CF8
LD L,A 6F
Copy Register A (the low byte of the address) into Register L.
1CF9
LD H,00H 26 00
Load Register H with 00H: Register Pair HL points to the high byte of the slot.
1CFB
LD A,1CH 3E 1C
Load Register A with 1CH, the high byte of NOTASK (1CE9H).
1CFD
CP (HL) BE
Compare Register A with the slot's high byte at Register Pair HL: Z when the slot holds NOTASK, free.
1CFE
RET C9
Return Z for a free slot (NOTASK), NZ for a slot in use.
1CFF
DEFB 00H 00
1CFFH: one zero byte that fills SYSRES up to 1D00H (DC 1D00H-CORE$,0 in the source).

1E00H - SYSINIT4: The Start-Up

1E00H is the transfer address of SYS0/SYS, so these 871 bytes are the first code of the system to run after the loader in BOOT/SYS hands over. They run once: the overlay area 1E00H-23FFH is where SYS1/SYS to SYS13/SYS load, so the first overlay called writes over all of it. The start-up points the non maskable interrupt at the floppy disk driver, clears the stack and the spare device control blocks, sets the four ports from their images in low memory, finds out whether the machine has the two extra banks of a 128K Model 4, asks for the date and the time, works out the day of the year and the day of the week, shows the date, reads the keyboard for the D, ENTER and CLEAR keys, loads the SYSGEN configuration, restores the drives and leaves through the AUTO command or TRSDOS Ready. Of the whole file this is the part LS-DOS 6.3.1 changed most: 837 of these 871 bytes differ, where the resident system above is all but identical, and five of the twelve bugs of this release are in these rows.

1E00
DI F3
Disable interrupts: the loader left them on and the system has no stack of its own yet.
1E01
LD HL,0FE9H 21 E9 0FLD HL,@RSTNMI
Load Register Pair HL with 0FE9H, @RSTNMI in the floppy disk driver of BOOT/SYS.
1E04
LD (0067H),HL 22 67 00
Store Register Pair HL into 0067H, the operand of the jump at @NMI 0066H, so that the disk controller's non maskable interrupt now reaches the driver. The boot code had it pointing at its own read routine.
1E07
LD HL,0410H 21 10 04LD HL,PAKNAM$
Load Register Pair HL with 0410H (PAKNAM$), the name of this release, which BOOT/SYS loaded from sector 2 of the boot and which reads TRSDOS62Level-AR.
1E0A
LD DE,0F8BEH 11 BE F8
Load Register Pair DE with 0F8BEH, row 2 column 30 of the video memory.
1E0D
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the first eight characters of the name.
1E10
LDIR ED B0
Move Register Pair BC (8) characters from Register Pair HL (0410H) to Register Pair DE (0F8BEH): the pack name goes on the screen under the sign-on lines the loader wrote.
1E12
LD C,08H 0E 08
Load Register C with 08H for the next eight characters, Register B being zero after the move.
1E14
INC DE 13
Increment Register Pair DE past one screen position, the first of two spaces left between the two halves.
1E15
INC DE 13
Increment Register Pair DE past the second space, so that Register Pair DE is 0F8C8H.
1E16
LDIR ED B0
Move Register Pair BC (8) more characters from Register Pair HL to Register Pair DE, which is the level half of PAKNAM$: on this release it reads Level-AR.
1E18
XOR A AF
Clear Register A to 00H, the byte to fill the stack page with.
1E19
LD HL,0381H 21 81 03
Load Register Pair HL with 0381H, one past the top of the system stack.
1E1CCLRLOOP
DEC L 2D
Decrement Register L, stepping down a byte of the stack page.
1E1D
LD (HL),A 77
Store Register A (00H) at Register Pair HL, clearing that byte.
1E1E
Loop back to CLRLOOP at 1E1CH until Register L reaches 00H, which clears 0380H down to 0300H and leaves 0300H itself alone.
1E20
IM 1 ED 56
Set interrupt mode 1, so that an interrupt goes to 0038H and the task processor's handler there.
1E22
LD SP,0380H 31 80 03LD SP,STACK$
Load the Stack Pointer with 0380H, the top of the stack just cleared: from here the system has its own stack.
1E25
XOR A AF
Clear Register A to 00H, the bank number of the main 32K.
1E26
LD (0202H),A 32 02 02LD (LBANK$),A
Store Register A into 0202H (LBANK$), the logical bank in use.
1E29
OUT (0E4H),A D3 E4
Send Register A (00H) to port E4H, which turns off the floppy disk controller's interrupt and data requests.
1E2B
LD HL,0238H 21 38 02LD HL,S1DCB$
Load Register Pair HL with 0238H, the first of the spare device control blocks above the six BOOT/SYS loaded.
1E2EZERDCB
LD (HL),A 77
Store Register A (00H) at Register Pair HL, clearing one byte.
1E2F
INC L 2C
Increment Register L, stepping Register Pair HL to the next byte of the area.
1E30
Loop back to ZERDCB at 1E2EH until Register L wraps to 00H, which clears 0238H to 02FFH: every spare control block and the drive code table area below 0400H.
1E32
LD A,(0076H) 3A 76 00LD A,(MODOUT$)
Load Register A with 0076H (MODOUT$), the image of port ECH.
1E35
OUT (0ECH),A D3 EC
Send Register A to port ECH, which sets the 4 MHz clock, the external I/O bus, the video wait states and the alternate character set from the image.
1E37
LD A,(0080H) 3A 80 00LD A,(WRINT$)
Load Register A with 0080H (WRINT$), the image of port E0H.
1E3A
OUT (0E0H),A D3 E0
Send Register A to port E0H, which enables the real time clock interrupt and nothing else.
1E3C
LD A,(0078H) 3A 78 00LD A,(OPREG$)
Load Register A with 0078H (OPREG$), the image of the Operation Register, 87H.
1E3F
LD B,A 47
Copy Register A into Register B, the regular map value for the test below.
1E40
LD A,0A7H 3E A7
Load Register A with 0A7H, the same map with bit 5 set: the alternate 32K of a 128K machine in place of the regular one.
1E42
LD C,84H 0E 84
Load Register C with 84H, the Operation Register port, for the OUT (C) instructions below.
1E44
OUT (C),B ED 41
Send Register B, the regular map, to the port Register C names, 84H.
1E46
LD HL,0FFFFH 21 FF FF
Load Register Pair HL with 0FFFFH, the highest address of memory and the byte the test is made in.
1E49
LD (040EH),HL 22 0E 04LD (HIGH$),HL
Store Register Pair HL into 040EH (HIGH$), the high limit for programs, which the start-up leaves at FFFFH.
1E4C
LD (001CH),HL 22 1C 00LD (PHIGH$),HL
Store Register Pair HL into 001CH (PHIGH$), the physical high limit, also FFFFH.
1E4F
LD D,(HL) 56
Load Register D with the byte at Register Pair HL (0FFFFH) in the regular map, to be put back when the test is done.
1E50
LD (HL),55H 36 55
Store 55H at Register Pair HL (0FFFFH), a marker byte in the regular map that the alternate map cannot also hold.
1E52
OUT (C),A ED 79
Send Register A (0A7H) to the port Register C names, 84H, switching the alternate 32K in.
1E54
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL (0FFFFH) in the alternate map, to be put back in its turn.
1E55
LD (HL),A 77
Store Register A (0A7H) at Register Pair HL (0FFFFH) in the alternate map, a value that is not the 55H the regular map holds.
1E56
OUT (C),B ED 41
Send Register B to the port Register C names, 84H, switching the regular map back.
1E58
CP (HL) BE
Compare Register A (0A7H) with the byte at Register Pair HL (0FFFFH), which is 55H when the two maps are different memory and 0A7H when one 32K answers both.
1E59
LD (HL),D 72
Store Register D at Register Pair HL (0FFFFH), putting the regular map's own byte back.
1E5A
OUT (C),A ED 79
Send Register A (0A7H) to the port Register C names, 84H, switching the alternate map in once more.
1E5C
LD (HL),E 73
Store Register E at Register Pair HL (0FFFFH), putting the alternate map's byte back.
1E5D
OUT (C),B ED 41
Send Register B to the port Register C names, 84H, leaving the regular map in place for good.
1E5F
LD A,0FEH 3E FE
Load Register A with 0FEH, the bank availability byte of a machine with bank 0 alone: bit 0 clear for the one bank there is.
1E61
If the comparison at 1E58H found the two maps the same, which means 64K, jump past the next instruction to 1E65H and keep the 0FEH.
1E63
LD A,0F8H 3E F8
Load Register A with 0F8H instead, three banks: bits 2-0 clear for banks 0, 1 and 2 of a 128K machine.
1E65
LD (0201H),A 32 01 02LD (BAR$),A
Store Register A into 0201H (BAR$), the banks the machine has.
1E68
LD (0200H),A 32 00 02LD (BUR$),A
Store Register A into 0200H (BUR$), the banks in use, which starts as the same set.
1E6B
LD A,(006FH) 3A 6F 00LD A,(FEMSK$)
Load Register A with 006FH (FEMSK$), the image of port FEH.
1E6E
OUT (0FEH),A D3 FE
Send Register A to port FEH, which on a Model 4 with the hardware for it sets the alternate character generator and the like.
1E70-1E72
DEFB 00H, 00H, 00H 00 00 00
1E70H-1E72H: three bytes left clear for a jump, so that a patch can take the start-up away at this point without moving anything.
1E73
LD A,(439DH) 3A 9D 43LD A,(BOOTST$)
Load Register A with 439DH (BOOTST$), the step rate the boot code worked out and left in its own scratch page at 4300H, which nothing has written over yet.
1E76
AND 03H E6 03
AND Register A with 03H, leaving the two bits of the step rate.
1E78
LD B,A 47
Copy Register A into Register B, keeping the step rate.
1E79
LD HL,0473H 21 73 04
Load Register Pair HL with 0473H, byte 3 of the drive code table of drive 0, which holds the step rate in its low two bits.
1E7C
LD A,(HL) 7E
Load Register A with the table byte at Register Pair HL.
1E7D
AND 0FCH E6 FC
AND Register A with 0FCH, clearing the two step rate bits and keeping the rest.
1E7F
OR B B0
OR Register B into Register A, merging in the rate the boot found.
1E80
LD (HL),A 77
Store Register A back into the table at Register Pair HL, so that the system steps drive 0 at the rate the boot proved it would answer.
1E81
IN A,(0F1H) DB F1
Read port F1H into Register A, the floppy disk controller's track register, which still holds the cylinder the boot left the head on.
1E83
LD (0475H),A 32 75 04
Store Register A into 0475H, byte 5 of drive 0's table, the cylinder the system believes the head is over: no restore is needed to find out.
1E86
LD DE,0208H 11 08 02LD DE,KIDCB$
Load Register Pair DE with 0208H (KIDCB$), the keyboard device control block.
1E89
LD A,03H 3E 03
Load Register A with 03H, the control request that flushes the type-ahead buffer and sets its pointers.
1E8B
Call @CTL at 0623H, which passes the request to the keyboard driver.
1E8E
EI FB
Enable interrupts: the stack, the ports and the vectors are all set, so the clock may run.
1E8F
LD HL,0401H 21 01 04LD HL,ZERO$
Load Register Pair HL with 0401H (ZERO$), which is both the always zero byte the date code reads as the length of month zero and the flag the SYSGEN configuration writes C9H into.
1E92
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL: C9H when the diskette was SYSGENed and 00H when it was not.
1E93
LD (HL),00H 36 00
Store 00H at Register Pair HL, making ZERO$ zero again for good.
1E95
PUSH AF F5
Save Register Pair AF, whose Register A is the SYSGEN flag, on the stack: the stub at 2056H reads it back at the end of the start-up.
1E96
LD A,(04C2H) 3A C2 04LD A,(DTPMT$)
Load Register A with 04C2H (DTPMT$), which SYSTEM (DATE=OFF) sets to stop the date being asked for.
1E99
OR A B7
OR Register A with itself to test it: NZ when the prompt is turned off.
1E9A
LD HL,0033H 21 33 00LD HL,DATE$
Load Register Pair HL with 0033H (DATE$), the year byte of the date, which this file does not load and which therefore survives a reset.
1E9D
LD C,(HL) 4E
Load Register C with the year at Register Pair HL, keeping it.
1E9E
LD (HL),00H 36 00
Store 00H at Register Pair HL (0033H) over the year, so that a date left in memory cannot be used unless it passes the tests below.
1EA0
INC HL 23
Increment Register Pair HL to 0034H, the day of the month.
1EA1
LD B,(HL) 46
Load Register B with the day of the month at Register Pair HL (0034H), keeping it for the tests below.
1EA2
LD (HL),00H 36 00
Store 00H at Register Pair HL (0034H) over the day of the month.
1EA4
INC HL 23
Increment Register Pair HL to 0035H, the month.
1EA5
LD A,(HL) 7E
Load Register A with the month at Register Pair HL (0035H), keeping it for the tests below.
1EA6
LD (HL),00H 36 00
Store 00H at Register Pair HL (0035H) over the month: DATE$ now reads 00/00/00 and will stay so unless a date is accepted.
1EA8
If the Zero flag from 1E99H says the date prompt is turned off, jump to TIMIN at 1F99H and leave the date as the three zero bytes. This is the path bug T2 on the BOOT/SYS page waits on: a machine that boots with no date set rolls that unset date over to 01/01/00 at the first midnight.
1EAB
LD L,0FFH 2E FF
Load Register L with 0FFH, so that Register Pair HL is 00FFH, the last byte of the configuration control block, which the start-up borrows as its three field reply buffer.
1EAD
LD (HL),A 77
Store Register A, the month that was in memory, at Register Pair HL (00FFH), the third field of the reply buffer.
1EAE
DEC HL 2B
Decrement Register Pair HL to 00FEH, the second field of the reply buffer.
1EAF
LD (HL),B 70
Store Register B, the day, at Register Pair HL (00FEH), the second field.
1EB0
DEC HL 2B
Decrement Register Pair HL to 00FDH, the first field of the reply buffer.
1EB1
LD (HL),C 71
Store Register C, the year, at Register Pair HL (00FDH): the date that survived the reset is now laid out as though it had been typed.
1EB2
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, so that Register Pair DE points at 00FDH, the first field, as the tests below expect.
1EB3
DEC A 3D
Decrement Register A, the month, so that a month of 1 to 12 becomes 0 to 11.
1EB4
CP 0CH FE 0C
Compare Register A with 0CH (12): no Carry when the month was 0 or above 12.
1EB6
If the month is in range, jump to DATIN1 at 1EC6H and test the rest of the date that was in memory, without asking for one.
1EB8DATIN
LD HL,151BH 21 1B 15
Load Register Pair HL with 151BH, row 21 column 27, where the Date prompt is to be written.
1EBB
LD DE,211EH 11 1E 21LD DE,DATEPR
Load Register Pair DE with 211EH (DATEPR), the text Date MM/DD/YY ? and its 03H terminator.
1EBE
LD BC,0830H 01 30 08
Load Register Pair BC with 0830H: Register B = 08H, the longest reply taken, and Register C = 30H, the digit 0, which is the value a separator character must be below.
1EC1
Call GETPARM at 20AEH, which writes the prompt, reads a reply and parses its three fields into 00FDH-00FFH. It returns with the Carry flag set when all three fields were two good digits.
1EC4
If the reply did not parse, jump back to DATIN at 1EB8H and ask again.
1EC6DATIN1
LD A,(DE) 1A
Load Register A with the first field at Register Pair DE, the year.
1EC7
LD C,A 4F
Copy Register A into Register C, keeping the year for later.
1EC8
SUB 50H D6 50
Subtract 50H (80) from Register A, so that 1980 becomes 0 and the test below has only the years since 1980 to weigh. That test is bug T8 and it stands at 1ECAH.
1ECA
CP 08H FE 08
Compare Register A with 08H: no Carry when the year is 1988 or later, or below 1980. Bug T8: this one operand byte is what makes TRSDOS 6 refuse every date after 31 December 1987, the limit that made an upgrade unavoidable and that LS-DOS 6.3 was sold to lift. LS-DOS 6.3.1 has CP 20H here, which takes the range to 2011.
1ECC
If the year is outside 1980 to 1987, jump back to DATIN at 1EB8H and ask again. A year that was in memory and is now out of range is refused the same way, and the prompt comes up.
1ECE
AND 03H E6 03
AND Register A with 03H, the two bits that are zero in a leap year.
1ED0
LD A,1CH 3E 1C
Load Register A with 1CH (28), February's length in a common year.
1ED2
If the year is not a leap year, jump to NOTLEAP at 1EDAH with the 28.
1ED4
LD HL,0037H 21 37 00
Load Register Pair HL with 0037H (DATE$+4), the byte of flags about the date. Bug T9: this file does not load DATE$+4 and nothing clears bit 7 or bit 0 of it, so both survive a reset and are only ever set.
1ED7
SET 7,(HL) CB FE
Set bit 7 of the byte at Register Pair HL (0037H), the leap year flag. The flag is set for a leap year but never cleared for a common one, which is the first half of bug T9 at 1ED4H.
1ED9
INC A 3C
Increment Register A to 1DH (29), February's length in a leap year.
1EDANOTLEAP
LD HL,0403H 21 03 04
Load Register Pair HL with 0403H (MAXDAY$+2), February's entry in the table of month lengths.
1EDD
LD (HL),A 77
Store Register A, 28 or 29, at Register Pair HL (0403H), February's entry. This is the byte bug T3 on the BOOT/SYS page leaves standing when the year rolls over at midnight.
1EDE
INC DE 13
Increment Register Pair DE to the second field, the day.
1EDF
INC DE 13
Increment Register Pair DE to the third field, the month.
1EE0
LD A,(DE) 1A
Load Register A with the month at Register Pair DE (00FFH), the third field of the reply.
1EE1
LD B,A 47
Copy Register A into Register B, keeping the month.
1EE2
DEC A 3D
Decrement Register A, so that a month of 1 to 12 becomes 0 to 11.
1EE3
CP 0CH FE 0C
Compare Register A with 0CH (12): no Carry when the month was 0 or above 12.
1EE5
If the month is out of range, jump back to DATIN at 1EB8H and ask again.
1EE7
DEC HL 2B
Decrement Register Pair HL to 0402H, January's entry in the table of month lengths.
1EE8
ADD A,L 85
Add Register L to Register A, indexing the table by the month less one.
1EE9
LD L,A 6F
Copy Register A into Register L, so that Register Pair HL points at this month's length.
1EEA
DEC DE 1B
Decrement Register Pair DE back to the second field, the day.
1EEB
LD A,(DE) 1A
Load Register A with the day of the month at Register Pair DE (00FEH), the second field of the reply.
1EEC
DEC A 3D
Decrement Register A, so that a day of 1 becomes 0 and a day of 0 becomes 0FFH.
1EED
CP (HL) BE
Compare Register A with the month's length at Register Pair HL: no Carry when the day is past the end of the month, and a day of 0 gives 0FFH and fails the same test.
1EEE
If the day is out of range, jump back to DATIN at 1EB8H and ask again.
1EF0
LD HL,0035H 21 35 00
Load Register Pair HL with 0035H (DATE$+2), the month byte of the date.
1EF3
INC A 3C
Increment Register A, putting the day back to 1 to 31 after the decrement at 1EECH.
1EF4
LD (HL),B 70
Store Register B, the month, at Register Pair HL (0035H), DATE$+2.
1EF5
DEC L 2D
Decrement Register L to 0034H, the day of the month.
1EF6
LD (HL),A 77
Store Register A, the day, at Register Pair HL (0034H), DATE$+1.
1EF7
DEC L 2D
Decrement Register L, so that Register Pair HL is 0033H, the year byte of DATE$.
1EF8
LD (HL),C 71
Store Register C, the year, at Register Pair HL (0033H): the date is accepted and the system has it.
1EF9
LD A,C 79
Load Register A with Register C, the year, for the leap year test again.
1EFA
PUSH AF F5
Save Register Pair AF, with the year in Register A, on the stack for the day of the week below.
1EFB
AND 03H E6 03
AND Register A with 03H, the two bits that are zero in a leap year.
1EFD
LD HL,0403H 21 03 04
Load Register Pair HL with 0403H (MAXDAY$+2), February's entry.
1F00
LD (HL),1CH 36 1C
Store 1CH (28) at Register Pair HL (0403H), February's entry in the table of month lengths.
1F02
If the year is not a leap year, jump past the next instruction to 1F05H and leave the 28.
1F04
INC (HL) 34
Increment the byte at Register Pair HL (0403H) to 29. The work at 1ED0H to 1EDDH is done again here because the year the reply gave need not be the year that was in memory.
1F05
LD A,(0035H) 3A 35 00
Load Register A with 0035H (DATE$+2), the month.
1F08
LD B,A 47
Copy Register A into Register B, the count of months to add up.
1F09
LD A,(0034H) 3A 34 00
Load Register A with 0034H (DATE$+1), the day of the month.
1F0C
LD L,A 6F
Copy Register A into Register L, the running total of the day of the year.
1F0D
LD H,00H 26 00
Load Register H with 00H, so that Register Pair HL is the day of the month.
1F0F
LD DE,0401H 11 01 04LD DE,MAXDAY$
Load Register Pair DE with 0401H (MAXDAY$), the length of month zero, which is the always zero byte ZERO$: adding it in for the first month leaves the total alone.
1F12DAYLP
LD A,(DE) 1A
Load Register A with the month length at Register Pair DE.
1F13
ADD A,L 85
Add Register L to Register A, the low byte of the running total.
1F14
LD L,A 6F
Copy Register A into Register L, the new low byte.
1F15
ADC A,H 8C
Add Register H to Register A with the Carry flag of that addition.
1F16
SUB L 95
Subtract Register L from Register A, which leaves the high byte plus the carry alone: an eight bit addition into a sixteen bit total in four instructions.
1F17
LD H,A 67
Copy Register A into Register H, the new high byte.
1F18
INC DE 13
Increment Register Pair DE to the next month's length.
1F19
Count Register B down and loop back to DAYLP at 1F12H once for each month before this one.
1F1B
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, moving the day of the year into Register Pair DE.
1F1C
LD HL,0036H 21 36 00
Load Register Pair HL with 0036H (DATE$+3), the low byte of the day of the year.
1F1F
LD (HL),E 73
Store Register E, the low eight bits of the day of the year, at Register Pair HL (0036H), DATE$+3.
1F20
INC HL 23
Increment Register Pair HL to 0037H (DATE$+4), the flags byte.
1F21
LD A,D 7A
Load Register A with Register D, whose bit 0 is bit 8 of the day of the year.
1F22
OR (HL) B6
OR the flags byte at Register Pair HL (0037H) into Register A. Bit 0 is ORed in and never cleared, so a day of the year above 255 left in memory by an earlier date keeps its bit 8 set for a new date whose day of the year is below 256: the second half of bug T9 at 1ED4H.
1F23
LD (HL),A 77
Store Register A back at Register Pair HL (0037H), DATE$+4, with bit 8 of the day of the year in its bit 0.
1F24
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, bringing the day of the year back into Register Pair HL for the division below.
1F25
POP AF F1
Restore Register Pair AF from the stack, the year kept at 1EFAH.
1F26
AND 07H E6 07
AND Register A with 07H, the low three bits of the year.
1F28
LD E,A 5F
Copy Register A into Register E, keeping them.
1F29
ADD A,03H C6 03
Add 03H to Register A, the offset that puts the first of the eight year cycle on the right weekday.
1F2B
RRCA 0F
Rotate Register A right, the first of two that divide by four.
1F2C
RRCA 0F
Rotate Register A right, the second: Register A is now the number of leap days in the years so far.
1F2D
AND 03H E6 03
AND Register A with 03H, keeping the two bits the rotations left meaningful.
1F2F
ADD A,E 83
Add Register E to Register A, the years and the leap days together.
1F30
LD E,A 5F
Copy Register A into Register E, the low byte of what is to be added to the day of the year.
1F31
LD D,00H 16 00
Load Register D with 00H, so that Register Pair DE is that number alone.
1F33
ADD HL,DE 19
Add Register Pair DE to Register Pair HL, the day of the year plus the years and leap days since the start of the cycle.
1F34
INC HL 23
Increment Register Pair HL, the offset that lands the answer on the right day of the week.
1F35
LD C,07H 0E 07
Load Register C with 07H, the seven days of a week, Register B being zero.
1F37DIV7
SBC HL,BC ED 42
Subtract Register Pair BC and the Carry flag from Register Pair HL, taking a week off.
1F39
Loop back to DIV7 at 1F37H while the subtraction does not borrow, which divides by seven by repeated subtraction.
1F3B
LD A,L 7D
Load Register A with Register L, the remainder, which the last subtraction left below zero.
1F3C
ADD A,08H C6 08
Add 08H to Register A, bringing it back into the range 1 to 7.
1F3E
LD B,A 47
Copy Register A into Register B, the day of the week for the table below.
1F3F
RLCA 07
Rotate Register A left, moving the day of the week into bits 3-1.
1F40
LD C,A 4F
Copy Register A into Register C, the bits to merge in.
1F41
LD HL,0037H 21 37 00
Load Register Pair HL with 0037H (DATE$+4), the flags byte.
1F44
LD A,(HL) 7E
Load Register A with the flags byte at Register Pair HL (0037H).
1F45
AND 0F1H E6 F1
AND Register A with 0F1H, clearing bits 3-1, the old day of the week, and keeping bits 7-4 and bit 0: the two bits bug T9 is about are exactly the ones this mask keeps.
1F47
OR C B1
OR Register C into Register A, the new day of the week.
1F48
LD (HL),A 77
Store Register A back at Register Pair HL (0037H), DATE$+4, with the day of the week in its bits 3-1.
1F49
PUSH BC C5
Save Register Pair BC, whose Register B is the day of the week, on the stack.
1F4A
LD HL,151BH 21 1B 15
Load Register Pair HL with 151BH, row 21 column 27, where the date is to be written.
1F4D
LD B,03H 06 03
Load Register B with 03H, the @VDCTL function that sets the cursor.
1F4F
Call @VDCTL at 0B99H, which moves the cursor there.
1F52
POP BC C1
Restore Register Pair BC, the day of the week, from the stack.
1F53
LD HL,04C7H 21 C7 04LD HL,DAYTBL$
Load Register Pair HL with 04C7H (DAYTBL$), the table of seven three letter day names in low memory.
1F56
Call SPACE4 at 20FFH, which writes four spaces and then the Register B-th name of the table.
1F59
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that follows the name of the day.
1F5B
Call @DSP at 0642H, which shows the comma in Register A.
1F5E
LD A,20H 3E 20
Load Register A with 20H, the space after the comma.
1F60
Call @DSP at 0642H, which shows the space in Register A.
1F63
LD A,(0035H) 3A 35 00
Load Register A with 0035H (DATE$+2), the month.
1F66
LD B,A 47
Copy Register A into Register B, the month for the table below.
1F67
LD L,0DCH 2E DC
Load Register L with 0DCH, so that Register Pair HL is 04DCH (MONTBL$), the table of twelve three letter month names.
1F69
Call DSPMDY at 2107H, which writes the Register B-th name of the table.
1F6C
LD A,20H 3E 20
Load Register A with 20H, the space after the name of the month.
1F6E
Call @DSP at 0642H, which shows the space in Register A.
1F71
LD A,(0034H) 3A 34 00
Load Register A with 0034H (DATE$+1), the day of the month.
1F74
DEC B 05
Decrement Register B to 0FFH, which the loop below increments back to 00H before it counts.
1F75DIV10
INC B 04
Increment Register B, the tens digit so far.
1F76
SUB 0AH D6 0A
Subtract 0AH (10) from Register A, one ten off the day of the month.
1F78
Loop back to DIV10 at 1F75H while the subtraction does not borrow, which divides the day by ten.
1F7A
PUSH AF F5
Save Register Pair AF, whose Register A is the units digit less ten, on the stack.
1F7B
LD A,B 78
Load Register A with Register B, the tens digit.
1F7C
ADD A,30H C6 30
Add 30H to Register A, the code of the digit 0, making it a character.
1F7E
CP 30H FE 30
Compare Register A with 30H: Z when the tens digit is zero.
1F80
Call @DSP at 0642H to show the tens digit only when it is not zero, so that the 3rd is shown and not the 03rd.
1F83
POP AF F1
Restore Register Pair AF, the units digit less ten, from the stack.
1F84
ADD A,3AH C6 3A
Add 3AH to Register A, which is the 30H of the digit 0 and the ten the last subtraction took off, in one.
1F86
Call @DSP at 0642H, which shows the units digit in Register A.
1F89
LD HL,2117H 21 17 21LD HL,PARTYR
Load Register Pair HL with 2117H (PARTYR), the text , 198 and its terminator: the first three digits of the year are built into the text, which is the same eight year range bug T8 refuses to go outside.
1F8C
Call @DSPLY at 052DH, which writes the text at Register Pair HL up to its 03H terminator.
1F8F
LD A,(0033H) 3A 33 00LD A,(DATE$)
Load Register A with 0033H (DATE$), the year.
1F92
AND 07H E6 07
AND Register A with 07H, the low three bits, which are all the eight years of the range need.
1F94
ADD A,30H C6 30
Add 30H to Register A, making the last digit of the year a character.
1F96
Call @DSP at 0642H to show it: the date line is written.
1F99TIMIN
LD A,(04C3H) 3A C3 04LD A,(TMPMT$)
Load Register A with 04C3H (TMPMT$), which SYSTEM (TIME=OFF) sets to stop the time being asked for. BOOT/SYS ships this byte as FFH, where LS-DOS 6.3.1 ships 00H, so this release asks for the time and that one does not.
1F9C
OR A B7
OR Register A with itself to test it: NZ when the prompt is turned off.
1F9D
If the time prompt is turned off, jump to SELDCT at 1FC7H and leave TIME$ as the clock has it.
1F9FTIMIN0
LD HL,161BH 21 1B 16
Load Register Pair HL with 161BH, row 22 column 27, where the Time prompt is to be written.
1FA2
LD DE,2130H 11 30 21LD DE,TIMEPR
Load Register Pair DE with 2130H (TIMEPR), the text Time HH:MM:SS ? and its 03H terminator.
1FA5
LD BC,0830H 01 30 08
Load Register Pair BC with 0830H: Register B = 08H, the longest reply taken, and Register C = 30H, the digit 0, which a separator must be below. A colon is 3AH and so above it, which is why GETPARM tests for a colon on its own at 20EFH.
1FA8
Call GETPARM at 20AEH, which writes the prompt, reads a reply and parses its three fields into 00FDH-00FFH.
1FAB
If the reply did not parse, jump back to TIMIN0 at 1F9FH and ask again.
1FAD
LD HL,00FFH 21 FF 00
Load Register Pair HL with 00FFH, the third field of the reply, which for the time is the seconds.
1FB0
LD A,17H 3E 17
Load Register A with 17H (23), the highest hour.
1FB2
CP (HL) BE
Compare Register A (23) with the byte at Register Pair HL: Carry when the field is above 23.
1FB3
If it is, jump back to TIMIN0 at 1F9FH and ask again. The buffer is filled downward from 00FFH and read upward from it, so the field the hour test is made on is the one the reply gave last: the three fields of the reply are stored at 00FFH, 00FEH and 00FDH in that order at 20E8H, so 00FFH holds the first field typed, which the prompt asks to be the hours.
1FB5
DEC HL 2B
Decrement Register Pair HL to 00FEH, the second field, the minutes.
1FB6
LD A,3BH 3E 3B
Load Register A with 3BH (59), the highest minute and the highest second.
1FB8
CP (HL) BE
Compare Register A (59) with the byte at Register Pair HL: Carry when the field is above 59.
1FB9
If it is, jump back to TIMIN0 at 1F9FH and ask again.
1FBB
DEC HL 2B
Decrement Register Pair HL to 00FDH, the first field, the seconds.
1FBC
CP (HL) BE
Compare Register A (59) with the byte at Register Pair HL, the same test for the seconds.
1FBD
If the seconds are above 59, jump back to TIMIN0 at 1F9FH and ask again.
1FBF
LD DE,002DH 11 2D 00LD DE,TIME$
Load Register Pair DE with 002DH (TIME$), the seconds byte of the system's time.
1FC2
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes to move.
1FC5
LDIR ED B0
Move Register Pair BC (3) bytes from Register Pair HL (00FDH) to Register Pair DE (002DH): the seconds, minutes and hours as the clock of BOOT/SYS keeps them.
1FC7SELDCT
LD HL,0420H 21 20 04LD HL,INBUF$
Load Register Pair HL with 0420H (INBUF$), the command line buffer, which holds the AUTO command of the diskette if it has one.
1FCA
LD A,(HL) 7E
Load Register A with the first character of the AUTO command at Register Pair HL.
1FCB
CP 2AH FE 2A
Compare Register A with 2AH, an asterisk, which is how an AUTO command asks for BREAK to be disabled while it runs.
1FCD
If the command does not begin with an asterisk, jump to CKDCR at 1FDEH.
1FCF
INC HL 23
Increment Register Pair HL past the asterisk, so that the command itself is what is passed on.
1FD0
LD A,0E6H 3E E6
Load Register A with 0E6H, the second byte of SET 4,(HL).
1FD2
LD (205AH),A 32 5A 20
Store Register A into 205AH, the second byte of the RES 4,(HL) at STUB1 2059H, which turns it into SET 4,(HL): the stub will now set bit 4 of SFLAG$ and disable BREAK instead of clearing it. The stub is moved to 4350H before it runs, so the byte is patched here, in the copy the move reads.
1FD5
Jump to AUTO? at 1FF1H, which tests whether there is a command to run.
1FD7GETKB17
Call ENADIS_DO_RAM at 0817H, which switches the keyboard and the video memory in and arranges for them to be switched out when the caller returns.
1FDA
LD A,(0F441H) 3A 41 F4
Load Register A with 0F441H. Bug T10: the keyboard is read by address, and 41H has bits 0 and 6 set, so this one read returns rows 0 and 6 ORed together and the two tests below cannot tell which of the two rows a key came from.
1FDD
RET C9
Return to the caller with the two rows in Register A.
1FDECKDCR
Call GETKB17 at 1FD7H, which returns keyboard rows 0 and 6 ORed together in Register A.
1FE1
BIT 4,A CB 67
Test bit 4 of Register A, which is the D key of row 0. Bit 4 of row 6 is the down arrow, so holding the down arrow at boot starts the debugger exactly as holding D does: the first half of bug T10 at 1FDAH.
1FE3
PUSH HL E5
Save Register Pair HL, the AUTO command pointer, on the stack.
1FE4
LD HL,1B08H 21 08 1BLD HL,@ABORT
Load Register Pair HL with 1B08H (@ABORT), where the debugger is to return to.
1FE7
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer points at: the abort address becomes the return address and the command pointer comes back into Register Pair HL.
1FE8
If the D key or the down arrow was down, jump to @DEBUG at 19A0H, which runs the debugger and returns to @ABORT.
1FEB
POP DE D1
Restore Register Pair DE from the stack, which keeps the stack straight on the path where the debugger was not wanted.
1FEC
CPL 2F
Complement Register A, so that a key that was down is now a clear bit.
1FED
AND 01H E6 01
AND Register A with 01H, bit 0, which is the ENTER key of row 6. Bit 0 of row 0 is the at sign, so holding the at sign at boot skips the AUTO command exactly as holding ENTER does: the second half of bug T10 at 1FDAH.
1FEF
If the key was down, jump to NOAUT1 at 1FF4H, which leaves the Zero flag saying there is no AUTO command to run.
1FF1AUTO?
LD A,(HL) 7E
Load Register A with the first character of the AUTO command at Register Pair HL.
1FF2
CP 0DH FE 0D
Compare Register A with 0DH, a carriage return: Z when the command line is empty and there is no AUTO command.
1FF4NOAUT1
POP DE D1
Restore Register Pair DE from the stack, whose Register D is the SYSGEN flag saved at 1E95H.
1FF5
LD A,D 7A
Load Register A with Register D, the SYSGEN flag, which the stub tests at 2028H.
1FF6
LD DE,1B0BH 11 0B 1BLD DE,@EXIT
Load Register Pair DE with 1B0BH (@EXIT), where the system is to go when the start-up is done and there is no AUTO command.
1FF9
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the parameters @EXIT takes.
1FFC
If there is no AUTO command, jump to NOAUT at 200DH, which stacks @EXIT and the zero.
1FFE
PUSH HL E5
Save Register Pair HL, the AUTO command pointer, on the stack.
1FFF
LD HL,2084H 21 84 20LD HL,CURSET
Load Register Pair HL with 2084H, the high byte of the LD HL,1500H at 2082H inside the stub, which is the row the stub puts the cursor on.
2002
INC (HL) 34
Increment the byte at Register Pair HL (2084H) from 15H to 16H, moving the stub's cursor from row 21 to row 22: an AUTO command is about to be echoed on row 21, so the SYSGEN line the stub writes must go a row lower. The stub is patched here, before the move to 4350H reads it.
2003
POP HL E1
Restore Register Pair HL, the AUTO command pointer, from the stack.
2004
LD DE,197EH 11 7E 19LD DE,@CMNDI
Load Register Pair DE with 197EH (@CMNDI), where the system is to go to run the AUTO command.
2007
PUSH DE D5
Save Register Pair DE (@CMNDI) on the stack, the second of the three return addresses the start-up stacks.
2008
LD B,H 44
Copy Register H into Register B, the first half of moving the command pointer into Register Pair BC.
2009
LD C,L 4D
Copy Register L into Register C: Register Pair BC is the AUTO command, which is what @CMNDI takes.
200A
LD DE,052DH 11 2D 05LD DE,@DSPLY
Load Register Pair DE with 052DH (@DSPLY), which is to run first and show the command on the screen.
200DNOAUT
PUSH DE D5
Save Register Pair DE on the stack: @DSPLY on the AUTO path, @EXIT on the other.
200E
PUSH BC C5
Save Register Pair BC on the stack: the command pointer or the zero, which the routine popped into it will find.
200F
LD HL,2056H 21 56 20LD HL,STUB
Load Register Pair HL with 2056H (STUB), the code that is to run after the configuration is loaded.
2012
LD DE,4350H 11 50 43
Load Register Pair DE with 4350H, 80 bytes into the boot code's old scratch page at 4300H, where the stub is to run.
2015
LD BC,0058H 01 58 00LD BC,STUBLEN
Load Register Pair BC with 0058H (88), the length of the stub.
2018
PUSH DE D5
Save Register Pair DE (4350H) on the stack, the third return address: the stub is reached by a RET and not by a jump.
2019
LDIR ED B0
Move Register Pair BC (88) bytes from Register Pair HL (2056H) to Register Pair DE (4350H), the stub to the scratch page. It has to be moved because 1E00H-23FFH is where the SYSGEN configuration and then the overlays load.
201B
Call GETKB67 at 204CH, which returns keyboard rows 5 and 6 ORed with the SYSGEN flag in Register A.
201E
LD DE,0470H 11 70 04LD DE,DCT$
Load Register Pair DE with 0470H (DCT$), the eight drive code tables.
2021
LD HL,4300H 21 00 43LD HL,MOD3BUF
Load Register Pair HL with 4300H, the first 80 bytes of the scratch page, where the boot code left the tables it built.
2024
LD BC,0050H 01 50 00
Load Register Pair BC with 0050H (80), eight tables of ten bytes.
2027
EXX D9
Exchange Register Pair HL, Register Pair DE and Register Pair BC with the alternate set, which keeps all three out of the way of the configuration load for the stub to use afterwards.
2028
AND 82H E6 82
AND Register A with 82H, bits 7 and 1 of the keyboard rows and the SYSGEN flag ORed together at 2054H. Bit 7 of row 6 is the space bar, bit 1 of row 5 is the 9 key and bit 7 of row 5 is the oblique stroke, so holding any of those three at boot skips the SYSGEN configuration exactly as holding CLEAR does: this is the test bug T11 at 204CH feeds.
202A
RET NZ C0
Return if any of those bits is set, which takes the start-up straight to the stub at 4350H without loading a configuration.
202B
LD HL,1500H 21 00 15
Load Register Pair HL with 1500H, row 21 column 0.
202E
LD B,03H 06 03
Load Register B with 03H, the @VDCTL function that sets the cursor.
2030
Call @VDCTL at 0B99H, which moves the cursor there.
2033
LD HL,203FH 21 3F 20LD HL,CONFIG$
Load Register Pair HL with 203FH (CONFIG$), the twelve character SYSGEN line and its terminator.
2036
Call @DSPLY at 052DH, which shows that the configuration is being loaded.
2039
LD DE,00E0H 11 E0 00LD DE,CFGFCB$
Load Register Pair DE with 00E0H (CFGFCB$), the control block that holds the file specification CONFIG/SYS.CCC:0.
203C
Jump to @LOAD at 1B38H, which loads the configuration and returns to the stub at 4350H through the address stacked at 2018H.
203F-204BCONFIG$
DEFM "** SYSGEN **" / DEFB 03H 2A 2A 20 53 59 53 47 45 4E 20 2A 2A 03
CONFIG$, 203FH-204BH: the twelve characters shown while the configuration is read, and the 03H @DSPLY stops on.
204CGETKB67
LD HL,0F460H 21 60 F4LD HL,KB67
Load Register Pair HL with 0F460H. Bug T11: 60H has bits 5 and 6 set, so this address returns keyboard rows 5 and 6 ORed together, and the AND 82H at 2028H cannot tell the CLEAR key of row 6 from the 9 and the oblique stroke of row 5.
204F
LD C,A 4F
Copy Register A, the SYSGEN flag, into Register C, out of the way of the call below.
2050
Call ENADIS_DO_RAM at 0817H, which switches the keyboard in and arranges for it to be switched out on the return.
2053
LD A,C 79
Load Register A with Register C, the SYSGEN flag again.
2054
OR (HL) B6
OR the keyboard rows at Register Pair HL into Register A: the result is not zero when the diskette was not SYSGENed or when one of those keys is down.
2055
RET C9
Return to the caller with the two put together in Register A.
2056STUB
LD HL,007CH 21 7C 00LD HL,SFLAG$
Load Register Pair HL with 007CH (SFLAG$), the system flags. These 88 bytes are shown at the addresses they are loaded at, 2056H-20ADH, and run 22FAH higher, at 4350H-43A7H, having been moved there at 2019H.
2059STUB1
RES 4,(HL) CB A6
Clear bit 4 of SFLAG$ at Register Pair HL, which enables BREAK. 1FD2H turns this instruction into SET 4,(HL) when the AUTO command began with an asterisk, and the Zero flag it leaves is the SYSGEN flag the AND at 2028H set.
205B
If the SYSGEN flag and the keyboard said no configuration was to be loaded, jump to NOTSG at 2069H.
205D
LD HL,0076H 21 76 00LD HL,MODOUT$
Load Register Pair HL with 0076H (MODOUT$), the image of port ECH, which the configuration may have changed.
2060
LD A,(HL) 7E
Load Register A with the image at Register Pair HL.
2061
OUT (0ECH),A D3 EC
Send Register A to port ECH, so that a configuration that asked for a different clock speed or character set gets it.
2063
EXX D9
Exchange the three register pairs with the alternate set again, which brings back what 2027H kept there: Register Pair HL 4300H, Register Pair DE 0470H and Register Pair BC 0050H.
2064
LDIR ED B0
Move Register Pair BC (80) bytes from Register Pair HL (4300H) to Register Pair DE (0470H), the eight drive code tables the boot built, over whatever the configuration left in them.
2066
Call @ICNFG at 0086H, the chain vector a driver that came in with the configuration puts its own start-up routine on. It is a RET in the file.
2069NOTSG
LD C,07H 0E 07
Load Register C with 07H, the highest drive number: the loop below works down through all eight.
206BSETCYL0
Call @GTDCT at 1A1EH, which points Index Register IY at the drive code table of drive Register C.
206E
BIT 3,(IY+03H) FD CB 03 5E
Test bit 3 of the table byte at Index Register IY+03H, which is set for a hard drive.
2072
If the drive is a hard drive, jump to NOFF at 207FH: a hard drive is not restored and its cylinder is not forced.
2074
LD (IY+05H),0FFH FD 36 05 FF
Store 0FFH into the table byte at Index Register IY+05H, the cylinder the system believes the head is over, which no real cylinder matches: the next seek must therefore step the head.
2078
LD A,(04C4H) 3A C4 04LD A,(RSTOR$)
Load Register A with 04C4H (RSTOR$), which BOOT/SYS loads and SYSTEM can set to stop the drives being restored.
207B
OR A B7
OR Register A with itself to test it: Z when the drives are to be restored.
207C
Call @RSTOR at 19C8H when the byte is zero, which steps the head of drive Register C out to cylinder 0.
207FNOFF
DEC C 0D
Decrement Register C to the next drive down.
2080
Loop back to SETCYL0 at 206BH until Register C passes zero, which covers drives 7 down to 0.
2082
LD HL,1500H 21 00 15
Load Register Pair HL with 1500H, row 21 column 0, or with 1600H when 2002H stepped the high byte on because an AUTO command is to be echoed. The source names the high byte of this instruction's operand, 2084H, CURSET, which is the address 1FFFH points Register Pair HL at.
2085
LD B,03H 06 03
Load Register B with 03H, the @VDCTL function that sets the cursor.
2087
Call @VDCTL at 0B99H, which moves the cursor there: it is where the AUTO command or TRSDOS Ready will be written.
208A
LD DE,4F4DH 11 4D 4F
Load Register Pair DE with 4F4DH, the two characters M and O as a word.
208D
LD HL,(4018H) 2A 18 40
Load Register Pair HL with the word at 4018H, which on a Model 4P is what the boot ROM left in memory and on a Model 4 is whatever was there.
2090
SBC HL,DE ED 52
Subtract Register Pair DE and the Carry flag from Register Pair HL: Z when the two characters are found.
2092
LD A,04H 3E 04
Load Register A with 04H, the machine type of a Model 4.
2094
If the characters were not found, jump to MOD4REG at 2098H with the 04H.
2096
LD A,05H 3E 05
Load Register A with 05H instead, the machine type of a Model 4P.
2098MOD4REG
LD (007DH),A 32 7D 00LD (TFLAG$),A
Store Register A into 007DH (TFLAG$), the machine type, which FORMAT, BACKUP and MODELA/III read.
209B
LD HL,0038H 21 38 00LD HL,@RST38
Load Register Pair HL with 0038H (@RST38), the maskable interrupt vector.
209E
LD (HL),0C3H 36 C3
Store 0C3H, the opcode of JP, at Register Pair HL (0038H), over whatever is there: the file loaded a JP to the task processor at 0038H, and a SYSGEN configuration is a load module that may have written over it.
20A0
POP HL E1
Restore Register Pair HL from the stack, which is the AUTO command pointer or the zero stacked at 200EH.
20A1
RET C9
Return through the address stacked at 200DH: @DSPLY, which shows the AUTO command and then returns to @CMNDI to run it, or @EXIT, which gives TRSDOS Ready. The start-up is over and 1E00H-23FFH is free for the overlays.
20A2-20AD
DEFB 00H x 12 00 x 12
20A2H-20ADH: twelve zero bytes inside the stub, moved to 43A2H with the rest of it and left for more stub code.
20AEGETPARM
PUSH BC C5
Save Register Pair BC, whose Register C is the separator character and Register B the length of the reply buffer, on the stack.
20AF
PUSH DE D5
Save Register Pair DE, the prompt text, on the stack.
20B0
LD B,03H 06 03
Load Register B with 03H, the @VDCTL function that sets the cursor.
20B2
Call @VDCTL at 0B99H, which moves the cursor to the row and column in Register Pair HL.
20B5
POP HL E1
Restore Register Pair HL, the prompt text, from the stack.
20B6
Call @DSPLY at 052DH, which writes the prompt.
20B9
LD HL,1E00H 21 00 1ELD HL,OVERLAY
Load Register Pair HL with 1E00H (OVERLAY), the start of the overlay area, which the start-up uses as its reply buffer: it is about to be overwritten by the first overlay anyway.
20BC
POP BC C1
Restore Register Pair BC, the separator and the length, from the stack.
20BD
PUSH BC C5
Save Register Pair BC again, so that the parse below has them too.
20BE
Call @KEYIN at 0585H, which reads a line into Register Pair HL and returns its length in Register B.
20C1
XOR A AF
Clear Register A to 00H, so that the OR below tests the length alone.
20C2
OR B B0
OR Register B into Register A, the length of the reply: Z when nothing was typed.
20C3
POP BC C1
Restore Register Pair BC, the separator and the length, from the stack.
20C4
RET Z C8
Return with no Carry if the reply was empty, which the caller takes as a format error and asks again. On the date prompt that is what makes ENTER alone leave the date unset.
20C5
PUSH BC C5
Save Register Pair BC on the stack once more.
20C6
LD B,40H 06 40
Load Register B with 40H, the count @PAUSE is to run down.
20C8
Call @PAUSE at 0382H, a short delay so that the finger is off the ENTER key before the next prompt reads the keyboard.
20CB
POP BC C1
Restore Register Pair BC, the separator character and the length, from the stack.
20CCPARSDAT
LD DE,00FFH 11 FF 00
Load Register Pair DE with 00FFH, the last byte of the configuration control block: the three fields are written downward from here.
20CF
LD B,03H 06 03
Load Register B with 03H, the three fields to parse.
20D1PRSD1
PUSH DE D5
Save Register Pair DE, where this field is to go, on the stack.
20D2
Call PRSD3 at 20F8H, which turns the character at Register Pair HL into its value in Register A and steps Register Pair HL past it.
20D5
If the character was not a digit, jump to PRSD2 at 20E6H, which returns the format error.
20D7
LD E,A 5F
Copy Register A, the tens digit, into Register E.
20D8
RLCA 07
Rotate Register A left, which leaves Register A at twice the digit.
20D9
RLCA 07
Rotate Register A left, four times the digit.
20DA
ADD A,E 83
Add Register E to Register A, five times the digit.
20DB
RLCA 07
Rotate Register A left once more, which leaves Register A at ten times the digit.
20DC
LD E,A 5F
Copy Register A into Register E, the tens of the field, ready for the units to be added to it.
20DD
Call PRSD3 at 20F8H again, which returns the units digit of the field in Register A.
20E0
If that character was not a digit, jump to PRSD2 at 20E6H.
20E2
ADD A,E 83
Add Register E to Register A, the tens and the units: the field is now a binary value.
20E3
LD E,A 5F
Copy Register A into Register E, keeping the value.
20E4
SCF 37
Set the Carry flag, which the caller reads as a good field.
20E5
LD A,E 7B
Load Register A with Register E, the value, for the store below.
20E6PRSD2
POP DE D1
Restore Register Pair DE, where the field is to go, from the stack.
20E7
RET NC D0
Return with no Carry if either character was not a digit, which the caller reads as a format error.
20E8
LD (DE),A 12
Store Register A, the value of the field, at Register Pair DE.
20E9
DEC B 05
Decrement Register B, the fields left to parse.
20EA
SCF 37
Set the Carry flag, which the caller reads as a good field.
20EB
RET Z C8
Return with the Carry flag set when all three fields have been parsed.
20EC
DEC DE 1B
Decrement Register Pair DE to the next field down.
20ED
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, which should be the separator between two fields.
20EE
INC HL 23
Increment Register Pair HL past the separator character.
20EF
CP 3AH FE 3A
Compare Register A with 3AH, a colon, which the time prompt asks for and which is above the 30H Register C holds.
20F1
If it is a colon, jump back to PRSD1 at 20D1H for the next field.
20F3
CP C B9
Compare Register A with Register C, which is 30H, the digit 0: Carry when the character is below it.
20F4
If the character is the digit 0 or above, jump to PRSD4 at 20FCH, which returns no Carry and so a format error.
20F6
Jump back to PRSD1 at 20D1H for the next field. Bug T12: every character below the digit 0 is taken as a separator, and a carriage return is 0DH. A reply of fewer than three fields therefore does not end the parse: the 0DH @KEYIN left is read as a separator and the next field is taken from the bytes after it in the buffer at 1E00H, which nothing clears. A time of 10 and ENTER typed after the date 01/23/85 is taken as 10:23:85, and only the range tests at 1FB2H to 1FBDH refuse it when the leftover bytes make a field too large.
20F8PRSD3
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
20F9
INC HL 23
Increment Register Pair HL past the character just read.
20FA
SUB 30H D6 30
Subtract 30H from Register A, the code of the digit 0, which turns a digit into its value.
20FCPRSD4
CP 0AH FE 0A
Compare Register A with 0AH (10): Carry when the character was a digit 0 to 9, which is the good return, and no Carry on anything else.
20FE
RET C9
Return to the caller with the value in Register A and the Carry flag as the answer.
20FFSPACE4
PUSH HL E5
Save Register Pair HL, the table of names, on the stack.
2100
LD HL,2142H 21 42 21LD HL,SPACE4$
Load Register Pair HL with 2142H (SPACE4$), three spaces and two 03H bytes.
2103
Call @DSPLY at 052DH, which writes the three spaces and stops on the first 03H.
2106
POP HL E1
Restore Register Pair HL, the table of names, from the stack.
2107DSPMDY
DEC B 05
Decrement Register B, the number of the name wanted, so that the first name is at an offset of zero.
2108
LD A,L 7D
Load Register A with Register L, the low byte of the table address.
2109
ADD A,B 80
Add Register B to Register A, once the number.
210A
ADD A,B 80
Add Register B to Register A, twice the number.
210B
ADD A,B 80
Add Register B to Register A, three times the number: each name is three characters long.
210C
LD L,A 6F
Copy Register A into Register L, so that Register Pair HL points at the name wanted.
210D
LD B,03H 06 03
Load Register B with 03H, the three characters of a name.
210FDSPM1
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
2110
INC HL 23
Increment Register Pair HL to the next character.
2111
Call @DSP at 0642H, which shows the character in Register A.
2114
Count Register B down and loop back to DSPM1 at 210FH for all three characters.
2116
RET C9
Return to the caller with the three characters of the name written to the screen.
2117-211DPARTYR
DEFM ", 198" / DEFB 1EH, 03H 2C 20 31 39 38 1E 03
PARTYR, 2117H-211DH: the text shown between the day of the month and the last digit of the year, then 1EH, the code that clears to the end of the line, and the 03H @DSPLY stops on. The first three digits of the year are built into this text, which is the same eight year range the test at 1ECAH holds the date to.
211E-212FDATEPR
DEFB 1EH / DEFM "Date MM/DD/YY ? " / DEFB 03H 1E 44 61 74 65 20 4D 4D 2F 44 44 2F 59 59 20 3F 20 03
DATEPR, 211EH-212FH: the date prompt, led by the 1EH that clears to the end of the line and ended by the 03H @DSPLY stops on.
2130-2141TIMEPR
DEFB 1EH / DEFM "Time HH:MM:SS ? " / DEFB 03H 1E 54 69 6D 65 20 48 48 3A 4D 4D 3A 53 53 20 3F 20 03
TIMEPR, 2130H-2141H: the time prompt, laid out the same way. The colon it shows between the fields is what the test at 20EFH takes.
2142-2146SPACE4$
DEFM " " / DEFB 03H, 03H 20 20 20 03 03
SPACE4$, 2142H-2146H: three spaces and two 03H bytes, written before the name of the day at 2103H. The second 03H is never reached, @DSPLY stopping on the first.
2147-2166
DEFB 00H x 32 00 x 32
2147H-2166H: thirty-two zero bytes, the last of the file, which the source leaves as room for another message or more code. They are the only part of the start-up with nothing in it.

F80DH - The Sign-On Screen, Loaded Straight into Video Memory

SYS0/SYS ends with eighteen load blocks that go into video memory, which the boot code left mapped at F800H-FFFFH and cleared to spaces. Two of them write the version and copyright lines across the top two rows, and the other sixteen draw the logo, one block for each screen row from row 4 to row 19. Nothing in the file paints the screen: the loader writes the bytes where they are to be seen, so the sign-on is on the screen before the start-up code at 1E00H is reached. The logo is drawn in the Model 4 block graphics characters 80H-0BFH, each of which is a cell two pixels wide and three deep with one bit for each pixel, and it is symmetrical about the middle, 33 characters wide at its top and bottom row and 15 at its waist. The bytes the file does not load are left as the spaces the boot wrote.

F80D-F81B
DEFM "TRSDOS 06.02.01" 54 52 53 44 4F 53 20 30 36 2E 30 32 2E 30 31
F80DH-F81BH, row 0 from column 13: the version, TRSDOS 06.02.01. The release number comes from OSRLS$ at 003BH and the version from OSVER$ at 0085H, and these fifteen characters are the only place the whole number is written out. The source of level AD has 06.02.00 here.
F81C
DEFM " " 20
F81CH, row 0, column 28: a space, the position the German and French builds put their language letter in.
F81D-F82D
DEFM "- Copyright 1984 " 2D 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 34 20
F81DH-F82DH, row 0 from column 29: the text and a space. The source of level AD carries 1983 here, so the year was stepped on with the release.
F82E-F841
DEFM "Logical Systems Inc." 4C 6F 67 69 63 61 6C 20 53 79 73 74 65 6D 73 20 49 6E 63 2E
F82EH-F841H, row 0 from column 46: the name of the company that wrote the system, which Tandy sold under its own name.
F842-F85D
DEFS 28
F842H-F85DH, row 0 from column 66 to row 1 column 13: not loaded, left as the spaces the boot wrote.
F85E-F872
DEFM "All Rights Reserved. " 41 6C 6C 20 52 69 67 68 74 73 20 52 65 73 65 72 76 65 64 2E 20
F85EH-F872H, row 1 from column 14: the reserved rights line and a space.
F873-F890
DEFM "Licensed to Tandy Corporation." 4C 69 63 65 6E 73 65 64 20 74 6F 20 54 61 6E 64 79 20 43 6F 72 70 6F 72 61 74 69 6F 6E 2E
F873H-F890H, row 1 from column 35: the licence line, the one line of the screen that names the arrangement between the two companies. LS-DOS 6.3.1, which Logical Systems sold itself, has no line like it.
F891-F956
DEFS 198
F891H-F956H: not loaded, the ends of the rows above and the spaces to the left of the logo.
F957-F97A
DEFB 82H, 0AFH, 0BFH x 27, 9FH, 0A1H, 84H, 90H, 80H, 74H, 6DH 82 AF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF 9F A1 84 90 80 74 6D
F957H-F97AH, screen row 4 from column 23, 36 characters: the top row of the logo. Its last two bytes, 74H and 6DH, are the letters t and m, the trademark mark at the top right.
F97B-F9A8
DEFS 46
F97BH-F9A8H: not loaded, the ends of the rows above and the spaces to the left of the logo.
F9A9-F9C9
DEFB 8BH, 0BFH x 7, 8FH x 11, 0AFH, 0BFH x 6, 87H, 98H, 0A1H, 86H, 98H, 0A1H, 84H 8B BF BF BF BF BF BF BF 8F 8F 8F 8F 8F 8F 8F 8F 8F 8F 8F AF BF BF BF BF BF BF 87 98 A1 86 98 A1 84
F9A9H-F9C9H, screen row 5 from column 25, 33 characters: row 2 of the logo.
F9CA-F9F9
DEFS 48
F9CAH-F9F9H: not loaded, the ends of the rows above and the spaces to the left of the logo.
F9FA-FA18
DEFB 82H, 0AFH, 0BFH x 5, 0BCH x 5, 80H, 0A8H, 0BCH x 4, 0BEH, 0BFH x 4, 9FH, 0A1H, 86H, 98H, 0A1H, 86H, 98H, 81H 82 AF BF BF BF BF BF BC BC BC BC BC 80 A8 BC BC BC BC BE BF BF BF BF 9F A1 86 98 A1 86 98 81
F9FAH-FA18H, screen row 6 from column 26, 31 characters: row 3 of the logo.
FA19-FA4B
DEFS 51
FA19H-FA4BH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FA4C-FA66
DEFB 8BH, 0BFH x 9, 80H, 0AAH, 0BFH x 8, 87H, 98H, 0A1H, 86H, 98H, 0A1H, 86H 8B BF BF BF BF BF BF BF BF BF 80 AA BF BF BF BF BF BF BF BF 87 98 A1 86 98 A1 86
FA4CH-FA66H, screen row 7 from column 28, 27 characters: row 4 of the logo.
FA67-FA9C
DEFS 54
FA67H-FA9CH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FA9D-FAB5
DEFB 82H, 0AFH, 0BFH x 7, 80H, 0AAH, 0BFH x 6, 9FH, 0A1H, 86H, 98H, 0A1H, 86H, 98H, 81H 82 AF BF BF BF BF BF BF BF 80 AA BF BF BF BF BF BF 9F A1 86 98 A1 86 98 81
FA9DH-FAB5H, screen row 8 from column 29, 25 characters: row 5 of the logo.
FAB6-FAEE
DEFS 57
FAB6H-FAEEH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FAEF-FB03
DEFB 8BH, 0BFH x 6, 0B0H, 0BAH, 0BFH x 5, 87H, 98H, 0A1H, 86H, 98H, 0A1H, 86H 8B BF BF BF BF BF BF B0 BA BF BF BF BF BF 87 98 A1 86 98 A1 86
FAEFH-FB03H, screen row 9 from column 31, 21 characters: row 6 of the logo.
FB04-FB3F
DEFS 60
FB04H-FB3FH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FB40-FB52
DEFB 82H, 0AFH, 0BFH x 9, 9FH, 0A1H, 86H, 98H, 0A1H, 86H, 98H, 81H 82 AF BF BF BF BF BF BF BF BF BF 9F A1 86 98 A1 86 98 81
FB40H-FB52H, screen row 10 from column 32, 19 characters: row 7 of the logo.
FB53-FB91
DEFS 63
FB53H-FB91H: not loaded, the ends of the rows above and the spaces to the left of the logo.
FB92-FBA0
DEFB 0ABH, 8FH x 7, 97H, 0A8H, 81H, 96H, 0A8H, 81H, 96H AB 8F 8F 8F 8F 8F 8F 8F 97 A8 81 96 A8 81 96
FB92H-FBA0H, screen row 11 from column 34, 15 characters: row 8 of the logo.
FBA1-FBE1
DEFS 65
FBA1H-FBE1H: not loaded, the ends of the rows above and the spaces to the left of the logo.
FBE2-FBF0
DEFB 0BAH, 0BCH x 7, 0B5H, 8AH, 90H, 0A5H, 8AH, 90H, 0A5H BA BC BC BC BC BC BC BC B5 8A 90 A5 8A 90 A5
FBE2H-FBF0H, screen row 12 from column 34, 15 characters: row 9 of the logo.
FBF1-FC2F
DEFS 63
FBF1H-FC2FH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FC30-FC42
DEFB 0A0H, 0BEH, 0BFH x 9, 0BDH, 92H, 0A4H, 89H, 92H, 0A4H, 89H, 90H A0 BE BF BF BF BF BF BF BF BF BF BD 92 A4 89 92 A4 89 90
FC30H-FC42H, screen row 13 from column 32, 19 characters: row 10 of the logo.
FC43-FC7E
DEFS 60
FC43H-FC7EH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FC7F-FC93
DEFB 0B8H, 0BFH x 2, 87H, 83H x 7, 8BH, 0BFH x 2, 0B4H, 89H, 92H, 0A4H, 89H, 92H, 0A4H B8 BF BF 87 83 83 83 83 83 83 83 8B BF BF B4 89 92 A4 89 92 A4
FC7FH-FC93H, screen row 14 from column 31, 21 characters: row 11 of the logo.
FC94-FCCC
DEFS 57
FC94H-FCCCH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FCCD-FCE5
DEFB 0A0H, 0BEH, 0BFH x 2, 81H, 0A0H, 0BEH, 0BFH x 5, 0BDH, 0B0H, 0B2H, 0BFH x 2, 0BDH, 92H, 0A4H, 89H, 92H, 0A4H, 89H, 90H A0 BE BF BF 81 A0 BE BF BF BF BF BF BD B0 B2 BF BF BD 92 A4 89 92 A4 89 90
FCCDH-FCE5H, screen row 15 from column 29, 25 characters: row 12 of the logo.
FCE6-FD1B
DEFS 54
FCE6H-FD1BH: not loaded, the ends of the rows above and the spaces to the left of the logo.
FD1C-FD36
DEFB 0B8H, 0BFH x 4, 80H, 0AAH, 0BFH x 13, 0B4H, 89H, 92H, 0A4H, 89H, 92H, 0A4H B8 BF BF BF BF 80 AA BF BF BF BF BF BF BF BF BF BF BF BF BF B4 89 92 A4 89 92 A4
FD1CH-FD36H, screen row 16 from column 28, 27 characters: row 13 of the logo.
FD37-FD69
DEFS 51
FD37H-FD69H: not loaded, the ends of the rows above and the spaces to the left of the logo.
FD6A-FD88
DEFB 0A0H, 0BEH, 0BFH x 5, 0B4H, 80H, 8BH, 8FH x 5, 87H, 80H, 0B8H, 0BFH x 5, 0BDH, 92H, 0A4H, 89H, 92H, 0A4H, 89H, 90H A0 BE BF BF BF BF BF B4 80 8B 8F 8F 8F 8F 8F 87 80 B8 BF BF BF BF BF BD 92 A4 89 92 A4 89 90
FD6AH-FD88H, screen row 17 from column 26, 31 characters: row 14 of the logo.
FD89-FDB8
DEFS 48
FD89H-FDB8H: not loaded, the ends of the rows above and the spaces to the left of the logo.
FDB9-FDD9
DEFB 0B8H, 0BFH x 8, 0BDH, 0BCH x 7, 0BEH, 0BFH x 8, 0B4H, 89H, 92H, 0A4H, 89H, 92H, 84H B8 BF BF BF BF BF BF BF BF BD BC BC BC BC BC BC BC BE BF BF BF BF BF BF BF BF B4 89 92 A4 89 92 84
FDB9H-FDD9H, screen row 18 from column 25, 33 characters: row 15 of the logo.
FDDA-FE06
DEFS 45
FDDAH-FE06H: not loaded, the ends of the rows above and the spaces to the left of the logo.
FE07-FE27
DEFB 0A0H, 0BEH, 0BFH x 27, 0BDH, 92H, 84H, 81H A0 BE BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BF BD 92 84 81
FE07H-FE27H, screen row 19 from column 23, 33 characters: row 16 of the logo.