0000H - Page 0: Restart Vectors and System Storage
SYS0/SYS loads the first page of memory, 0000H-00FFH, in pieces: the restart vectors, the system's time and date, the interrupt vectors and task table, the 26 system flags, two vectors and the control blocks of the system files. In the Model 4 memory map the DOS uses, RAM fills 0000H-FFFFH, so these addresses are RAM. The areas the file does not load (user storage, part of the date, the NMI jump, the DEBUG save area and the end of two FCBs) are shown as DEFS rows; 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 at 1BF2H uses its own five byte stub instead.
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 without that port 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 kept 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 that follow.
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 SVC a program issued, stored by the RST 28H handler at 1A4BH for every SVC but @ERROR. 0000H in the file.
000DLSVC$
DEFB 00H 00
LSVC$ (Last SVC), 000DH: the number of the last SVC a program issued, stored at 1A47H for every SVC but @ERROR (26). 00H in the file.
000EFDDINT$
DI F3
Disable interrupts. The floppy driver calls FDDINT$ (CALL 000EH at 0F3FH on the BOOT/SYS page) before a disk transfer; the source names the byte NOP or DI (F3H) for SYSTEM (SMOOTH): the DI is what SMOOTH puts here, and this file has SMOOTH on (DFLAG$ bit 3), so interrupts are off during disk I/O; SYSTEM (SMOOTH=OFF) makes it a NOP.
000F
RET C9
Return from FDDINT$ to the floppy 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 kept for programs' own use. SYS0/SYS does not load them, so they hold what 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: the drive select byte last sent to port F4H by the floppy driver, which reselects the drive with it while it waits (0E87H, 0ED4H and 0F2EH on the BOOT/SYS page). 01H in the file, the select bit of drive 0.
001C-001DPHIGH$
DEFW 0000H 00 00
PHIGH$ (Physical HIGH$), 001CH-001DH: the highest address of memory. 0000H in the file; the start-up code at 1E55H stores FFFFH here.
001E-001FLOW$
DEFW 3000H 00 30
LOW$, 001EH-001FH = 3000H in the file: the low limit of the memory for programs, read and set by @HIGH$ (SVC 100) with Register B not zero (1962H and 1965H). SYS1/SYS sets it to 2FFFH, the last byte below 3000H, on every @EXIT and @CMNDI (CLEANUP), so the 3000H of the file holds only during 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 current disk request, stored by the disk SVC front end at 1A04H from Register C and read by TAPDRV at 19B8H. 00H in the file.
0024-0025JDCB$
DEFW 0000H 00 00
JDCB$, 0024H-0025H: the FCB or DCB 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 SVC handler: a program loads Register A with an SVC number and issues RST 28H.
002BTIMSL$
DEFB 55H 55
TIMSL$ (Time Slice), 002BH = 55H (01010101 binary). The clock interrupt routine at 1C9BH rotates it left each interrupt and runs the clock and tasks 0 to 10 only when a 1 bit comes out: with 55H every second interrupt (the fast setting), with FFH every one.
002CTIMER$
DEFB 00H 00
TIMER$, 002CH: the heartbeat counter, incremented at 1CB7H on every interrupt that runs the clock; its low three bits pick which of tasks 0 to 7 runs. 00H in the file.
002D-002FTIME$
DEFB 00H, 00H, 00H 00 00 00
TIME$, 002DH-002FH: the time of day in binary, seconds at 002DH, minutes at 002EH and hours at 002FH, kept by the clock task. The start-up code at 1FE2H copies the time typed at the prompt here.
0030@RST30
Jump to @DEBUG at 19A0H: RST 30H enters the system debugger.
0033-0035DATE$
DEFS 3
DATE$, 0033H-0035H: the date in binary, the year less 1900 at 0033H, the day at 0034H and the month at 0035H. SYS0/SYS does not load them, so a date still in memory after a reset survives; the start-up code at 1EA3H reads and checks them.
0036
DEFB 00H 00
DATE$+3, 0036H: the low eight bits of the day of the year, stored by the start-up code at 1F2FH. The file loads 00H here, a change of LS-DOS 6.3.1.
0037
DEFS 1
DATE$+4, 0037H, not loaded: bit 0 is bit 8 of the day of the year, bits 3-1 the day of the week (1 to 7) and bit 7 the leap year flag, all set by the start-up code (1EE7H, 1F33H, 1F55H).
0038@RST38
Jump to RST38@ at 1BFFH, the interrupt handler of the task processor. The boot code stored a RET at 0038H; SYS0/SYS loads this jump over it and the start-up code at 20C6H stores C3H here again (STUB, run at 4398H) to activate the task processor.
003BOSRLS$
DEFB 01H 01
OSRLS$ (OS Release), 003BH = 01H, the release number of the operating system: 6.3.1 with OSVER$ (0085H) = 63H.
003CINTIM$
DEFB 00H 00
INTIM$ (Interrupt Image), 003CH: the interrupt latch read from port E0H by the interrupt handler at 1C1EH, inverted so that a set bit is a device asking for service.
003DINTMSK$
DEFB 2CH 2C
INTMSK$ (Interrupt Mask), 003DH = 2CH: the bits of INTIM$ the interrupt handler serves. 2CH is bits 2 (real time clock), 3 (I/O bus) and 5 (RS-232 receive), the only interrupts the task processor allows.
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: bit 0, 1 and 3 point to RETINST (a RET at 1C48H) and bit 2, the real time clock, to RTCPROC at 1C94H.
0046-004D
DEFW 1C48H, 1C48H, 1C48H, 1C48H 48 1C 48 1C 48 1C 48 1C
INTVC$+8, 0046H-004DH: the vectors of interrupt bits 4 to 7, all RETINST (1C48H), a RET. A driver that uses an interrupt (the RS-232 driver for bit 5) stores its own routine's address 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 to 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 NOTASK (1CE9H). Slots 0 to 7 each run on every eighth clock tick, chosen by 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 (1CE9H); slot 10 holds TYPTSK$ at 0B26H, the type-ahead task of the keyboard driver. Slots 8 to 10 run on every clock tick, slot 11 on every real time clock interrupt.
0066-0068@NMI
DEFS 3
@NMI, 0066H-0068H: the non maskable interrupt vector, not loaded by SYS0/SYS. The boot code made it JP 43CDH for its own reads; the start-up code at 1E01H stores 0FE9H (@RSTNMI) at 0067H, so the disk controller's NMI goes to the floppy driver.
0069OVRLY$
DEFB 00H 00
OVRLY$ (Overlay), 0069H: the request code of the system overlay last executed, stored by the RST 28H handler at 1A71H; its low four bits name the overlay that is resident at 1E00H.
006AAFLAG$
DEFB 01H 01
FLGTAB$ / AFLAG$, 006AH = 01H: the first of the 26 system flags A to Z that @FLAGS (SVC 101) points Index Register IY to. AFLAG$ is the cylinder where the search for free space starts.
006B
DEFB 00H 00
BFLAG$, 006BH: system flag B, 00H in the file.
006CCFLAG$
DEFB 00H 00
CFLAG$ (Condition Flag), 006CH: bit 0 HIGH$ cannot be changed by SVC 100, 1 @CMNDR running, 2 @KEYIN called from SYS1, 3 system request for drivers, filters and drive tables, 4 @CMNDR to run only library commands, 5 SYSGEN inhibited, 6 @ERROR shows nothing, 7 @ERROR uses the caller's buffer at Register Pair DE. 00H in the file.
006DDFLAG$
DEFB 0AH 0A
DFLAG$ (Device Flag), 006DH = 0AH: bit 0 SPOOL active, 1 type-ahead active, 2 VERIFY on, 3 SMOOTH active, 4 MemDISK active, 5 FORMS active, 6 KSM active, 7 graphics accepted in a screen print. 0AH sets bits 1 and 3.
006EEFLAG$
DEFB 00H 00
EFLAG$, 006EH: when not zero, SYS1 runs SYS13 with bits 4, 5 and 6 of this byte merged into the SYS13 request; a program sets it to have its own entry code passed. 00H in the file.
006FFEMSK$
DEFB 00H 00
FEMSK$ (Port FE Mask), 006FH: the value the start-up code at 1E74H 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 0 to 2 the French, German and Swiss character sets, bit 6 special printer mode, bit 7 seven bit mode. 00H in this United States build.
0073
DEFB 00H 00
JFLAG$, 0073H: system flag J, 00H in the file.
0074KFLAG$
DEFB 00H 00
KFLAG$ (Keyboard Flag), 0074H: bit 0 BREAK latched, 1 PAUSE latched, 2 ENTER latched, 5 CAPS lock, 7 a character in the type-ahead buffer; set and read by the keyboard driver on the BOOT/SYS page. 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 8 inch drives, bit 5 FORMAT does not ask for the number of sides, bits 6 and 7 kept for interrupt mode 2 hardware. 11H sets bits 0 and 4.
0076MODOUT$
DEFB 78H 78
MODOUT$, 0076H = 78H: the copy of port ECH, sent there by the start-up code at 1E3BH. Bit 1 cassette motor, 2 40 characters a line, 3 alternate character set, 4 external I/O bus on, 5 video wait states, 6 4 MHz clock; 78H sets bits 3 to 6.
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 runs (1C09H, 1C43H). 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 = 11 give RAM at every address, bit 2 the 80 by 24 display, bit 7 the second page of video memory; the start-up code at 1E4DH sends it to the port.
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, read by the floppy driver (0F46H on the BOOT/SYS page). 00H in the file.
007BRFLAG$
DEFB 08H 08
RFLAG$ (Retry Flag), 007BH = 08H: the number of tries the floppy driver makes before it reports a disk error; the source asks for at least 2.
007CSFLAG$
DEFB 08H 08
SFLAG$ (System Flag), 007CH = 08H: bit 0 do not set the open bit of a file, 1 an EXEC only file was opened, 2 @RUN may load an EXEC only file, 3 SYSTEM (FAST), 4 BREAK disabled, 5 JCL active, 6 extended error messages, 7 DEBUG to run after the load. 08H is the FAST bit.
007DTFLAG$
DEFB 04H 04
TFLAG$ (Type Flag), 007DH = 04H, the machine type, Model 4. STUB at 20C0H (run at 4392H) stores 05H instead when it finds the Model 4P boot ROM's leftovers.
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 display, 5 the blink phase, 6 the user's solid cursor, 7 no blinking while the video driver works. 00H in the file.
0080WRINT$
DEFB 04H 04
WRINT$, 0080H = 04H: the interrupt enable mask sent to port E0H by the start-up code at 1E40H. Bit 0 and 1 cassette edges, 2 real time clock, 3 I/O bus, 4 RS-232 transmit, 5 RS-232 receive, 6 RS-232 error; 04H enables only the clock.
0081
DEFB 00H 00
XFLAG$, 0081H: system flag X, 00H in the file.
0082YFLAG$
DEFB 0FFH FF
YFLAG$, 0082H = FFH: bits 0 to 7 mark drives 0 to 7 as using the new style of directory dating.
0083
DEFB 00H 00
ZFLAG$, 0083H: system flag Z, the last of the 26, 00H in the file.
0084
DEFB 01H 01
0084H = 01H, the high byte of the address of the SVC table SVCTAB$ at 0100H.
0085OSVER$
DEFB 63H 63
OSVER$ (OS Version), 0085H = 63H: the operating system version, 6.3.
0086@ICNFG
RET C9
Return at once to the address on the stack: @ICNFG is the chain vector for configuration initialization, called by STUB at 208EH (run at 4360H) after a SYSGEN configuration is loaded. A driver set up by the configuration stores a JP here to its own start-up routine.
0087-0088
DEFW 0000H 00 00
0087H-0088H: the 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 (CALL 0089H at 0925H on the BOOT/SYS page). A filter that wants a look at each keyboard scan stores a JP here.
008A-008B
DEFW 0000H 00 00
008AH-008BH: the 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 FCB through which the RST 28H handler reads the system overlays. FCB+0 = 80H (an open file), FCB+1 = 00H (set to 20H at 1AB0H before each read), FCB+2 = 00H.
008F-0090
DEFW 1D00H 00 1D
SFCB$+3, 008FH-0090H = 1D00H, the buffer of the system FCB: SBUFF$, the system's sector buffer.
0091
DEFB 00H 00
SFCB$+5, 0091H: the offset of the next byte in the buffer, 00H.
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 +19, 0092H-009FH: drive 0 and DEC 00H (0093H, set to the overlay's directory entry code at 1AAAH), EOF offset 00H and LRL 00H (256), NRN 0000H (zeroed at 1AB5H), ERN FFFFH, the first extent 0000H at 009AH-009BH and FFFFH in the two words after it, which 1ACEH fills with the granule count and the second extent.
00A0-00BFDBGSV$
DEFS 32
DBGSV$ (DEBUG Save Area), 00A0H-00BFH: 32 bytes where the debugger keeps the registers of the program it stopped. Not loaded.
00C0-00C2JFCB$
DEFB 00H, 00H, 00H 00 00 00
JFCB$ (JCL File Control Block), 00C0H-00C2H: the FCB used when a DO file supplies the input; its first three bytes are zero in the file.
00C3-00C4
DEFW 1D00H 00 1D
JFCB$+3, 00C3H-00C4H = 1D00H: the buffer of the JCL FCB, SBUFF$.
00C5-00DF
DEFS 27
JFCB$+5 to +31, 00C5H-00DFH: the rest of the JCL FCB, 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
CFCB$ / CFGFCB$, 00E0H-00F0H: the command interpreter's FCB, which in the file holds the filespec CONFIG/SYS.CCC:0 (password CCC, drive 0) ended by 03H; the start-up code at 2061H loads the SYSGEN configuration through it.
00F1-00FF
DEFS 15
CFCB$+17 to +31, 00F1H-00FFH: the rest of the command FCB, not loaded. The start-up code uses 00FDH-00FFH for the date and the time it reads at the prompts.
0100H - SVCTAB$: The Supervisor Call Table
SVCTAB$, 0100H-01FFH, holds one address for each of the 128 SVC numbers. RST28 at 1A5BH doubles an SVC number below 128 into the low byte of an address in page 01H and jumps to the word there with Register A loaded from Register C. Many entries point to short stubs at 197BH-19B4H that pass the request on to a system overlay. Numbers 23, 36 to 39, 84, 92 and 108 to 127 are unassigned and point to SVCERR at 1AF4H, which shows and logs Error 2BH (43, SVC parameter error) through SYSERR and aborts the program.
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, 1420H, 078DH 82 03 87 19 20 14 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 1420H; 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, 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: SVCs 36 to 39, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
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 @RENAME at 1996H; SVC 57 @REMOVE at 19A6H; SVC 58 @INIT (open or create a file) at 198DH; SVC 59 @OPEN (open a file) at 198AH.
0178-017F
DEFW 1999H, 14ADH, 158FH, 14DAH 99 19 AD 14 8F 15 DA 14
SVCTAB$+78H, 0178H-017FH: SVC 60 @CLOSE (close a file) at 1999H; SVC 61 @BKSP (back up one record) at 14ADH; SVC 62 @CKEOF (check for end of file) at 158FH; SVC 63 @LOC (current record number) at 14DAH.
0180-0187
DEFW 1505H, 14C9H, 145BH, 1513H 05 15 C9 14 5B 14 13 15
SVCTAB$+80H, 0180H-0187H: SVC 64 @LOF (end of file record number) at 1505H; SVC 65 @PEOF (position to end of file) at 14C9H; SVC 66 @POSN (position to a record) at 145BH; SVC 67 @READ (read a record) at 1513H.
0188-018F
DEFW 14C2H, 149AH, 13ADH, 13A0H C2 14 9A 14 AD 13 A0 13
SVCTAB$+88H, 0188H-018FH: SVC 68 @REW (rewind) at 14C2H; SVC 69 @RREAD (reread a record) at 149AH; SVC 70 @RWRIT (rewrite a sector) at 13ADH; SVC 71 @SEEKSC (seek a sector, a no-op) at 13A0H.
0190-0197
DEFW 1457H, 1560H, 1430H, 1531H 57 14 60 15 30 14 31 15
SVCTAB$+90H, 0190H-0197H: SVC 72 @SKIP (skip a record) at 1457H; SVC 73 @VER (write and verify) at 1560H; SVC 74 @WEOF (write the end of file) at 1430H; 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, 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, 06F8H F4 1A 27 19 E3 06 F8 06
SVCTAB$+B8H, 01B8H-01BFH: SVC 92 unassigned (SVCERR, 1AF4H); SVC 93 @DIV8 at 1927H; SVC 94 @DIV16 at 06E3H; SVC 95 @HEXD (hexadecimal digits) at 06F8H.
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, 0935H 92 03 45 05 53 05 35 09
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 @VDPRT (print the screen) at 0935H.
01D8-01DF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+D8H, 01D8H-01DFH: SVCs 108 to 111, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
01E0-01E7
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+E0H, 01E0H-01E7H: SVCs 112 to 115, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
01E8-01EF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+E8H, 01E8H-01EFH: SVCs 116 to 119, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
01F0-01F7
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+F0H, 01F0H-01F7H: SVCs 120 to 123, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
01F8-01FF
DEFW 1AF4H, 1AF4H, 1AF4H, 1AF4H F4 1A F4 1A F4 1A F4 1A
SVCTAB$+F8H, 01F8H-01FFH: SVCs 124 to 127, all unassigned; each word is 1AF4H, SVCERR, which shows and logs Error 2BH and aborts the program.
0380H - @PAUSE, @SOUND, @DECHEX and the Reboot Stub
SYS0/SYS loads 0380H-03FFH just above the system stack, which grows down from STACK$ (0380H) over 0300H-037FH. The page holds @PAUSE (SVC 16), @SOUND (SVC 104), @DECHEX (SVC 96) and the five byte stub that @IPL copies to 4300H to restart the machine.
0380-0381
DEFW 0000H 00 00
0380H-0381H: two zero bytes at STACK$, the top of the system stack, which the source calls the stack guard. The start-up code at 1E21H clears 0300H-0380H.
0382@PAUSE
PUSH BC C5
Save Register Pair BC (the delay count) on the stack. @PAUSE (SVC 16) waits for the count in Register Pair BC, 26 clock cycles a pass.
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, the SYSTEM (FAST) bit: at 4 MHz the delay loop runs twice as fast.
0388
If the FAST bit is set (NZ), call CDLOOP at 038CH to count Register Pair BC down once before the count below, doubling the delay.
038B
POP BC C1
Restore Register Pair BC (the delay count) from the stack for the count down.
038CCDLOOP
DEC BC 0B
Decrement Register Pair BC, the delay count.
038D
LD A,B 78
Copy Register B (the high byte of the count) into Register A.
038E
OR C B1
OR Register C (the low byte) into Register A: Z when Register Pair BC has reached 0000H.
038F
If Register Pair BC is not zero, loop back to 038CH (CDLOOP).
0391
RET C9
Return with Register Pair BC = 0000H and Register A = 00H.
0392@SOUND
PUSH BC C5
Save Register Pair BC on the stack. @SOUND (SVC 104) plays a tone: Register B bits 2-0 pick the note (0 the highest, 7 the lowest) and bits 7-3 the duration.
0393
PUSH HL E5
Save Register Pair HL on the stack; the tone loop uses it for its counts.
0394
LD A,B 78
Copy Register B (the sound code) into Register A.
0395
AND 07H E6 07
Mask Register A with 07H, keeping bits 2-0, the note number.
0397
RLCA 07
Rotate Register A left: the note number times 2, the offset of its two byte entry in the tone table.
0398
LD HL,03D1H 21 D1 03LD HL,SNDTAB
Point Register Pair HL to 03D1H (SNDTAB), the tone table of eight two byte entries.
039B
LD C,A 4F
Copy Register A (the table offset) into Register C.
039C
LD A,B 78
Load Register A with Register B, the sound code again, for its duration bits.
039D
LD B,00H 06 00
Load Register B with 00H, so Register Pair BC is the table offset.
039F
ADD HL,BC 09
Add Register Pair BC (the offset) to Register Pair HL (03D1H): Register Pair HL points to the note's entry.
03A0
LD C,(HL) 4E
Load Register C with the first byte of the entry at Register Pair HL, the half cycle count of the note (its 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.
03A3
RRCA 0F
Rotate Register A (the sound code) right: bits 7-3, the duration, move toward bit 0.
03A4
RRCA 0F
Rotate Register A right a second time, the duration moving on toward bits 4-0.
03A5
RRCA 0F
Rotate Register A right a third time: the duration is now in bits 4-0.
03A6
AND 1FH E6 1F
Mask Register A with 1FH, keeping the duration, 0 to 31.
03A8
INC A 3C
Increment Register A, so a duration of 0 plays one unit.
03A9
LD H,A 67
Copy Register A (the number of units) into Register H, the sound counter.
03AA
LD A,(007CH) 3A 7C 00LD A,(SFLAG$)
Load Register A with 007CH (SFLAG$), the system flags.
03AD
AND 08H E6 08
Mask Register A with 08H, the SYSTEM (FAST) bit.
03AF
If the machine runs at the slow speed (Z), jump to 03B7H; at 4 MHz the three counts are doubled first.
03B1
SLA H CB 24
Shift Register H (the number of units) left: twice as many units.
03B3
SLA L CB 25
Shift Register L (the cycles a unit) left: twice as many cycles.
03B5
SLA C CB 21
Shift Register C (the half cycle count) left: the same pitch at the faster clock.
03B7
DI F3
Disable interrupts: an interrupt would upset the timing of the tone.
03B8
PUSH HL E5
Save Register Pair HL (Register H the units left, Register L the cycles a unit) on the stack for the next unit.
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, bit 0 set, the sound output high.
03BC
OUT (90H),A D3 90
Send Register A (01H) to port 90H, the sound port: the speaker line goes high.
03BE
Decrement Register B and jump back to 03BEH, this same instruction, until Register B is zero: the high half of the cycle.
03C0
LD B,C 41
Load Register B with Register C, the half cycle count, again.
03C1
INC A 3C
Increment Register A to 02H, bit 0 clear, the sound output low.
03C2
OUT (90H),A D3 90
Send Register A (02H) to port 90H: the speaker line goes low.
03C4
Decrement Register B and jump back to 03C4H, this same instruction, until Register B is zero: the low half of the cycle.
03C6
DEC L 2D
Decrement Register L, the cycles left in this unit.
03C7
If Register L is not zero, loop back to 03B9H for the next cycle.
03C9
POP HL E1
Restore Register Pair HL from the stack: Register L the cycles a unit again, Register H the units left.
03CA
DEC H 25
Decrement Register H, the units of duration left.
03CB
If Register H is not zero, loop back to 03B8H for the next unit.
03CD
EI FB
Enable interrupts again: the tone is over and its timing no longer matters.
03CE
POP HL E1
Restore Register Pair HL (the caller's value, saved at 0393H) from the stack.
03CF
POP BC C1
Restore Register Pair BC (the caller's sound code, saved at 0392H) from the stack.
03D0
RET C9
Return to the caller of @SOUND with Register Pairs BC and HL as they were.
03D1-03D2SNDTAB
DEFB 50H, 4CH 50 4C
SNDTAB, 03D1H-03D2H: note 0, the highest: half cycle count 50H (80) and 4CH (76) cycles a unit.
03D3-03D4
DEFB 56H, 48H 56 48
SNDTAB+2, 03D3H-03D4H: note 1, half cycle count 56H (86) and 48H (72) cycles a unit.
03D5-03D6
DEFB 5CH, 44H 5C 44
SNDTAB+4, 03D5H-03D6H: note 2, half cycle count 5CH (92) and 44H (68) cycles a unit.
03D7-03D8
DEFB 62H, 40H 62 40
SNDTAB+6, 03D7H-03D8H: note 3, half cycle count 62H (98) and 40H (64) cycles a unit.
03D9-03DA
DEFB 6BH, 3CH 6B 3C
SNDTAB+8, 03D9H-03DAH: note 4, half cycle count 6BH (107) and 3CH (60) cycles a unit.
03DB-03DC
DEFB 72H, 38H 72 38
SNDTAB+10, 03DBH-03DCH: note 5, half cycle count 72H (114) and 38H (56) cycles a unit.
03DD-03DE
DEFB 79H, 34H 79 34
SNDTAB+12, 03DDH-03DEH: note 6, half cycle count 79H (121) and 34H (52) cycles a unit.
03DF-03E0
DEFB 80H, 30H 80 30
SNDTAB+14, 03DFH-03E0H: note 7, the lowest: half cycle count 80H (128) and 30H (48) cycles a unit. Lower notes get fewer cycles, so every note's unit lasts about as long.
03E1@DECHEX
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value so far. @DECHEX (SVC 96) converts the decimal digits at Register Pair HL to a binary value in Register Pair BC and stops at the first character that is not a digit, with Register Pair HL pointing to it.
03E4DEC1
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
03E5
SUB 30H D6 30
Subtract 30H (the character 0) from Register A, turning a digit into its value.
03E7
RET C D8
Return if the character was below 0 (Carry), with the value in Register Pair BC and Register Pair HL at the character.
03E8
CP 0AH FE 0A
Compare Register A (the character less 30H) with 0AH, the first value that is not a digit.
03EA
RET NC D0
Return if Register A is 0AH or more (No Carry): the character was above 9.
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 top of the stack (Stack Pointer): Register Pair HL holds the value and the stack holds the text pointer.
03ED
ADD HL,HL 29
Add Register Pair HL to itself: the value times 2.
03EE
ADD HL,HL 29
Add Register Pair HL to itself again: the value times 4.
03EF
ADD HL,BC 09
Add Register Pair BC (the value) to Register Pair HL: the value times 5.
03F0
ADD HL,HL 29
Add Register Pair HL to itself: the value times 10.
03F1
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit to be added.
03F3
LD C,A 4F
Copy Register A (the digit's value) into Register C, so Register Pair BC is the digit.
03F4
ADD HL,BC 09
Add Register Pair BC (the digit) to Register Pair HL: the new value.
03F5
LD B,H 44
Copy Register H (the high byte of the new value) into Register B.
03F6
LD C,L 4D
Copy Register L into Register C: Register Pair BC holds the new value.
03F7
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
03F8
INC HL 23
Increment Register Pair HL to the next character.
03F9
Loop back to 03E4H (DEC1) for the next digit.
03FBBOOTCOD
DI F3
Disable interrupts. These five bytes (03FBH-03FFH) are copied to 4300H-4304H by @IPL at 1BF2H and run there, out of the way of the ROM.
03FC
XOR A AF
Clear Register A to 00H, the Operation Register value of the Model III memory map with the ROM at 0000H.
03FD
OUT (84H),A D3 84
Send Register A (00H) to port 84H, the Operation Register: the ROM comes back into the memory map at 0000H.
03FF
RST 00H C7
Restart at 0000H, now the ROM's reset entry, which boots the machine 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 1412H: 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 1412H: 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.
13A0@SEEKSC / ZEROA@
XOR A AF
Clear Register A to 00H and set the Z flag. @SEEKSC (SVC 71) comes here and does nothing more.
13A1
RET C9
Return to the caller with Register A = 00H and Z.
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 140BH: 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 1436H (WEOF1) to write the end of file into the directory now.
140A
RET C9
Return to the caller with Z (from the BIT test): the sector is written.
140BH - GETNRN, BFRPOS and @DATE
Two small helpers of the file routines, and @DATE, which LS-DOS 6.3.1 puts here in place of the old date code: it calls DATELO$ in BOOT/SYS and corrects the tens digit of years 2000 to 2011.
140BGETNRN
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 (NRN).
140E
LD H,(IX+0BH) DD 66 0B
Load Register H with FCB+11 (Index Register IX+0BH), the high byte: Register Pair HL = the NRN.
1411
RET C9
Return to the caller with the NRN in Register Pair HL.
1412BFRPOS
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.
1415
ADD A,(IX+03H) DD 86 03
Add FCB+3 (Index Register IX+03H), the low byte of the buffer address, to Register A.
1418
LD E,A 5F
Copy Register A (the low byte of the byte's address) into Register E.
1419
LD A,(IX+04H) DD 7E 04
Load Register A with FCB+4 (Index Register IX+04H), the high byte of the buffer address.
141C
ADC A,00H CE 00
Add 00H with the Carry of the low byte addition to Register A, the high byte of the byte's address.
141E
LD D,A 57
Copy Register A into Register D: Register Pair DE = the buffer address plus the offset.
141F
RET C9
Return to the caller with Register Pair DE pointing to the next byte in the buffer.
1420@DATE
Call DATELO$ at 07A8H to write the date from DATE$ as MM/DD/YY into the buffer at Register Pair HL; it returns Register Pair HL just past the year. @DATE is SVC 18.
1423
PUSH HL E5
Save Register Pair HL (the end of the text) on the stack.
1424
DEC HL 2B
Decrement Register Pair HL to the second digit of the year.
1425
DEC HL 2B
Decrement Register Pair HL again, to the first digit of the year.
1426
LD A,(HL) 7E
Load Register A with the first digit of the year at Register Pair HL.
1427
CP 3AH FE 3A
Compare Register A with 3AH, the character after 9: DATELO$ makes a year byte of 100 to 111 (2000 to 2011) into a first digit of 3AH or 3BH.
1429
If the digit is 0 to 9 (Carry), jump to 142EH (DATE1); nothing to correct.
142B
SUB 0AH D6 0A
Subtract 0AH from Register A, turning 3AH or 3BH into the digit 0 or 1.
142D
LD (HL),A 77
Store the corrected digit (Register A) back at Register Pair HL: the year shows as 00 to 11.
142EDATE1
POP HL E1
Restore Register Pair HL (just past the date text) from the stack.
142F
RET C9
Return to the caller of @DATE with Register Pair HL past the eight characters.
1430H - @WEOF: Write the End of File to the Directory
@WEOF (SVC 74) writes back the buffer if it holds changed data, then copies the end of file offset (FCB+8) and the ERN (FCB+12/+13) into the file's directory entry. YESEOF at 1408H enters at WEOF1 when a filespec ended with an exclamation mark.
1430@WEOF
Call CKOPEN@ at 1568H to check the FCB at Register Pair DE, point Index Register IX to it and save the registers.
1433
Call RWRIT@ at 13A2H to write the buffer to the disk if it holds changed data of a byte I/O file.
1436WEOF1
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.
1439
LD C,(IX+06H) DD 4E 06
Load Register C with FCB+6 (Index Register IX+06H), the drive of the file.
143C
Call @DIRRD at 18BBH to read the directory sector of entry Register B on drive Register C; Register Pair HL points to the entry in SBUFF$ (1D00H).
143F
RET NZ C0
Return if the directory could not be read, NZ with the error code in Register A.
1440
INC L 2C
Increment Register L, pointing Register Pair HL to the entry's byte 1.
1441
INC L 2C
Increment Register L, pointing Register Pair HL to the entry's byte 2.
1442
INC L 2C
Increment Register L to the entry's byte 3, the end of file offset.
1443
LD A,(IX+08H) DD 7E 08
Load Register A with FCB+8 (Index Register IX+08H), the end of file offset of the FCB.
1446
LD (HL),A 77
Store Register A into the directory entry's end of file offset at Register Pair HL.
1447
LD DE,0011H 11 11 00
Load Register Pair DE with 0011H, the distance from entry byte 3 to entry byte 14H, the ERN.
144A
ADD HL,DE 19
Add Register Pair DE (0011H) to Register Pair HL: Register Pair HL points to the entry's ERN.
144B
LD A,(IX+0CH) DD 7E 0C
Load Register A with FCB+12 (Index Register IX+0CH), the low byte of the ERN.
144E
LD (HL),A 77
Store Register A into the low byte of the directory's ERN at Register Pair HL.
144F
INC HL 23
Increment Register Pair HL to the high byte of the directory's ERN.
1450
LD A,(IX+0DH) DD 7E 0D
Load Register A with FCB+13 (Index Register IX+0DH), the high byte of the ERN.
1453
LD (HL),A 77
Store Register A into the high byte of the directory's ERN at Register Pair HL.
1454
Jump to @DIRWR at 1803H to write the directory sector back, which returns to the caller.
1457H - @SKIP and @POSN: Position to a Record
@POSN (SVC 66) positions the file at record Register Pair BC: with a logical record length (LRL) below 256 it multiplies the record number by the LRL to find the sector and the offset. If the buffer already holds that sector nothing is read; otherwise the buffer is written back if changed and marked not current. @SKIP (SVC 72) finds the current record with @LOC and positions to the one after it. Both return the end of file status of CKEOF1.
1457@SKIP
Call @LOC at 14DAH: Register Pair BC = the number of the current record.
145A
INC BC 03
Increment Register Pair BC to the next record, and fall into @POSN to go there.
145B@POSN
Call CKOPEN@ at 1568H to check the FCB at Register Pair DE, point Index Register IX to it, save the registers and clear Register A.
145E
SET 6,(IX+01H) DD CB 01 F6
Set bit 6 of FCB+1 (Index Register IX+01H): after a position the end of file moves only when the file grows.
1462
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.
1466
If the file is used only by whole sectors (Z), jump to 1485H (POSN1): the record number is the sector number, offset 0 (Register A).
1468
LD H,B 60
Copy Register B (the high byte of the record number) into Register H.
1469
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the record number.
146A
OR (IX+09H) DD B6 09
OR FCB+9 (Index Register IX+09H), the LRL, into Register A (00H): Z when the LRL is 0, meaning 256.
146D
If the LRL is 256 (Z), jump to 1485H (POSN1): one record a sector, offset 0.
146F
Call @MUL16 at 06C9H to multiply Register Pair HL (the record number) by Register A (the LRL): Registers H and L hold the sector and Register A the offset in it.
1472
LD B,H 44
Copy Register H (the high byte of the sector number) into Register B.
1473
LD C,L 4D
Copy Register L (the low byte) into Register C: Register Pair BC = the sector of the record.
1474
LD (IX+05H),A DD 77 05
Store Register A (the offset) into FCB+5 (Index Register IX+05H), the offset of the next byte.
1477
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.
147B
If the buffer is not current, jump to 1488H (POSN2) to point the NRN at the record's sector.
147D
Call GETNRN at 140BH: Register Pair HL = the NRN, one past the sector in the buffer.
1480
SCF 37
Set the Carry flag, so the subtraction below takes one more.
1481
SBC HL,BC ED 42
Subtract Register Pair BC (the record's sector) and the Carry from Register Pair HL: Z when the buffer already holds that sector.
1483
In that case jump to 1497H ($CKEOF): the position is set, only the end of file is checked.
1485POSN1
LD (IX+05H),A DD 77 05
Store Register A (the offset, 00H for whole sectors) into FCB+5 (Index Register IX+05H).
1488POSN2
PUSH BC C5
Save Register Pair BC (the sector to go to) on the stack.
1489POSN2A
Call RWRIT@ at 13A2H to write the buffer back first if it holds changed data.
148C
POP BC C1
Restore Register Pair BC (the sector to go to) from the stack.
148D
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
148E
LD (IX+0AH),C DD 71 0A
Store Register C into FCB+10 (Index Register IX+0AH), the low byte of the NRN.
1491
LD (IX+0BH),B DD 70 0B
Store Register B into FCB+11 (Index Register IX+0BH), the high byte of the NRN.
1494
Call SET5 at 132AH: the buffer does not hold the new current sector, which the next read fetches.
1497$CKEOF
Jump to CKEOF1 at 1592H to return Z before the end of file, or NZ with 1CH or 1DH in Register A.
149AH - @RREAD and @BKSP: Reread or Back Up a Record
@RREAD (SVC 69) moves back to the sector just read so the next read gets it again. @BKSP (SVC 61) backs up one logical record: with an LRL below 256 it subtracts the LRL from the offset and steps the NRN back only when the offset crosses into the previous sector. Register C tells ADJUST at 15BAH whether to count a partly read sector (1 for @RREAD, 0 for @BKSP).
149A@RREAD
Call CKOPEN@ at 1568H to check the FCB at Register Pair DE, point Index Register IX to it and save the registers.
149D
LD C,01H 0E 01
Load Register C with 01H, so ADJUST at 15BAH steps forward for a sector that is partly read.
149FBKSP1
Call GETNRN at 140BH: Register Pair HL = the NRN.
14A2
LD A,H 7C
Copy Register H (the high byte of the NRN) into Register A.
14A3
OR L B5
OR Register L into Register A: Z when the NRN is 0000H.
14A4
If the file is rewound (Z), jump to 14BBH (BKSP0) with Register A = 00H: the offset is set to 0 and nothing else is done.
14A6
DEC HL 2B
Decrement Register Pair HL (the NRN) to the sector before it, one sector back.
14A7
Call 15BAH (ADJUST) with Register C: for byte I/O, step Register Pair HL forward if Register C is not zero and back if the buffer is current (FCB+1 bit 5 clear).
14AA
PUSH HL E5
Save Register Pair HL (the sector to go to) on the stack; POSN2A pops it into Register Pair BC.
14AB
Jump to 1489H (POSN2A) to write the buffer back if needed and set the NRN to the sector.
14AD@BKSP
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and clear Register A.
14B0
LD C,A 4F
Copy Register A (00H) into Register C, so ADJUST at 15BAH does not step forward.
14B1
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the LRL.
14B4
OR B B0
OR Register B into Register A (00H): Z when the LRL is 0, meaning 256.
14B5
If the LRL is 256 (Z), jump to 149FH (BKSP1) to back up one whole sector.
14B7
LD A,(IX+05H) DD 7E 05
Load Register A with FCB+5 (Index Register IX+05H), the offset of the next byte.
14BA
SUB B 90
Subtract Register B (the LRL) from Register A: the offset of the record before; Carry when it lies in the previous sector.
14BBBKSP0
LD (IX+05H),A DD 77 05
Store Register A (the new offset) into FCB+5 (Index Register IX+05H).
14BE
If the subtraction crossed the start of the sector (Carry), jump to 149FH (BKSP1) to step the NRN back as well.
14C0
XOR A AF
Clear Register A to 00H and set the Z flag: the record is backed up inside the buffer.
14C1
RET C9
Return to the caller with Register A = 00H and Z.
14C2H - @REW and @PEOF: Rewind and Position to the End of File
@REW (SVC 68) sets the position to record 0, offset 0. @PEOF (SVC 65) positions to the end of file: sector ERN at offset 0 when the file ends on a sector boundary, otherwise the last sector (ERN-1) at the end of file offset. Both finish through POSN1.
14C2@REW
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and clear Register A to 00H.
14C5
LD B,A 47
Copy Register A (00H) into Register B, the high byte of the sector number.
14C6
LD C,A 4F
Copy Register A (00H) into Register C: Register Pair BC = sector 0.
14C7
Jump to 1485H (POSN1) to set offset Register A (0) and NRN Register Pair BC (0).
14C9@PEOF
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and clear Register A to 00H.
14CC
LD C,(IX+0CH) DD 4E 0C
Load Register C with FCB+12 (Index Register IX+0CH), the low byte of the ERN.
14CF
LD B,(IX+0DH) DD 46 0D
Load Register B with FCB+13 (Index Register IX+0DH), the high byte: Register Pair BC = the ERN.
14D2
OR (IX+08H) DD B6 08
OR FCB+8 (Index Register IX+08H), the end of file offset, into Register A: Z when the file ends on a sector boundary.
14D5
If it does (Z), jump to 1485H (POSN1): position to sector ERN at offset 0.
14D7
DEC BC 0B
Decrement Register Pair BC to the last sector of the file, which holds the end of file.
14D8
Jump to 1485H (POSN1): position to sector Register Pair BC at the end of file offset in Register A.
14DAH - @LOC and @LOF: Current and Last Record Numbers
@LOC (SVC 63) returns in Register Pair BC the number of the current logical record and @LOF (SVC 64) the number of records in the file. With an LRL of 256 the number is the sector count; otherwise the byte position (sector times 256 plus offset) is divided by the LRL in two steps with @DIV16 and rounded up for a partial record. Register A returns the bits above Register Pair BC, and Z when they are zero. LOC3 swaps the result into the Register Pair BC that RESTREG restores.
14DA@LOC
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and save the registers.
14DD
Call GETNRN at 140BH: Register Pair HL = the NRN.
14E0
Call 15B7H (ADJUST): Register C = the offset (FCB+5) and Register Pair HL the sector of the position for byte I/O.
14E3LOC1
LD E,(IX+09H) DD 5E 09
Load Register E with FCB+9 (Index Register IX+09H), the LRL.
14E6
LD A,E 7B
Copy Register E (the LRL) into Register A to test it for zero.
14E7
OR A B7
OR Register A with itself: Z when the LRL is 0, meaning 256.
14E8
If the LRL is 256 (Z), jump to 1500H (LOC3): Register Pair HL, the sector count, is the record number.
14EA
INC C 0C
Increment Register C (the offset); with the decrement that follows it tests Register C for 00H.
14EB
DEC C 0D
Decrement Register C back to the offset: the Z flag now says whether Register C is 00H.
14EC
If the offset is 00H (a whole sector, offset 256), jump to 14EFH (LOC2) without stepping Register Pair HL back.
14EE
DEC HL 2B
Decrement Register Pair HL: a position with a non zero offset lies in the sector before the one Register Pair HL counts to.
14EFLOC2
Call @DIV16 at 06E3H to divide Register Pair HL (the sector number) by Register A (the LRL): quotient in Register Pair HL, remainder in Register A.
14F2
LD B,L 45
Copy Register L (the low byte of the first quotient) into Register B.
14F3
LD D,H 54
Copy Register H (the high byte of the first quotient, bits 16 and up of the result) into Register D.
14F4
LD H,A 67
Copy Register A (the remainder) into Register H, the high byte of the second dividend.
14F5
LD L,C 69
Copy Register C (the offset) into Register L: Register Pair HL = remainder times 256 plus the offset.
14F6
LD A,E 7B
Load Register A with Register E, the LRL, the divisor again.
14F7
Call @DIV16 at 06E3H to divide Register Pair HL by Register A: the low byte of the record number in Register L, the remainder in Register A.
14FA
LD H,B 60
Copy Register B (the middle byte of the result) into Register H: Register Pair HL = the record number.
14FB
OR A B7
OR Register A (the remainder) with itself: Z when the position is on a record boundary.
14FC
If there is no remainder (Z), jump to 14FFH and keep the record number as it is.
14FE
INC HL 23
Increment Register Pair HL: a partly read record counts as the next one.
14FF
LD A,D 7A
Copy Register D (the bits above Register Pair HL) into Register A.
1500LOC3
POP BC C1
Restore Register Pair BC from the stack: the return address to RESTREG (1589H) that CKOPEN@ placed there.
1501
EX (SP),HL E3
Exchange Register Pair HL (the record number) with the caller's Register Pair BC saved under it (Stack Pointer): RESTREG will return the record number in Register Pair BC.
1502
PUSH BC C5
Save Register Pair BC (the RESTREG address) on the stack again.
1503ORARET@
OR A B7
OR Register A (the high order bits) with itself: Z when the record number fits in Register Pair BC.
1504
RET C9
Return through RESTREG to the caller with the record number in Register Pair BC.
1505@LOF
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and save the registers.
1508
LD L,(IX+0CH) DD 6E 0C
Load Register L with FCB+12 (Index Register IX+0CH), the low byte of the ERN.
150B
LD H,(IX+0DH) DD 66 0D
Load Register H with FCB+13 (Index Register IX+0DH): Register Pair HL = the ERN.
150E
LD C,(IX+08H) DD 4E 08
Load Register C with FCB+8 (Index Register IX+08H), the end of file offset.
1511
Jump to 14E3H (LOC1) to turn the end of file position into a record count.
1513H - @READ, @WRITE and @VER: Read and Write a Record
@READ (SVC 67) reads the next record: a whole sector into the FCB's buffer when the LRL is 256, otherwise LRL bytes through RDCHAR into the user's buffer at Register Pair HL. @WRITE (SVC 75) writes the next record the same way; @VER (SVC 73) does the same and reads each sector back. If a byte of a record fails, @WRITE restores the offset and the end of file offset, so the record is not half written in the FCB.
1513@READ
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and save the registers.
1516
PUSH HL E5
Save Register Pair HL (the user's record buffer) on the stack.
1517
Call RWRIT@ at 13A2H to write the buffer back first if it holds changed data.
151A
POP HL E1
Restore Register Pair HL (the user's record buffer) from the stack.
151B
RET NZ C0
Return if the write failed, NZ with the error code in Register A.
151C
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the LRL, the count of bytes to read.
151F
LD A,B 78
Copy Register B (the LRL) into Register A to test it for zero.
1520
OR A B7
OR Register A with itself: Z when the LRL is 0, meaning 256.
1521
If the LRL is 256 (Z), jump to 1375H (NXTSECT) to read the next sector into the FCB's buffer.
1524RDREC
PUSH HL E5
Save Register Pair HL (the position in the user's buffer) on the stack.
1525
PUSH BC C5
Save Register Pair BC (Register B, the bytes left) on the stack.
1526
Call RDCHAR at 1312H to read the next byte of the file into Register A.
1529
POP BC C1
Restore Register Pair BC (the bytes left) from the stack.
152A
POP HL E1
Restore Register Pair HL (the position in the user's buffer) from the stack.
152B
RET NZ C0
Return if the read failed, NZ with the error code (for example 1CH at the end of file) in Register A.
152C
LD (HL),A 77
Store Register A (the byte read) into the user's buffer at Register Pair HL.
152D
INC HL 23
Increment Register Pair HL to the next byte of the user's buffer.
152E
Decrement Register B and loop back to 1524H (RDREC) until the whole record is read.
1530
RET C9
Return to the caller with Z: the record is in the user's buffer.
1531@WRITE
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and clear Register A to 00H.
1534WRIT1
LD (13EAH),A 32 EA 13
Store Register A into 13EAH, the operand of VEROP: 00H from @WRITE turns verify off, 01H from @VER turns it on.
1537
LD B,(IX+09H) DD 46 09
Load Register B with FCB+9 (Index Register IX+09H), the LRL, the count of bytes to write.
153A
LD A,B 78
Copy Register B (the LRL) into Register A to test it for zero.
153B
OR A B7
OR Register A with itself: Z when the LRL is 0, meaning 256.
153C
If the LRL is 256 (Z), jump to 13BDH (RWRIT2) to write the FCB's buffer as a whole sector.
153F
PUSH HL E5
Save Register Pair HL (the user's record) 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, to restore on an error.
1543
LD L,(IX+08H) DD 6E 08
Load Register L with FCB+8 (Index Register IX+08H), the end of file offset, to restore on an error.
1546
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): the two FCB values are saved and Register Pair HL points to the user's record again.
1547WRREC
LD A,(HL) 7E
Load Register A with the next byte of the user's record at Register Pair HL.
1548
INC HL 23
Increment Register Pair HL to the byte after it.
1549
PUSH HL E5
Save Register Pair HL (the record pointer) on the stack.
154A
PUSH BC C5
Save Register Pair BC (Register B, the bytes left) on the stack.
154B
Call WRCHAR at 132FH to write Register A to the file.
154E
POP BC C1
Restore Register Pair BC (the bytes left) from the stack.
154F
POP HL E1
Restore Register Pair HL (the record pointer) from the stack.
1550
If the write failed (NZ), jump to 1557H (WRERROR) to restore the FCB.
1552
Decrement Register B and loop back to 1547H (WRREC) until the whole record is written.
1554
EX (SP),HL E3
Exchange Register Pair HL with the saved FCB values on the stack (Stack Pointer).
1555
POP HL E1
Restore Register Pair HL from the stack, dropping the saved values: Register Pair HL points past the record.
1556
RET C9
Return to the caller with Z: the record is written.
1557WRERROR
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register H = the old offset, Register L = the old end of file offset.
1558
LD (IX+05H),H DD 74 05
Store Register H into FCB+5 (Index Register IX+05H), putting back the offset of the next byte.
155B
LD (IX+08H),L DD 75 08
Store Register L into FCB+8 (Index Register IX+08H), putting back the end of file offset.
155E
POP HL E1
Restore Register Pair HL (the record pointer) from the stack.
155F
RET C9
Return to the caller with the error, NZ and the code in Register A.
1560@VER
Call CKOPEN@ at 1568H to check the FCB, point Index Register IX to it and clear Register A to 00H.
1563
INC A 3C
Increment Register A to 01H, the verify flag.
1564
Jump to 1534H (WRIT1) to store the verify flag and write the record.
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 140BH: 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 140BH: 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,FFFCH 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 E0H 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,FFFCH 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 FEH 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 E0H 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 CBH 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 B4: unlike the test at 1734H, this search has no limit at CBH, the end of the GAT's cylinder map.
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,FFH 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),FFH 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),FEH 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.
181F@SCNHIT
PUSH AF F5
Save Register Pair AF (Register A, the first slot to try) on the stack.
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 (184DH),A 32 4D 18
Store Register A into 184DH, 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 1849H 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,01H 2E 01
Load Register L with 01H, so the scan below starts at slot 02H, past BOOT/SYS and DIR/SYS.
1844NHIT5
INC L 2C
Increment Register L to the next slot of the HIT.
1845
If Register L did not wrap to 00H, jump to 1849H (NHIT6) to test the slot.
1847
OR H B4
OR Register H (1DH) into Register A: NZ, no free slot.
1848
RET C9
Return NZ: the HIT has no free slot, so the directory is full.
1849NHIT6
LD A,L 7D
Copy Register L (the slot) into Register A.
184A
AND 1FH E6 1F
Mask Register A with 1FH, the directory sector of the slot (the low five bits of a DEC).
184CNHIT7
CP 00H FE 00
Compare Register A with the number of directory sectors, the operand at 184DH stored at 1839H.
184E
LD A,L 7D
Copy Register L (the slot) into Register A again (the flags are kept).
184F
If the slot's sector exists (Carry), jump to 1856H (NHIT8) to look at it.
1851
OR 1FH F6 1F
OR 1FH into Register A: the last slot of this row of 32.
1853
LD L,A 6F
Copy Register A into Register L, skipping the slots of sectors the disk does not have.
1854
Jump back to 1844H (NHIT5) to go on with the next row.
1856NHIT8
LD A,(HL) 7E
Load Register A with the HIT byte at Register Pair HL.
1857
OR A B7
OR Register A with itself: Z when the slot is 00H, free.
1858
RET Z C8
Return Z with Register Pair HL at the free slot.
1859
Jump back to 1844H (NHIT5) to test the next slot.
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 C7H 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 E0H 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,A3H 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,B3H 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,C3H 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,D3H 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,E3H 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,A4H 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,B4H 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,C4H 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,F4H 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,A5H 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 1503H 03 15
EXTDBG$, 19A4H-19A5H = 1503H (ORARET@): the hook for an extended debugger. The bytes are never run, since RST28 does not return to the stub.
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,CDH 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,AEH 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,BEH 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),C9H 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,FFFFH 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 C0H F6 C0
OR C0H into Register A: bit 7 (return to the caller) and bit 6 (short message) for @ERROR.
1B50
CP D8H 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 145BH 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,(E0H) 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),C9H 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 B5: the saved configuration is not sent back to port 84H, LBANK$ is not restored and NFLAG$ bit 6 stays set.
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,(ECH) 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).
1D00-1DFF
DEFS 256
SBUFF$ (System Buffer), 1D00H-1DFFH: the system's sector buffer, not loaded. The system FCB, the JCL FCB, @LOAD and the directory routines (@DIRRD, @DIRWR, @HITRD) all use it.
1E00H - SYSINIT: System Start-up, Part 1: Memory, Ports and Drives
The transfer address of SYS0/SYS. LBOOT on the BOOT/SYS page jumps here once the file is loaded; this code runs once and is then overwritten by the system overlays at 1E00H-23FFH. It points the NMI at the floppy driver, shows the system name on the screen, clears the stack page, sets interrupt mode 1 and the stack, sends the port images of low memory to ports ECH, E0H, 84H and FEH, finds whether the machine has 128K (two extra 32K banks) and sets BAR$ and BUR$, sets HIGH$ and PHIGH$ to FFFFH, copies the boot step rate into the drive 0 table and resets the keyboard.
1E00
DI F3
Disable interrupts for the start-up, until the ports and vectors are set.
1E01
LD HL,0FE9H 21 E9 0FLD HL,@RSTNMI
Load Register Pair HL with 0FE9H (@RSTNMI), the floppy driver's NMI routine on the BOOT/SYS page.
1E04
LD (0067H),HL 22 67 00
Store Register Pair HL into 0067H-0068H, the address of the JP at the NMI vector 0066H, which the boot code had pointed to its own routine.
1E07
LD HL,0410H 21 10 04LD HL,PAKNAM$
Point Register Pair HL to 0410H (PAKNAM$), the system name, LS-DOS63Level-1H on this diskette.
1E0A
LD DE,F8BEH 11 BE F8
Point Register Pair DE to F8BEH, row 2, column 30 of the screen (video memory is still mapped in by the boot code).
1E0D
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the first eight characters of the name.
1E10
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE: LS-DOS63 is shown at column 30.
1E12
LD C,08H 0E 08
Load Register C with 08H, the second eight characters; Register B is already 00H.
1E14
INC DE 13
Increment Register Pair DE, leaving a space on the screen.
1E15
INC DE 13
Increment Register Pair DE again: two spaces after the first part.
1E16
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE: Level-1H is shown at column 40.
1E18
INC DE 13
Increment Register Pair DE, leaving a space on the screen.
1E19
INC DE 13
Increment Register Pair DE again, to column 50.
1E1A
LD C,12H 0E 12
Load Register C with 12H (18), the length of the serial number field, which is no longer shown.
1E1C
LD HL,2185H 21 85 21LD HL,SERIAL$
Point Register Pair HL to 2185H (SERIAL$), the serial number field, all zero in this file.
1E1F
NOP 00
No operation: LS-DOS 6.3.1 replaced the copy of the serial number (LDIR) with two NOPs.
1E20
NOP 00
No operation, the second byte where the LDIR of the serial number was.
1E21
XOR A AF
Clear Register A to 00H, for clearing the stack page.
1E22
LD HL,0381H 21 81 03
Point Register Pair HL to 0381H, one past the top of the stack.
1E25CLRLOOP
DEC L 2D
Decrement Register L, moving Register Pair HL down one byte.
1E26
LD (HL),A 77
Store Register A (00H) at Register Pair HL, clearing one byte of the stack page.
1E27
If Register L has not reached 00H, loop back to 1E25H (CLRLOOP): 0300H-0380H are cleared, over the old copy of the boot sector.
1E29
IM 1 ED 56
Set interrupt mode 1: an interrupt runs RST 38H.
1E2B
LD SP,0380H 31 80 03LD SP,STACK$
Load the Stack Pointer with 0380H (STACK$), the system stack.
1E2E
XOR A AF
Clear Register A to 00H, for the bank number and the ports below.
1E2F
LD (0202H),A 32 02 02LD (LBANK$),A
Store Register A (00H) into 0202H (LBANK$): logical bank 0.
1E32
OUT (E4H),A D3 E4
Send Register A (00H) to port E4H, the NMI mask: the disk controller's interrupts are off.
1E34
LD HL,0238H 21 38 02LD HL,S1DCB$
Point Register Pair HL to 0238H (S1DCB$), the first spare device control block.
1E37ZERDCB
LD (HL),A 77
Store Register A (00H) at Register Pair HL.
1E38
INC L 2C
Increment Register L to the next byte of page 2.
1E39
If Register L has not wrapped to 00H, loop back to 1E37H (ZERDCB): 0238H-02FFH, the spare DCBs and the rest of page 2, are cleared.
1E3B
LD A,(0076H) 3A 76 00LD A,(MODOUT$)
Load Register A with 0076H (MODOUT$), the port ECH image (78H: 4 MHz, wait states, external I/O, alternate characters).
1E3E
OUT (ECH),A D3 EC
Send Register A to port ECH: the fast clock and the external bus are on.
1E40
LD A,(0080H) 3A 80 00LD A,(WRINT$)
Load Register A with 0080H (WRINT$), the interrupt mask image (04H, the clock only).
1E43
OUT (E0H),A D3 E0
Send Register A to port E0H: the real time clock interrupt is enabled.
1E45
LD A,(0078H) 3A 78 00LD A,(OPREG$)
Load Register A with 0078H (OPREG$), the Operation Register image (87H, all RAM).
1E48
LD B,A 47
Copy Register A (the regular memory map) into Register B.
1E49
LD A,A7H 3E A7
Load Register A with A7H: the same map with bit 5 set, which switches bank 1 into the upper 32K.
1E4B
LD C,84H 0E 84
Load Register C with 84H, the port of the Operation Register.
1E4D
OUT (C),B ED 41
Send Register B (87H) to port 84H (Register C): the all RAM map; video and keyboard memory leave the map.
1E4F
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the last byte of memory, which the bank test uses.
1E52
LD (040EH),HL 22 0E 04LD (HIGH$),HL
Store Register Pair HL (FFFFH) into 040EH (HIGH$): all memory is free for programs.
1E55
LD (001CH),HL 22 1C 00LD (PHIGH$),HL
Store Register Pair HL (FFFFH) into 001CH (PHIGH$), the physical top of memory.
1E58
LD D,(HL) 56
Load Register D with the byte at FFFFH (Register Pair HL), to put it back afterwards.
1E59
LD (HL),55H 36 55
Store 55H at FFFFH (Register Pair HL), in the regular memory.
1E5B
OUT (C),A ED 79
Send Register A (A7H) to port 84H (Register C): bank 1 in the upper 32K, if it exists.
1E5D
LD E,(HL) 5E
Load Register E with the byte at FFFFH (Register Pair HL) in that bank, to put it back.
1E5E
LD (HL),A 77
Store Register A (A7H) at FFFFH (Register Pair HL).
1E5F
OUT (C),B ED 41
Send Register B (87H) to port 84H (Register C): the regular memory again.
1E61
CP (HL) BE
Compare Register A (A7H) with the byte at FFFFH (Register Pair HL): Z when the store to bank 1 changed it, so there is no bank 1.
1E62
LD (HL),D 72
Store Register D (the original byte) back at FFFFH (Register Pair HL).
1E63
OUT (C),A ED 79
Send Register A (A7H) to port 84H (Register C): bank 1 again.
1E65
LD (HL),E 73
Store Register E (its original byte) back at FFFFH (Register Pair HL).
1E66
OUT (C),B ED 41
Send Register B (87H) to port 84H (Register C): the regular memory again.
1E68
LD A,FEH 3E FE
Load Register A with FEH, the bank byte for bank 0 only (the flags of the compare are kept).
1E6A
If there is no bank 1 (Z), jump to 1E6EH: a 64K machine.
1E6C
LD A,F8H 3E F8
Load Register A with F8H, the bank byte for banks 0, 1 and 2 (a 128K machine).
1E6E
LD (0201H),A 32 01 02LD (BAR$),A
Store Register A into 0201H (BAR$), the banks available: a 0 bit is a bank that exists.
1E71
LD (0200H),A 32 00 02LD (BUR$),A
Store Register A into 0200H (BUR$), the banks in use: banks that do not exist count as used.
1E74
LD A,(006FH) 3A 6F 00LD A,(FEMSK$)
Load Register A with 006FH (FEMSK$), the port FEH image.
1E77
OUT (FEH),A D3 FE
Send Register A (the FEMSK$ value) to port FEH.
1E79
NOP 00
No operation: three zero bytes kept free for a JP (Space for a JUMP in the source).
1E7A
NOP 00
No operation, the second byte of the space kept free for a JP.
1E7B
NOP 00
No operation, the third byte of the space kept free for a JP.
1E7C
LD A,(439DH) 3A 9D 43LD A,(BOOTST$)
Load Register A with 439DH (BOOTST$), the Seek command of the boot sector, still at 4300H: its bits 1-0 are the step rate the diskette was formatted with.
1E7F
AND 03H E6 03
Mask Register A with 03H, the step rate bits.
1E81
LD B,A 47
Copy Register A (the step rate) into Register B.
1E82
LD HL,0473H 21 73 04
Point Register Pair HL to 0473H (DCT$+3), the first flag byte of drive 0's drive code table.
1E85
LD A,(HL) 7E
Load Register A with DCT$+3 at Register Pair HL.
1E86
AND FCH E6 FC
Mask Register A with FCH, clearing the step rate bits 1-0.
1E88
OR B B0
OR Register B (the boot step rate) into Register A.
1E89
LD (HL),A 77
Store Register A back into DCT$+3 at Register Pair HL: drive 0 steps at the boot rate.
1E8A
IN A,(F1H) DB F1
Read port F1H, the disk controller's track register, into Register A: the cylinder the head of drive 0 is on.
1E8C
LD (0475H),A 32 75 04
Store Register A into 0475H (DCT$+5), drive 0's current cylinder.
1E8F
LD DE,0208H 11 08 02LD DE,KIDCB$
Point Register Pair DE to 0208H (KIDCB$), the keyboard DCB.
1E92
LD A,03H 3E 03
Load Register A with 03H, the @CTL function that clears the type-ahead buffer and resets the keyboard.
1E94
Call @CTL at 0623H to send control request Register A to the keyboard DCB at Register Pair DE.
1E97
EI FB
Enable interrupts: the clock and the task processor run from now on.
1E98H - SYSINIT, Part 2: The Date
The date is kept in DATE$ (0033H-0037H), which SYS0/SYS does not load. Under SYSTEM (DATE=OFF) (DTPMT$ 04C2H not zero) the date is cleared and the start-up goes on to the time. Otherwise a valid date still in memory after a reset is kept, and if there is none Date MM/DD/YY ? is asked at row 21, column 27. A year below 12 counts as 2000 to 2011 (the year byte is 100 to 111); the years 1980 to 2011 are accepted. The start-up then sets the length of February, the day of the year, the day of the week (Sunday is 1) and the leap year flag, and shows the date as the day, month name, day of the month and year.
1E98
LD HL,0401H 21 01 04LD HL,ZERO$
Point Register Pair HL to 0401H (ZERO$), the configuration flag of BOOT/SYS: 00H when a SYSGEN configuration is to be loaded.
1E9B
LD A,(HL) 7E
Load Register A with the flag at Register Pair HL.
1E9C
LD (HL),00H 36 00
Store 00H at Register Pair HL: ZERO$ is the zero byte the month table (MAXDAY$) starts with.
1E9E
PUSH AF F5
Save Register Pair AF (Register A, the SYSGEN flag) on the stack for 201CH.
1E9F
LD A,(04C2H) 3A C2 04LD A,(DTPMT$)
Load Register A with 04C2H (DTPMT$), the date prompt switch.
1EA2
OR A B7
OR Register A with itself: NZ when SYSTEM (DATE=OFF) turned the date prompt off.
1EA3
LD HL,0033H 21 33 00LD HL,DATE$
Point Register Pair HL to 0033H (DATE$), the year.
1EA6
LD C,(HL) 4E
Load Register C with the year at Register Pair HL.
1EA7
LD (HL),00H 36 00
Store 00H into the year at Register Pair HL, clearing it until it is checked.
1EA9
INC HL 23
Increment Register Pair HL to 0034H, the day.
1EAA
LD B,(HL) 46
Load Register B with the day at Register Pair HL.
1EAB
LD (HL),00H 36 00
Store 00H into the day at Register Pair HL, clearing it until it is checked.
1EAD
INC HL 23
Increment Register Pair HL to 0035H, the month.
1EAE
LD A,(HL) 7E
Load Register A with the month at Register Pair HL.
1EAF
LD (HL),00H 36 00
Store 00H into the month at Register Pair HL.
1EB1
If the date prompt is off (NZ from 1EA2H), jump to 1FADH (TIMIN): the date stays zero.
1EB4
LD L,FFH 2E FF
Load Register L with FFH: Register Pair HL = 00FFH, the end of the command FCB, the work area for the date.
1EB6
LD (HL),A 77
Store Register A (the old month) at 00FFH (Register Pair HL).
1EB7
DEC HL 2B
Decrement Register Pair HL to 00FEH, the day of the work area.
1EB8
LD (HL),B 70
Store Register B (the old day) at 00FEH (Register Pair HL).
1EB9
DEC HL 2B
Decrement Register Pair HL to 00FDH, the year of the work area.
1EBA
LD (HL),C 71
Store Register C (the old year) at 00FDH (Register Pair HL).
1EBB
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 00FDH, the year in the work area.
1EBC
DEC A 3D
Decrement Register A (the old month): 0 to 11 for a real month.
1EBD
CP 0CH FE 0C
Compare Register A (the old month less 1) with 0CH: Carry for a real month.
1EBF
If the old month is 1 to 12 (Carry), jump to 1ECFH (DATIN1) and check the date still in memory without asking.
1EC1DATIN
LD HL,151BH 21 1B 15
Load Register Pair HL with 151BH, row 21 (15H), column 27 (1BH), where the prompt goes.
1EC4
LD DE,215CH 11 5C 21LD DE,DATEPR
Point Register Pair DE to 215CH (DATEPR), the prompt Date MM/DD/YY ? .
1EC7
LD BC,0830H 01 30 08
Load Register Pair BC with 0830H: Register B = 8 characters at most, Register C = 30H, the separators must be below the character 0.
1ECA
Call GETPARM at 20D6H to ask, read the reply and store month, day and year at 00FFH, 00FEH and 00FDH; Carry when it was valid.
1ECD
If the reply was not a date (No Carry), loop back to 1EC1H (DATIN) to ask again.
1ECFDATIN1
LD A,(DE) 1A
Load Register A with the year at Register Pair DE (00FDH).
1ED0
CP 0CH FE 0C
Compare Register A with 0CH (12): Carry for 00 to 11.
1ED2
If the year is 12 or more (No Carry), jump to 1ED7H.
1ED4
ADD A,64H C6 64
Add 64H (100) to Register A: years 00 to 11 are 2000 to 2011.
1ED6
LD (DE),A 12
Store Register A (the year less 1900) back at Register Pair DE.
1ED7
LD C,A 4F
Copy Register A (the year less 1900) into Register C, for later.
1ED8
SUB 50H D6 50
Subtract 50H (80) from Register A: years 1980 and up become 0 and up.
1EDA
CP 20H FE 20
Compare Register A (the year less 1980) with 20H (32): Carry for 1980 to 2011. Bug B6 (a limit): no year after 2011 can be entered.
1EDC
If the year is before 1980 or after 2011 (No Carry), jump to 1EC1H (DATIN) to ask again.
1EDE
AND 03H E6 03
Mask Register A with 03H: zero for a leap year (1980, 1984 and every fourth year).
1EE0
LD A,1CH 3E 1C
Load Register A with 1CH (28), the days of February in a common year (the flags of the AND are kept).
1EE2
If the year is not a leap year (NZ), jump to 1EEAH (NOTLEAP).
1EE4
LD HL,0037H 21 37 00
Point Register Pair HL to 0037H (DATE$+4), the byte with the leap year flag.
1EE7
SET 7,(HL) CB FE
Set bit 7 of DATE$+4 at Register Pair HL, the leap year flag. Bug B7: the bit is never cleared, so a leap year flag left from before a reset stays.
1EE9
INC A 3C
Increment Register A to 1DH (29), February in a leap year.
1EEANOTLEAP
LD HL,0403H 21 03 04
Point Register Pair HL to 0403H, February's entry in the month table (MAXDAY$+2).
1EED
LD (HL),A 77
Store Register A (28 or 29) into February's entry at Register Pair HL.
1EEE
INC DE 13
Increment Register Pair DE to 00FEH, the day.
1EEF
INC DE 13
Increment Register Pair DE to 00FFH, the month.
1EF0
LD A,(DE) 1A
Load Register A with the month at Register Pair DE.
1EF1
LD B,A 47
Copy Register A (the month) into Register B, for later.
1EF2
DEC A 3D
Decrement Register A: 0 to 11 for a real month.
1EF3
CP 0CH FE 0C
Compare Register A (the month less 1) with 0CH: Carry for a real month.
1EF5
If the month is 0 or above 12 (No Carry), jump to 1EC1H (DATIN) to ask again.
1EF7
DEC HL 2B
Decrement Register Pair HL to 0402H, January's entry in the month table.
1EF8
ADD A,L 85
Add Register L to Register A (the month less 1).
1EF9
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the month's entry, its number of days.
1EFA
DEC DE 1B
Decrement Register Pair DE to 00FEH, the day.
1EFB
LD A,(DE) 1A
Load Register A with the day at Register Pair DE.
1EFC
DEC A 3D
Decrement Register A: a day of 0 becomes FFH and fails the test.
1EFD
CP (HL) BE
Compare Register A (the day less 1) with the days of the month at Register Pair HL.
1EFE
If the day is 0 or past the month's end (No Carry), jump to 1EC1H (DATIN) to ask again.
1F00
LD HL,0035H 21 35 00
Point Register Pair HL to 0035H (DATE$+2), the month.
1F03
INC A 3C
Increment Register A back to the day of the month, 1 or more.
1F04
LD (HL),B 70
Store Register B (the month) into 0035H at Register Pair HL.
1F05
DEC L 2D
Decrement Register L to 0034H, the day of DATE$.
1F06
LD (HL),A 77
Store Register A (the day) into 0034H at Register Pair HL.
1F07
DEC L 2D
Decrement Register L to 0033H, the year of DATE$.
1F08
LD (HL),C 71
Store Register C (the year less 1900) into 0033H at Register Pair HL.
1F09
LD A,C 79
Copy Register C (the year less 1900) into Register A.
1F0A
PUSH AF F5
Save Register Pair AF (Register A, the year) on the stack for the day of the week.
1F0B
AND 03H E6 03
Mask Register A with 03H: zero for a leap year.
1F0D
LD HL,0403H 21 03 04
Point Register Pair HL to 0403H, February's entry in the month table.
1F10
LD (HL),1CH 36 1C
Store 1CH (28) into February's entry at Register Pair HL.
1F12
If the year is not a leap year (NZ), jump to 1F15H.
1F14
INC (HL) 34
Increment February's entry at Register Pair HL to 29.
1F15
LD A,(0035H) 3A 35 00
Load Register A with 0035H, the month of DATE$.
1F18
LD B,A 47
Copy Register A (the month) into Register B, the count of month table entries to add.
1F19
LD A,(0034H) 3A 34 00
Load Register A with 0034H, the day of the month.
1F1C
LD L,A 6F
Copy Register A (the day of the month) into Register L.
1F1D
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the day, the start of the day of the year.
1F1F
LD DE,0401H 11 01 04LD DE,MAXDAY$
Point Register Pair DE to 0401H (MAXDAY$), the zero byte before January's entry.
1F22DAYLP
LD A,(DE) 1A
Load Register A with the entry at Register Pair DE: 0 first, then the days of January and the months after it.
1F23
ADD A,L 85
Add Register L (the low byte of the sum) to Register A.
1F24
LD L,A 6F
Copy Register A into Register L, the low byte of the sum.
1F25
ADC A,H 8C
Add Register H and the Carry flag to Register A.
1F26
SUB L 95
Subtract Register L from Register A: Register A = Register H plus the Carry.
1F27
LD H,A 67
Copy Register A into Register H: Register Pair HL has the entry added.
1F28
INC DE 13
Increment Register Pair DE to the next month's entry.
1F29
Decrement Register B and loop back to 1F22H (DAYLP): the days of the months before this one are added.
1F2B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the day of the year.
1F2C
LD HL,0036H 21 36 00
Point Register Pair HL to 0036H (DATE$+3), the day of the year.
1F2F
LD (HL),E 73
Store Register E (the low eight bits of the day of the year) into 0036H at Register Pair HL.
1F30
INC HL 23
Increment Register Pair HL to 0037H (DATE$+4).
1F31
LD A,D 7A
Copy Register D (bit 8 of the day of the year) into Register A.
1F32
OR (HL) B6
OR DATE$+4 at Register Pair HL into Register A.
1F33
LD (HL),A 77
Store Register A back into DATE$+4 at Register Pair HL: bit 0 is set for a day after the 255th. Bug B7: the OR never clears bit 0, so a bit 8 left from before a reset stays.
1F34
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the day of the year again.
1F35
POP AF F1
Restore Register Pair AF from the stack: Register A = the year less 1900.
1F36
SUB 50H D6 50
Subtract 50H (80) from Register A: the years since 1980.
1F38
LD E,A 5F
Copy Register A (the years since 1980) into Register E.
1F39
ADD A,03H C6 03
Add 03H to Register A, so the division below counts the leap years before this one.
1F3B
RRCA 0F
Rotate Register A right: the value divided by 2.
1F3C
RRCA 0F
Rotate Register A right again: the value divided by 4.
1F3D
AND 0FH E6 0F
Mask Register A with 0FH, dropping the bits rotated round: the leap days since 1980 before this year.
1F3F
ADD A,E 83
Add Register E (the years since 1980) to Register A: each year moves the weekday on by one, a leap year by two.
1F40
LD E,A 5F
Copy Register A (the shift of the weekday) into Register E.
1F41
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the shift of the weekday.
1F43
ADD HL,DE 19
Add Register Pair DE to Register Pair HL (the day of the year).
1F44
INC HL 23
Increment Register Pair HL, so that 1 January 1980, a Tuesday, gives 3.
1F45
LD A,07H 3E 07
Load Register A with 07H, the days of a week.
1F47DIV7
Call @DIV16 at 06E3H to divide Register Pair HL by Register A (7): the remainder in Register A.
1F4A
INC A 3C
Increment Register A: the day of the week, 1 (Sunday) to 7 (Saturday).
1F4B
LD B,A 47
Copy Register A into Register B, for the day name.
1F4C
RLCA 07
Rotate Register A left: the day of the week in bits 3-1.
1F4D
LD C,A 4F
Copy Register A (the day of the week in bits 3-1) into Register C.
1F4E
LD HL,0037H 21 37 00
Point Register Pair HL to 0037H (DATE$+4), the byte with the day of the week.
1F51
LD A,(HL) 7E
Load Register A with DATE$+4 at Register Pair HL.
1F52
AND F1H E6 F1
Mask Register A with F1H, clearing bits 3-1, the old day of the week.
1F54
OR C B1
OR Register C (the new day of the week) into Register A.
1F55
LD (HL),A 77
Store Register A back into DATE$+4 at Register Pair HL.
1F56
PUSH BC C5
Save Register Pair BC (Register B, the day of the week) on the stack.
1F57
LD HL,151BH 21 1B 15
Load Register Pair HL with 151BH, row 21, column 27, where the date is shown.
1F5A
LD B,03H 06 03
Load Register B with 03H, @VDCTL function 3, move the cursor.
1F5C
Call @VDCTL at 0B99H to move the cursor to row Register H, column Register L.
1F5F
POP BC C1
Restore Register Pair BC (Register B, the day of the week) from the stack.
1F60
LD HL,04C7H 21 C7 04LD HL,DAYTBL$
Point Register Pair HL to 04C7H (DAYTBL$), the day names, Sunday first.
1F63
Call SPACE4 at 213CH to show three spaces and the three letter name of day Register B.
1F66
LD A,2CH 3E 2C
Load Register A with 2CH, a comma, to follow the day name.
1F68
Call @DSP at 0642H to show the character in Register A.
1F6B
LD A,20H 3E 20
Load Register A with 20H, a space, to follow the comma.
1F6D
Call @DSP at 0642H to show the character in Register A.
1F70
LD A,(0035H) 3A 35 00
Load Register A with 0035H, the month of DATE$.
1F73
LD B,A 47
Copy Register A (the month) into Register B, the entry to show.
1F74
LD L,DCH 2E DC
Load Register L with DCH: Register Pair HL = 04DCH (MONTBL$), the month names.
1F76
Call DSPMDY at 2144H to show the three letter name of month Register B.
1F79
LD A,20H 3E 20
Load Register A with 20H, a space, to follow the month name.
1F7B
Call @DSP at 0642H to show the character in Register A.
1F7E
LD A,(0034H) 3A 34 00
Load Register A with 0034H, the day of the month.
1F81
DEC B 05
Decrement Register B (00H after DSPMDY) to FFH, so the first pass below makes it 0.
1F82DIV10
INC B 04
Increment Register B, the tens of the day.
1F83
SUB 0AH D6 0A
Subtract 0AH (10) from Register A, the day of the month.
1F85
If Register A has not gone below zero (No Carry), loop back to 1F82H (DIV10).
1F87
PUSH AF F5
Save Register Pair AF (Register A, the units less 10) on the stack.
1F88
LD A,B 78
Copy Register B (the tens of the day) into Register A.
1F89
ADD A,30H C6 30
Add 30H to Register A: the tens digit as a character.
1F8B
CP 30H FE 30
Compare Register A with 30H, the digit 0: a day below 10 shows one digit.
1F8D
If the tens digit is not 0 (NZ), call @DSP at 0642H to show it.
1F90
POP AF F1
Restore Register Pair AF (Register A, the units less 10) from the stack.
1F91
ADD A,3AH C6 3A
Add 3AH to Register A: the units plus 30H, the units digit as a character.
1F93
Call @DSP at 0642H to show the character in Register A.
1F96
LD A,(0033H) 3A 33 00LD A,(DATE$)
Load Register A with 0033H, the year less 1900.
1F99
LD HL,076CH 21 6C 07
Load Register Pair HL with 076CH (1900), the century of the year byte.
1F9C
ADD A,L 85
Add Register L (6CH) to Register A (the year less 1900).
1F9D
LD L,A 6F
Copy Register A into Register L, the low byte of the sum.
1F9E
ADC A,H 8C
Add Register H and the Carry flag to Register A.
1F9F
SUB L 95
Subtract Register L from Register A: Register A = Register H plus the Carry.
1FA0
LD H,A 67
Copy Register A into Register H: Register Pair HL = the full year, 1980 to 2011.
1FA1
LD DE,2155H 11 55 21
Point Register Pair DE to 2155H, the five characters after the comma of PARTYR.
1FA4
Call @HEXDEC at 06F6H to write Register Pair HL as five decimal characters at Register Pair DE: a space and the year.
1FA7
LD HL,2154H 21 54 21LD HL,PARTYR
Point Register Pair HL to 2154H (PARTYR): a comma, the year and a clear to the end of the line.
1FAA
Call @DSPLY at 052DH to show the text at Register Pair HL.
1FADH - SYSINIT, Part 3: The Time, BREAK, DEBUG and the AUTO Command
Unless SYSTEM (TIME=OFF) is in effect (TMPMT$ 04C3H not zero), Time HH:MM:SS ? is asked at row 22, column 27; the seconds may be left out, and an empty reply keeps 00:00:00. After a short wait the start-up looks at the AUTO command in INBUF$ (0420H): a leading asterisk disables BREAK, holding D starts the debugger, and holding ENTER skips the AUTO command. The routine to return to (@EXIT, or @DSPLY and @CMNDI to show and run the AUTO command) is left on the stack, and the last part of the start-up, STUB, is copied to 4350H so that loading the SYSGEN configuration cannot overwrite it.
1FADTIMIN
LD A,(04C3H) 3A C3 04LD A,(TMPMT$)
Load Register A with 04C3H (TMPMT$), the time prompt switch.
1FB0
OR A B7
OR Register A with itself: NZ when SYSTEM (TIME=OFF) turned the time prompt off.
1FB1
If the time prompt is off (NZ), jump to 1FEAH (SELDCT).
1FB3TIMIN0
LD B,03H 06 03
Load Register B with 03H, the three fields of the time.
1FB5
LD HL,00FFH 21 FF 00
Point Register Pair HL to 00FFH, the end of the work area.
1FB8TIMINIT
LD (HL),00H 36 00
Store 00H at Register Pair HL, a field of the time set to zero.
1FBA
DEC HL 2B
Decrement Register Pair HL to the next field of the work area.
1FBB
Decrement Register B and loop back to 1FB8H (TIMINIT): 00FDH-00FFH hold 00:00:00.
1FBD
LD A,FFH 3E FF
Load Register A with FFH, the flag that a time is being read.
1FBF
LD (20EFH),A 32 EF 20LD (ISTIM),A
Store Register A into 20EFH, the operand of the LD A at 20EEH in GETPARM: an empty reply and a missing seconds field are accepted.
1FC2
LD HL,161BH 21 1B 16
Load Register Pair HL with 161BH, row 22 (16H), column 27 (1BH), where the prompt goes.
1FC5
LD DE,216EH 11 6E 21LD DE,TIMEPR
Point Register Pair DE to 216EH (TIMEPR), the prompt Time HH:MM:SS ? .
1FC8
LD BC,0830H 01 30 08
Load Register Pair BC with 0830H: Register B = 8 characters at most, Register C = 30H, the separators must be below the character 0.
1FCB
Call GETPARM at 20D6H to ask, read the reply and store hours, minutes and seconds at 00FFH, 00FEH and 00FDH; Carry when it was valid.
1FCE
If the reply was not a time (No Carry), loop back to 1FB3H (TIMIN0) to ask again.
1FD0
LD HL,00FFH 21 FF 00
Point Register Pair HL to 00FFH, the hours of the work area.
1FD3
LD A,17H 3E 17
Load Register A with 17H (23), the highest hour.
1FD5
CP (HL) BE
Compare Register A with the hours at Register Pair HL: Carry when the hours are above 23.
1FD6
If the hours are too large (Carry), jump to 1FB3H (TIMIN0) to ask again.
1FD8
DEC HL 2B
Decrement Register Pair HL to 00FEH, the minutes.
1FD9
LD A,3BH 3E 3B
Load Register A with 3BH (59), the highest minute and second.
1FDB
CP (HL) BE
Compare Register A with the minutes at Register Pair HL: Carry when they are above 59.
1FDC
If the minutes are too large (Carry), jump to 1FB3H (TIMIN0) to ask again.
1FDE
DEC HL 2B
Decrement Register Pair HL to 00FDH, the seconds.
1FDF
CP (HL) BE
Compare Register A (59) with the seconds at Register Pair HL: Carry when they are above 59.
1FE0
If the seconds are too large (Carry), jump to 1FB3H (TIMIN0) to ask again.
1FE2
LD DE,002DH 11 2D 00LD DE,TIME$
Point Register Pair DE to 002DH (TIME$), seconds, minutes and hours.
1FE5
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes of the time.
1FE8
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (00FDH) to Register Pair DE: the time is set.
1FEASELDCT
LD B,80H 06 80
Load Register B with 80H, the high byte of the delay count for @PAUSE.
1FEC
Call @PAUSE at 0382H to wait for the count in Register Pair BC: with the FAST bit the count runs twice, nearly half a second.
1FEF
LD HL,0420H 21 20 04LD HL,INBUF$
Point Register Pair HL to 0420H (INBUF$), which holds the AUTO command, if there is one.
1FF2
LD A,(HL) 7E
Load Register A with the first character of the AUTO command at Register Pair HL.
1FF3
CP 2AH FE 2A
Compare Register A with 2AH, an asterisk, which asks for BREAK to be disabled.
1FF5
If there is no asterisk (NZ), jump to 2006H (CKDCR) to look at the keyboard.
1FF7
INC HL 23
Increment Register Pair HL past the asterisk, to the command itself.
1FF8
LD A,E6H 3E E6
Load Register A with E6H, the second byte of SET 4,(HL).
1FFA
LD (2082H),A 32 82 20
Store Register A into 2082H, the second byte of the RES 4,(HL) at STUB1: the stub now sets bit 4 of SFLAG$, BREAK disabled.
1FFD
Jump to 2019H (AUTO?): with BREAK disabled the keys D and ENTER are not looked at.
1FFFGETKB17
Call ENADIS_DO_RAM at 0817H to bring the keyboard into the memory map; it switches it out again when this routine returns.
2002
LD A,(F441H) 3A 41 F4
Load Register A with F441H, keyboard rows 0 and 6 read together: bit 4 the D key (row 0) or the down arrow (row 6), bit 0 the ENTER key (row 6) or the @ key (row 0). Bug B8: the down arrow works as D and @ as ENTER.
2005
RET C9
Return with the keys in Register A, through DIS_DO_RAM.
2006CKDCR
Call GETKB17 at 1FFFH to read the D and ENTER keys into Register A.
2009
BIT 4,A CB 67
Test bit 4 of Register A, the D key: NZ when it is held down.
200B
PUSH HL E5
Save Register Pair HL (the AUTO command) on the stack.
200C
LD HL,1B08H 21 08 1BLD HL,@ABORT
Load Register Pair HL with 1B08H (@ABORT), the return address for the debugger.
200F
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): @ABORT is on the stack and Register Pair HL is the AUTO command again.
2010
If D is held down (NZ), jump to 19A0H (@DEBUG): the debugger starts, and returns to @ABORT.
2013
POP DE D1
Restore Register Pair DE from the stack, dropping the @ABORT address.
2014
CPL 2F
Complement Register A: bit 0 is now set when ENTER is not held down.
2015
AND 01H E6 01
Mask Register A with 01H, the ENTER bit: Z when ENTER is held down.
2017
If ENTER is held down (Z), jump to 201CH (NOAUT1) with Z: the AUTO command is skipped.
2019AUTO?
LD A,(HL) 7E
Load Register A with the first character of the AUTO command at Register Pair HL.
201A
CP 0DH FE 0D
Compare Register A with 0DH (ENTER): Z when there is no AUTO command.
201CNOAUT1
POP DE D1
Restore Register Pair DE from the stack: Register D = the SYSGEN flag saved at 1E9EH.
201D
LD A,D 7A
Copy Register D (the SYSGEN flag) into Register A, for STUB.
201E
LD DE,1B0BH 11 0B 1BLD DE,@EXIT
Point Register Pair DE to 1B0BH (@EXIT), where the start-up goes when there is no AUTO command.
2021
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the return code for @EXIT in Register Pair HL.
2024
If there is no AUTO command to run (Z), jump to 2035H (NOAUT).
2026
PUSH HL E5
Save Register Pair HL (the AUTO command) on the stack.
2027
LD HL,20ACH 21 AC 20LD HL,CURSET
Point Register Pair HL to 20ACH, the row byte of the cursor position loaded at 20AAH.
202A
INC (HL) 34
Increment the row at Register Pair HL: the cursor ends a line lower, under the AUTO command.
202B
POP HL E1
Restore Register Pair HL (the AUTO command) from the stack.
202C
LD DE,197EH 11 7E 19LD DE,@CMNDI
Point Register Pair DE to 197EH (@CMNDI), which will run the AUTO command.
202F
PUSH DE D5
Save Register Pair DE (197EH) on the stack, the return address of @DSPLY.
2030
LD B,H 44
Copy Register H (the high byte of the AUTO command's address) into Register B.
2031
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the AUTO command, for @DSPLY and @CMNDI.
2032
LD DE,052DH 11 2D 05LD DE,@DSPLY
Point Register Pair DE to 052DH (@DSPLY), which shows the AUTO command first.
2035NOAUT
PUSH DE D5
Save Register Pair DE (@EXIT or @DSPLY) on the stack: STUB ends by returning there.
2036
PUSH BC C5
Save Register Pair BC (0000H or the AUTO command) on the stack: STUB pops it into Register Pair HL.
2037
LD HL,207EH 21 7E 20LD HL,STUB
Point Register Pair HL to 207EH (STUB), the last part of the start-up.
203A
LD DE,4350H 11 50 43
Point Register Pair DE to 4350H, where STUB runs.
203D
LD BC,0058H 01 58 00LD BC,STUBLEN
Load Register Pair BC with 0058H, the 88 bytes of STUB (207EH-20D5H).
2040
PUSH DE D5
Save Register Pair DE (4350H) on the stack, the return address that takes the start-up into STUB.
2041
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE: STUB is now at 4350H-43A7H.
2043
Call GETKB67 at 2074H: Register A = the SYSGEN flag ORed with the keys of rows 5 and 6.
2046
LD DE,0470H 11 70 04LD DE,DCT$
Point Register Pair DE to 0470H (DCT$), where the configuration's drive code tables go.
2049
LD HL,4300H 21 00 43LD HL,MOD3BUF
Point Register Pair HL to 4300H, where CONFIG/SYS leaves its drive code tables.
204C
LD BC,0050H 01 50 00
Load Register Pair BC with 0050H, the 80 bytes of the eight drive code tables.
204F
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: the copy of the tables waits there for STUB.
2050
AND 82H E6 82
Mask Register A with 82H: zero when the SYSGEN flag is 00H and none of the keys of bits 1 and 7 of rows 5 and 6 is held down. Bug B9: besides CLEAR (row 6 bit 1) that is SPACE (row 6 bit 7), 9 (row 5 bit 1) and / (row 5 bit 7).
2052
RET NZ C0
Return into STUB at 4350H (NZ) when there is no configuration to load, or CLEAR asks to skip it.
2053
LD HL,1500H 21 00 15
Load Register Pair HL with 1500H, row 21, column 0.
2056
LD B,03H 06 03
Load Register B with 03H, @VDCTL function 3, move the cursor.
2058
Call @VDCTL at 0B99H to move the cursor to row Register H, column Register L.
205B
LD HL,2067H 21 67 20LD HL,CONFIG$
Point Register Pair HL to 2067H (CONFIG$), the SYSGEN message, the word SYSGEN between two pairs of asterisks.
205E
Call @DSPLY at 052DH to show the message at Register Pair HL.
2061
LD DE,00E0H 11 E0 00LD DE,CFGFCB$
Point Register Pair DE to 00E0H (CFGFCB$), the FCB holding CONFIG/SYS.CCC:0.
2064
Jump to @LOAD at 1B38H to load the configuration; it returns into STUB at 4350H with Z when it loaded.
2067-2073CONFIG$
DEFM "** SYSGEN **" / DEFB 03H 2A 2A 20 53 59 53 47 45 4E 20 2A 2A 03
CONFIG$, 2067H-2073H: the message SYSGEN between two pairs of asterisks, shown while the configuration loads, ended by 03H.
2074GETKB67
LD HL,F460H 21 60 F4LD HL,KB67
Load Register Pair HL with F460H, keyboard rows 5 and 6 read together; row 6 bit 1 is the CLEAR key.
2077
LD C,A 4F
Copy Register A (the SYSGEN flag) into Register C.
2078
Call ENADIS_DO_RAM at 0817H to bring the keyboard into the memory map until this routine returns.
207B
LD A,C 79
Copy Register C (the SYSGEN flag) back into Register A.
207C
OR (HL) B6
OR the keys of rows 5 and 6 at Register Pair HL into Register A.
207D
RET C9
Return with the flag and the keys in Register A, through DIS_DO_RAM.
207EH - STUB: The End of the Start-up, Run at 4350H
STUB (207EH-20D5H) is copied to 4350H-43A7H at 2041H and runs there; the rows show it at its file addresses, with the run address in each comment (file address plus 22D2H). It sets or clears the BREAK disable bit, and when the configuration was loaded it sets the port ECH image again, copies the drive code tables from 4300H to DCT$ and calls @ICNFG. It marks the current cylinder of every floppy drive 1 to 7 unknown and restores them (unless SYSTEM (RESTORE=OFF)), puts the cursor at row 21 or 22, stores 05H in TFLAG$ when the Model 4P boot ROM left MO at 4018H, makes 0038H a JP and returns to @EXIT, or to @DSPLY and @CMNDI with the AUTO command.
207ESTUB
LD HL,007CH 21 7C 00LD HL,SFLAG$
Point Register Pair HL to 007CH (SFLAG$), the system flags (run at 4350H).
2081STUB1
RES 4,(HL) CB A6
Reset bit 4 of SFLAG$ at Register Pair HL, BREAK enabled; the second byte becomes E6H at 1FFAH (SET 4, BREAK disabled) after an asterisk. The flags are kept (run at 4353H).
2083
If no configuration was loaded (NZ), jump to 2091H (NOTSG), run at 4355H to 4363H.
2085
LD HL,0076H 21 76 00LD HL,MODOUT$
Point Register Pair HL to 0076H (MODOUT$), which the configuration may have changed (run at 4357H).
2088
LD A,(HL) 7E
Load Register A with the port ECH image at Register Pair HL (run at 435AH).
2089
OUT (ECH),A D3 EC
Send Register A to port ECH, the clock speed and the other options of the configuration (run at 435BH).
208B
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair HL = 4300H, Register Pair DE = 0470H, Register Pair BC = 0050H (run at 435DH).
208C
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE: the configuration's drive code tables go into DCT$ (run at 435EH).
208E
Call @ICNFG at 0086H, the configuration's initialization chain (run at 4360H).
2091NOTSG
LD C,07H 0E 07
Load Register C with 07H, the last drive, to restore drives 7 down to 1 (run at 4363H).
2093SETCYL0
Call @GTDCT at 1A1EH to point Index Register IY to the drive code table of drive Register C (run at 4365H).
2096
BIT 3,(IY+03H) FD CB 03 5E
Test bit 3 of DCT+3 (Index Register IY+03H), set for a hard drive (run at 4368H).
209A
If the drive is a hard drive (NZ), jump to 20A7H (NOFF), run at 436CH to 4379H: it is neither marked nor restored.
209C
LD (IY+05H),FFH FD 36 05 FF
Store FFH into DCT+5 (Index Register IY+05H), the current cylinder: unknown until the drive is used (run at 436EH).
20A0
LD A,(04C4H) 3A C4 04LD A,(RSTOR$)
Load Register A with 04C4H (RSTOR$), the restore switch (run at 4372H).
20A3
OR A B7
OR Register A with itself: Z when the drives are to be restored at boot (run at 4375H).
20A4
If they are (Z), call @RSTOR at 19C8H to move the head of drive Register C to cylinder 0 (run at 4376H).
20A7NOFF
DEC C 0D
Decrement Register C to the next drive down (run at 4379H).
20A8
If Register C has not reached drive 0, loop back to 2093H (SETCYL0), run at 437AH to 4365H.
20AA
LD HL,1500H 21 00 15
Load Register Pair HL with 1500H, row 21, column 0; the row byte at 20ACH is 16H (row 22) after an AUTO command (run at 437CH).
20AD
LD B,03H 06 03
Load Register B with 03H, @VDCTL function 3, move the cursor (run at 437FH).
20AF
Call @VDCTL at 0B99H to move the cursor to row Register H, column Register L (run at 4381H).
20B2
LD DE,4F4DH 11 4D 4F
Load Register Pair DE with 4F4DH, the characters M and O as a word (run at 4384H).
20B5
LD HL,(4018H) 2A 18 40
Load Register Pair HL with 4018H, two bytes the Model 4P boot ROM leaves in memory (run at 4387H).
20B8
SBC HL,DE ED 52
Subtract Register Pair DE and the Carry flag from Register Pair HL: Z when the bytes are MO (run at 438AH).
20BA
LD A,04H 3E 04
Load Register A with 04H, the machine type of the Model 4 (the flags are kept) (run at 438CH).
20BC
If the bytes are not MO (NZ), jump to 20C0H (MOD4REG), run at 438EH to 4392H.
20BE
LD A,05H 3E 05
Load Register A with 05H, the machine type of the Model 4P (run at 4390H).
20C0MOD4REG
LD (007DH),A 32 7D 00LD (TFLAG$),A
Store Register A (04H or 05H) into 007DH (TFLAG$), the machine type (run at 4392H).
20C3
LD HL,0038H 21 38 00LD HL,@RST38
Point Register Pair HL to 0038H, the interrupt vector (run at 4395H).
20C6
LD (HL),C3H 36 C3
Store C3H (JP) at 0038H (Register Pair HL), making sure RST 38H reaches the task processor at 1BFFH (run at 4398H).
20C8
POP HL E1
Restore Register Pair HL from the stack: 0000H, or the AUTO command for @DSPLY and @CMNDI (run at 439AH).
20C9
RET C9
Return to @EXIT, or to @DSPLY, which shows the AUTO command and returns into @CMNDI to run it (run at 439BH).
20CA-20D5
DEFB 00H x 12 00 x 12
20CAH-20D5H: twelve zero bytes, space for more code at the end of STUB, copied to 439CH-43A7H with it.
20D6H - GETPARM: Ask for the Date or the Time
GETPARM moves the cursor to row Register H, column Register L, shows the prompt at Register Pair DE and reads a reply of up to Register B characters into 1E00H, over the start-up code that has already run. It parses three fields of two digits, from 00FFH down to 00FDH, separated by a colon or any character below Register C (30H). It returns Carry for a valid reply and No Carry for a bad one. An empty reply is bad for the date and good for the time (the flag at 20EFH), and the time may end after the minutes.
20D6GETPARM
PUSH BC C5
Save Register Pair BC (Register B the length, Register C the separator limit) on the stack.
20D7
PUSH DE D5
Save Register Pair DE (the prompt) on the stack.
20D8
LD B,03H 06 03
Load Register B with 03H, @VDCTL function 3, move the cursor.
20DA
Call @VDCTL at 0B99H to move the cursor to row Register H, column Register L.
20DD
POP HL E1
Restore Register Pair HL from the stack: the prompt.
20DE
Call @DSPLY at 052DH to show the prompt at Register Pair HL.
20E1
LD HL,1E00H 21 00 1ELD HL,OVERLAY
Point Register Pair HL to 1E00H, the buffer for the reply.
20E4
POP BC C1
Restore Register Pair BC (the length and the separator limit) from the stack.
20E5
PUSH BC C5
Save Register Pair BC (the length and the separator limit) on the stack again.
20E6
Call @KEYIN at 0585H to read up to Register B characters into the buffer at Register Pair HL; Register B returns the number typed.
20E9
XOR A AF
Clear Register A to 00H, to test Register B below.
20EA
OR B B0
OR Register B (the characters typed) into Register A: Z for an empty reply.
20EB
POP BC C1
Restore Register Pair BC (the length and the separator limit) from the stack.
20EC
If something was typed (NZ), jump to 20F4H (GETP1).
20EE
LD A,00H 3E 00
Load Register A with the time flag, the operand at 20EFH: 00H for the date, FFH for the time (stored at 1FBFH).
20F0
OR A B7
OR Register A (the time flag) with itself: Z for the date.
20F1
RET Z C8
Return with Z and No Carry for an empty date: it is asked again.
20F2
SCF 37
Set the Carry flag: an empty time is accepted as 00:00:00.
20F3
RET C9
Return with Carry: an empty time is accepted and the time stays 00:00:00.
20F4GETP1
PUSH BC C5
Save Register Pair BC (the length and the separator limit) on the stack.
20F5
LD B,40H 06 40
Load Register B with 40H, the high byte of the delay count for @PAUSE.
20F7
Call @PAUSE at 0382H to wait while the finger leaves the ENTER key.
20FA
POP BC C1
Restore Register Pair BC (Register C, the separator limit) from the stack.
20FBPARSDAT
LD DE,00FFH 11 FF 00
Point Register Pair DE to 00FFH, where the first field goes.
20FE
LD B,03H 06 03
Load Register B with 03H, the three fields of the reply.
2100PRSD1
PUSH DE D5
Save Register Pair DE (the field's place) on the stack.
2101
Call PRSD3 at 2135H to fetch the next character as a digit: Carry when it is 0 to 9.
2104
If it is not a digit (No Carry), jump to 2115H (PRSD2) and return No Carry.
2106
LD E,A 5F
Copy Register A (the tens digit) into Register E.
2107
RLCA 07
Rotate Register A left: the tens digit times 2.
2108
RLCA 07
Rotate Register A left again: the digit times 4.
2109
ADD A,E 83
Add Register E (the digit) to Register A: the digit times 5.
210A
RLCA 07
Rotate Register A left: the tens digit times 10.
210B
LD E,A 5F
Copy Register A (the tens times 10) into Register E.
210C
Call PRSD3 at 2135H to fetch the units digit: Carry when it is 0 to 9.
210F
If it is not a digit (No Carry), jump to 2115H (PRSD2) and return No Carry.
2111
ADD A,E 83
Add Register E (the tens) to Register A: the field's value.
2112
LD E,A 5F
Copy Register A (the value of the field) into Register E.
2113
SCF 37
Set the Carry flag: the field is two valid digits.
2114
LD A,E 7B
Copy Register E (the value of the field) into Register A.
2115PRSD2
POP DE D1
Restore Register Pair DE (the field's place) from the stack.
2116
RET NC D0
Return No Carry if a character was not a digit.
2117
LD (DE),A 12
Store Register A (the field's value) at Register Pair DE.
2118
DEC B 05
Decrement Register B, the fields still to parse.
2119
SCF 37
Set the Carry flag: so far the reply is valid.
211A
RET Z C8
Return with Carry when all three fields are stored.
211B
DEC DE 1B
Decrement Register Pair DE to the next field's place.
211C
LD A,(HL) 7E
Load Register A with the separator at Register Pair HL.
211D
INC HL 23
Increment Register Pair HL past the separator.
211E
CP 3AH FE 3A
Compare Register A with 3AH, a colon, the separator of the time.
2120
If it is a colon (Z), loop back to 2100H (PRSD1) for the next field.
2122
CP C B9
Compare Register A with Register C (30H), the separator limit.
2123
If the character is 0 or above (No Carry), jump to 2139H (PRSD4) to return No Carry: it is not a separator.
2125
CP 0DH FE 0D
Compare Register A with 0DH (ENTER), the end of the reply.
2127
If it is another separator (NZ), loop back to 2100H (PRSD1) for the next field.
2129
LD A,B 78
Copy Register B (the fields left) into Register A.
212A
DEC A 3D
Decrement Register A: Z when only the last field is missing.
212B
If more fields are missing (NZ), loop back to 2100H (PRSD1), which parses whatever follows the ENTER in the buffer at 1E00H. Bug B10: the buffer is not cleared, so for the time the rest of the date reply can still be there and be taken as the minutes and seconds.
212D
LD A,(20EFH) 3A EF 20LD A,(ISTIM)
Load Register A with the time flag at 20EFH: FFH while reading the time.
2130
OR A B7
OR Register A (the time flag) with itself: Z for the date.
2131
For the date (Z), loop back to 2100H (PRSD1): the year cannot be left out, so the parse fails.
2133
SCF 37
Set the Carry flag: a time may end after the minutes, the seconds staying 00.
2134
RET C9
Return with Carry: the time is valid without its seconds.
2135PRSD3
LD A,(HL) 7E
Load Register A with the next character of the reply at Register Pair HL.
2136
INC HL 23
Increment Register Pair HL past the character fetched.
2137
SUB 30H D6 30
Subtract 30H (the character 0) from Register A: a digit becomes 0 to 9, anything below 0 wraps to a large value.
2139PRSD4
CP 0AH FE 0A
Compare Register A with 0AH: Carry for 0 to 9.
213B
RET C9
Return with Carry for a digit, No Carry for anything else.
213CSPACE4
PUSH HL E5
Save Register Pair HL (the name table) on the stack.
213D
LD HL,2180H 21 80 21LD HL,SPACE4$
Point Register Pair HL to 2180H (SPACE4$), three spaces.
2140
Call @DSPLY at 052DH to show the three spaces at Register Pair HL.
2143
POP HL E1
Restore Register Pair HL (the name table) from the stack, and fall into DSPMDY.
2144DSPMDY
DEC B 05
Decrement Register B: the entry number 1 to 7 or 1 to 12 becomes 0 and up.
2145
LD A,L 7D
Copy Register L (the low byte of the table) into Register A.
2146
ADD A,B 80
Add Register B (the entry number) to Register A.
2147
ADD A,B 80
Add Register B (the entry number) to Register A again.
2148
ADD A,B 80
Add Register B to Register A a third time: the table plus three times the entry.
2149
LD L,A 6F
Copy Register A into Register L: Register Pair HL points to the three letter name.
214A
LD B,03H 06 03
Load Register B with 03H, the three characters of a name.
214CDSPM1
LD A,(HL) 7E
Load Register A with the next character of the name at Register Pair HL.
214D
INC HL 23
Increment Register Pair HL to the character after it.
214E
Call @DSP at 0642H to show the character in Register A.
2151
Decrement Register B and loop back to 214CH (DSPM1) for the three characters.
2153
RET C9
Return with Register B = 00H, the name shown.
2154-215BPARTYR
DEFM ", 198 " / DEFB 1EH, 03H 2C 20 31 39 38 20 1E 03
PARTYR, 2154H-215BH: a comma, then five characters that @HEXDEC replaces with a space and the year (, 198 in the file), 1EH (clear to the end of the line) and 03H.
215C-216DDATEPR
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, 215CH-216DH: 1EH (clear to the end of the line), the prompt Date MM/DD/YY ? and 03H.
216E-217FTIMEPR
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, 216EH-217FH: 1EH (clear to the end of the line), the prompt Time HH:MM:SS ? and 03H.
2180-2184SPACE4$
DEFM " " / DEFB 03H, 03H 20 20 20 03 03
SPACE4$, 2180H-2184H: three spaces and two 03H bytes; @DSPLY shows the three spaces.
2185-2199SERIAL$
DEFB 00H x 21 00 x 21
SERIAL$, 2185H-2199H: 21 zero bytes, where version 6.3.0 kept a serial number shown at start-up; 6.3.1 no longer shows it (1E1FH).
219A-21B9
DEFB 00H x 32 00 x 32
219AH-21B9H: 32 zero bytes, the last bytes SYS0/SYS loads into the overlay area (space for a message in the source).
F80DH - The Sign-on Screen, Loaded into Video Memory
SYS0/SYS ends with load blocks that go straight into video memory, which the boot code left mapped at F800H-FFFFH and cleared to spaces: the version and copyright lines at the top of the screen and a framed WELCOME to LS-DOS in the middle, rows 7 to 15, columns 29 to 47. Each row of the screen is 80 bytes. The frame is drawn with the graphics characters BFH (all six blocks lit) and 83H (the top two blocks). The bytes between the blocks are not loaded and keep their spaces.
F80D-F81B
DEFM "LS-DOS 06.03.01" 4C 53 2D 44 4F 53 20 30 36 2E 30 33 2E 30 31
F80DH-F81BH, row 0 from column 13: the version, LS-DOS 06.03.01.
F81C
DEFM " " 20
F81CH, row 0, column 28: a space, the language letter of this United States build (D or F in the German and French ones).
F81D-F830
DEFM "- Copyright 1986/90 " 2D 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 36 2F 39 30 20
F81DH-F830H, row 0 from column 29: the text - Copyright 1986/90 and a space.
F831-F841
DEFM "MISOSYS, Inc. " 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 20 20 20 20
F831H-F841H, row 0 from column 49: MISOSYS, Inc. and four spaces.
F842-F85D
DEFS 28
F842H-F85DH, row 0 from column 66 to row 1, column 13: not loaded, left as spaces.
F85E-F890
DEFM " All Rights Reserved. " 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 6C 6C 20 52 69 67 68 74 73 20 52 65 73 65 72 76 65 64 2E 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
F85EH-F890H, row 1 from column 14: fifteen spaces, All Rights Reserved. and sixteen spaces.
F891-FA4C
DEFS 444
F891H-FA4CH, the rest of row 1 to row 7, column 28: not loaded, left as spaces.
FA4D-FA5F
DEFB 0BFH / DEFB 83H x 17 / DEFB 0BFH BF 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 BF
FA4DH-FA5FH, row 7, columns 29 to 47: the top of the frame, a solid block, seventeen top bars and a solid block.
FA60-FA9C
DEFS 61
FA60H-FA9CH, row 7 from column 48 to row 8, column 28: not loaded.
FA9D-FAAF
DEFB 0BFH / DEFM " " / DEFB 0BFH BF 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 BF
FA9DH-FAAFH, row 8: the sides of the frame around seventeen spaces.
FAB0-FAEC
DEFS 61
FAB0H-FAECH, row 8 from column 48 to row 9, column 28: not loaded.
FAED-FAFF
DEFB 0BFH / DEFM " W E L C O M E " / DEFB 0BFH BF 20 20 57 20 45 20 4C 20 43 20 4F 20 4D 20 45 20 20 BF
FAEDH-FAFFH, row 9: the sides of the frame around W E L C O M E.
FB00-FB3C
DEFS 61
FB00H-FB3CH, row 9 from column 48 to row 10, column 28: not loaded.
FB3D-FB4F
DEFB 0BFH / DEFM " " / DEFB 0BFH BF 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 BF
FB3DH-FB4FH, row 10: the sides of the frame around seventeen spaces.
FB50-FB8C
DEFS 61
FB50H-FB8CH, row 10 from column 48 to row 11, column 28: not loaded.
FB8D-FB9F
DEFB 0BFH / DEFM " t o " / DEFB 0BFH BF 20 20 20 20 20 20 20 74 20 6F 20 20 20 20 20 20 20 BF
FB8DH-FB9FH, row 11: the sides of the frame around t o.
FBA0-FBDC
DEFS 61
FBA0H-FBDCH, row 11 from column 48 to row 12, column 28: not loaded.
FBDD-FBEF
DEFB 0BFH / DEFM " " / DEFB 0BFH BF 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 BF
FBDDH-FBEFH, row 12: the sides of the frame around seventeen spaces.
FBF0-FC2C
DEFS 61
FBF0H-FC2CH, row 12 from column 48 to row 13, column 28: not loaded.
FC2D-FC3F
DEFB 0BFH / DEFM " L S - D O S " / DEFB 0BFH BF 20 20 20 4C 20 53 20 2D 20 44 20 4F 20 53 20 20 20 BF
FC2DH-FC3FH, row 13: the sides of the frame around L S - D O S.
FC40-FC7C
DEFS 61
FC40H-FC7CH, row 13 from column 48 to row 14, column 28: not loaded.
FC7D-FC8F
DEFB 0BFH / DEFM " " / DEFB 0BFH BF 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 BF
FC7DH-FC8FH, row 14: the sides of the frame around seventeen spaces.
FC90-FCCC
DEFS 61
FC90H-FCCCH, row 14 from column 48 to row 15, column 28: not loaded.
FCCD-FCDF
DEFB 83H x 19 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
FCCDH-FCDFH, row 15, columns 29 to 47: the bottom of the frame, nineteen top bars.