TRSDOS v1.3 – SYS07/SYS Disassembly
General:
SYS7 handles the BACKUP and FORMAT Utility Commands. The only parameters permitted are drive numbers (0-2 for Backup, 0-1 for Format), and if drive numbers are not provided the user will be prompted for them.
Disassembly:
4E00H – This is the ERROR, EXIT, and FATAL ERROR Routine. This is not the Overlay entry point (which is 57A1H).
4E00
NOTE: 4463H is the storage location for the old system disk side number.
[4E1DH]
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
4E35H – ABORT with CAN’T BACK UP DISKETTE Message
4E35
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[4030H]
NOTE: 4030H is the OPERATION ABORTED routine. Routine runs, displays an error, and returns to the DOS PROMPT.
4E41H – Reset the Retry Counter in DOS
4E41
4E4AH – ABORT routine – Jumped to if there was an error along the way
4E4A
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[4E68H]
[516EH]
[516EH]
4E6EH – Clear RAM from 5E00H to 5EFFH and return
4E6E
4E7CH – MESSAGE and BYTE STORAGE AREA
4E7C
4E7D
4E7E
4E7F
4E80
4E81
4E82
4E83
4E84
4E85
4E86
4E87
4E88
4E8A
4E8D
4E8F
Message Storage Areas
4E90
4E98
4EA2
4EAB
4EB6
4EC1
4ECC
4ED1
4EDE
4EE2
4EF7
4F17
4F3C
4F5C
4F76
4F88
4F93
4FA2
4FB1
4FC6
4FF1
5001
5013
5031
5049
505F
507A
50B3
50E0
511D
5138H – Drive Selection and System Disk Check
Intermediate Code Section
Additional Message Storage
5145
5152
516B
516EH – Decode and Display a Coded String
516E
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
[5170H]
517AH – Read a Gran. A Gran in TRSDOS v1.3 is 3 Sectors. D=Track Number, E=Sector Number, HL=Buffer for Storage
[5195H]
[518AH]
519AH – Write a Gran. On entry, HL points to the Data Buffer to Write to Diskette
[51B6H]
[51ABH]
51BBH – Verify a Gran
[51D3H]
[51CAH]
51D8H – Read a Sector and Display a Message
51E2H – Write a Sector and Display a Message
51ECH – Verify a Sector and Display a Message
- If Register A equals track 40, the Z FLAG is set.
- If A < track 40, the CARRY FLAG will be set.
- if A >= track 40, the NO CARRY FLAG will be set.
If we are here, then we are at track 40, which gets special handling.
520BH – Display the appropriate Reading/Writing/Verifying Track xx Sector yy Message. On Entry, IY is pointing to a message of Reading, Writing, or Verifying, D holds the track number, and E holds the sector number
[522CH]
[522CH]
521E
POP HL
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
522CH – Convert the Value in Register A into a Two Digit Decimal, stored in (HL)
522C
[522EH]
5238H – Move to the Next Sector Buffer for a Given Gran. Since a Gran is 3 Sectors, processing a gran requires moving between 3 memory buffers. On Entry, D holds the Track, E holds the Sector Number, and HL points to the associated Data Buffer
5240H – Move to the next Gran Buffer in a Given Track
5248
POP DE
524A
INC HL
5255
POP HL
5257H – Copy of the BOOT Sector and Check for Permitted Backup
NOTE: 4463H is the storage location for the old system disk side number.
[4E00H]
- If Register A equals 12H, the Z FLAG is set.
- If A < 12H, the CARRY FLAG will be set.
- if A >= 12H, the NO CARRY FLAG will be set.
[52A9H]
[4E00H]
52A9H – Continuation of BACKUP Routine. Jumped here if no more permitted backups can be made
52B4H – Read the Directory Track into RAM
NOTE: 4463H is the storage location for the old system disk side number.
[4E00H]
[52C2H]
[5312H]
[52E9H]
52F2H – Write the Directory Track
NOTE: 4463H is the storage location for the old system disk side number.
[4E00H]
[4E00H]
[5300H]
5312H – Examine a Directory Gran for Files which are limited backup
5315
[5323H]
If we did not jump to 5337H because of either of those 2 tests, we wind up here – to flag the file as deleted.
EXMGRN Routine Completion
The EXMGRN routine continues processing directory entries and managing the HIT table for backup operations. This final section completes the directory examination process and handles the remaining file processing logic.
[5327H]
[5323H]
5351H – De-Allocate a File which was Protected. On Entry, HL points to the director record to deallocate.
5351
ADD A,L
LD L,A
At this point, Register Pair DE holds the next segment descriptor.
- If Register A equals 0FEH, the Z FLAG is set.
- If A < 0FEH, the CARRY FLAG will be set.
- if A >= 0FEH, the NO CARRY FLAG will be set.
[5364H]
[537CH]
5364H – Clear the Directory Entry following a De-Allocation.
5364
5366
LD E,L
537CH – De-Allocate All Grans in a Given Extent. On Entry, DE is the segment descriptor.
537C
5388
5389
RLCA
RLCA
[4451H]
539C
LD L,A
[53ADH]
[538CH]
53ADH – Reset Bit (A) of Register B. On Entry, A contains the bit to reset and B contains the byte to reset.
53AD
53BA
53D3H – Write the Grans from the RAM BUFFER to the DISKETTE.
53D3
NOTE: 4463H is the storage location for the old system disk side number.
[4E00H]
[4E00H]
[53BAH]
[53DFH]
53FAH – Find the Next Allocated Gran on Diskette.
53FA
- If Register A equals track 40, the Z FLAG is set.
- If A < track 40, the CARRY FLAG will be set.
- if A >= track 40, the NO CARRY FLAG will be set.
[5409H]
5409H – Determine Which Track was Allocated.
5409
5438H – Read granules from the source diskette. On exit, the C FLAG will be set if the buffer is full.
5438
NOTE: 4463H is the storage location for the old system disk side number.
[545EH]
544A
ADD A,E
[5454H]
5454H – Read Granules from RAM to Diskette.
[5444H]
545EH – Mark the END OF DATA in the BUFFER.
545E
5465H – Flashing Prompt Routine.
5465
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[002BH]
NOTE: 002BH is the Model III ROM Keyboard scanning routine; Register A exits with the ASCII value for the key that was pressed or ZERO if no key was pressed.
[5488H]
5476
OR C
[546DH]
[5465H]
5488H – SUBROUTINE in the Flashing Prompt Routine to clear a line.
5488
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
5492H – Prompt for the SOURCE DISK (if necessary).
5492
54A0
54A5H – Prompt User for the Destination Disk.
54A5
54B4
54B9H – Check Destination Diskette.
[4A93H]
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
[4E00H]
[4A93H]
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
[4E00H]
[54F9H]
[4E4AH]
[54F0H]
5509H – Prompt the User for the SYSTEM DISK (if necessary).
5509
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
5518H – Copy the Source Diskette to the Destination Diskette.
5518
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
[54A5H]
[5803H]
[552FH]
5560H – Start of the backup routine … first Check the Source Diskette.
[4ABAH]
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
[4E00H]
5572
OR L
[5585H]
If we are here, then this is a non-DOS disk.
[56ABH]
[56ABH]
[4A93H]
NOTE: 4A93H is the SYS00/SYS routine to read THE GAT sector into RAM (Buffer at 4D00H).
[4E00H]
[55B3H]
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
55B3H – Continuation of the BACKUP routine; Jumped here if the user supplied the correct master password.
55B3
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
55CCH – Get and Validate the Source Drive Number.
55CC
[55E0H]
[5645H]
[55D7H]
NOTE: 4413H is the storage location for the NUMBER OF DISK DRIVES in the system.
- If Register A equals the NUMBER OF DISK DRIVES IN THE SYSTEM, the Z FLAG is set.
- If A < NUMBER OF DISK DRIVES IN THE SYSTEM, the CARRY FLAG will be set.
- if A >= NUMBER OF DISK DRIVES IN THE SYSTEM, the NO CARRY FLAG will be set.
[55D7H]
55F2
INC HL
55F4H – Get and Validate the Destination Drive Number.
55F4
[5602H]
[5645H]
[55FAH]
NOTE: 4413H is the storage location for the NUMBER OF DISK DRIVES in the system.
- If Register A equals the NUMBER OF DISK DRIVES IN THE SYSTEM, the Z FLAG is set.
- If A < NUMBER OF DISK DRIVES IN THE SYSTEM, the CARRY FLAG will be set.
- if A >= NUMBER OF DISK DRIVES IN THE SYSTEM, the NO CARRY FLAG will be set.
[55FAH]
[45E9H]
NOTE: 45E9H is the routine to calculate the DRIVE SELECT CODE to be used.
5626H – Get the Number of the Drive for the FORMAT.
5626
[5637H]
[5645H]
[562FH]
NOTE: 4413H is the storage location for the NUMBER OF DISK DRIVES in the system.
- If Register A equals the NUMBER OF DISK DRIVES IN THE SYSTEM, the Z FLAG is set.
- If A < NUMBER OF DISK DRIVES IN THE SYSTEM, the CARRY FLAG will be set.
- if A >= NUMBER OF DISK DRIVES IN THE SYSTEM, the NO CARRY FLAG will be set.
[562FH]
5645H – Prompt the user with a message and fetch B characters from the user. On entry, HL points to the text to display and B holds the maximum character count to accept.
5645
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[0040H]
NOTE: 0040H is the Model III ROM routine to get a full line from the keyboard. In this routine, a line is terminated by a carriage return or BREAK, and characters typed are echoed to the display. On entry, B must be the maximum length of line to be accepted and (HL) must be the storage buffer which should be set to B+1. On Exit, CARRY will be set if the BREAK key was hit, Register B will contain the number of characters entered, and (HL) will contain the line from the keyboard followed by the terminating character. Register paid DE is altered in this routine.
[4030H]
NOTE: 4030H is the OPERATION ABORTED routine. Routine runs, displays an error, and returns to the DOS PROMPT.
5652H – Prepare to display the prompt for the MASTER PASSWORD.
5652
5657H – Prompt the user for the master password for the source diskette.
5657
[5645H]
5666H – Get the NAME for the DISKETTE to FORMAT and put it in 4E98H-4EA0H.
5666
[5645H]
[5683H]
[5666H]
[567DH]
568CH – Generate the Date in ASCII from the SYSTEM CALENDAR.
568C
5693H – Generate a Formatted Diskette’s GAT TABLE (meaning identify the BOOT and DIRECTORY tracks aas allocated).
5693
56ABH – Set the flag to prompt for the SYSTEM DISKETTE once the current operation is completed.
56AB
56B1H – Analyze the Destination Diskette for a Prior Format.
56B1
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[4ABAH]
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
[4AC2H]
NOTE: 4AC2H is the SYS00/SYS routine to write the HIT sector from RAM to diskette.
[4E00H]
[56E9H]
[56E1H]
56E9H – Continuation of the above ANALYZE A DESTINATION DISKETTE routine; jumnped here if there is an active file present. On Exit A is ZERO if we are not reformatting; and anything else if we are.
56E9
[5645H]
[4E50H]
[56FFH]
[56E9H]
[5645H]
[5712H]
5714H – Clear the Screen and Display a Program Name. On Entry, HL points to the middle part of the applicable message.
5714
[01C9H]
NOTE: 01C9H is the Model III ROM routine to to CLEAR THE SCREEN and RETurn.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
5728H – Common Routine for both BACKUP and FORMAT – Set up the RAM BUFFERS.
5728
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
5739H – “BACKUP” Utility.
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
5762H – “FORMAT” Utility.
5790
DEC HL
[5138H]
57A1H – DOS Entry to the FORMAT and BACKUP Utilities.
57A1
[5762H]
[5739H]
57C3H – Encode a Password.
57C3
[57D3H]
[57CEH]
57D3H – Password Encode. Encode the password stored in the memory location pointed to by Register Pair DE; results in Register Pair HL.
57D3
The next few instructions skip to the end of the password (pointed to by Register Pair DE) by adding 7 to the LSB (i.e., Register E).
At this point, Register Pair DE is now pointing to the END of the password.
57E7
57E8
RRCA
57FF
OR L
5803H – Format a Diskette.
5803
When this bit pattern in sent to Port F0H (the Floppy Disk Control Port) and bits 7-4 are 0000, this is a RESTORE command and is a Type I command. Bits 0-1 are the stepping rate (00=6ms, 01=12ms, 10=20ms, 11=30ms), Bit 2 is the Track Number Verify Flag (0=No Verify), and Bit 3 is the Head Load Flag (1=Load Head).
When activated, the Track Register is checked, and if its 0 (meaning at Track 0) an interrupt is generated. If it is not 0, stepping pulses are issued until the TR00 goes to 0, and then an interrupt is generated.
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
[5816H]
[5816H]
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
[5832H]
5832H – Continuation of FORMAT routine above; jumped here once we hit track 0.
[5840H]
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
When this bit pattern in sent to Port F0H (the Floppy Disk Control Port) and bits 7-4 are 0000, this is a RESTORE command and is a Type I command. Bits 0-1 are the stepping rate (00=6ms, 01=12ms, 10=20ms, 11=30ms), Bit 2 is the Track Number Verify Flag (0=No Verify), and Bit 3 is the Head Load Flag (1=Load Head).
When activated, the Track Register is checked, and if its 0 (meaning at Track 0) an interrupt is generated. If it is not 0, stepping pulses are issued until the TR00 goes to 0, and then an interrupt is generated.
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
[5847H]
4300H – EXACT COPY OF BOOT/SYS … This is what gets dumped onto a disk. The JUMP values do not match the instruction addresses because it will be Relocated
5853
NOTE: 43EAH is where the DISK SECTOR NUMBER and 43EBH is where the DISK TRACK NUMBER is stored.
NOTE: 43ECH is where the EOF BYTE is stored.
4322H – Data Byte. Number of Backups Permitted.
5875
4323H – Read a Data Block from Diskette into a Memory Buffer Pointed To By HL. If we are here, the byte we read from disk was a DATA BLOCK designator.
5876
So, at this point we have the 01H, so we need to pull the rest of the header bytes from disk. To do this we GOSUB to 433EH (the READ A BYTE FROM DISKETTE routine).
587FH – Start of LOOP to read “B” bytes from the diskette and put them into a buffer starting at HL.
5888H – Get an address from diskette. Basically, this just reads 2 bytes into Register Pair HL; LSB into L and MSB into H.
5891H – Read a Byte from Diskette
5891
NOTE: 43ECH is where the BYTE NUMBER is stored.
If we’re here, we are not at the sector we want.
589BH is the start of a loop of 9 tries to get a good sector read.
… uh oh, we have an error!
At this point we failed 9 times, so its time to error out.
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
NOTE: 021BH will display the character at (HL) until a 03H or 0DH is found.
58B7H – Jumped to by 434FH if we weren’t originally at the sector we wanted, but we are now.
58B7
NOTE: 43EAH is where the DISK SECTOR NUMBER and 43EBH is where the DISK TRACK NUMBER is stored.
- If Register A equals 13H, the Z FLAG is set.
- If A < 13H, the CARRY FLAG will be set.
- if A >= 13H, the NO CARRY FLAG will be set.
If we are here, the sector number is greater than 18 sectors, so we need to bump the track number and reset the sector number to 01H (which is the lowest sector in TRSDOS v1.3 land).
NOTE: 43EAH is where the DISK SECTOR NUMBER and 43EBH is where the DISK TRACK NUMBER is stored.
NOTE: 43ECH is where the BYTE NUMBER is stored.
58D2H – Read a Sector from Diskette
58D2
NOTE: Port F4H is the Floppy drive select and options register. For OUTPUT:
- Bit 0: Drive 0 Select
- Bit 1: Drive 1 Select
- Bit 2: Drive 2 Select
- Bit 3: Drive 3 Select
- Bit 4: Side Select (0 = Select Side 0, 1 = Select Side 1)
- Bit 5: Write Precompensation (0 = Disable WP, 1 = Enable WP)
- Bit 6: Wait State Generation (0 = Disable WSG, 1 = Enable WSG)
- Bit 7: Density Select (0 = Single/FM, 1 = Double/MFM)
NOTE: 4049H is a NMI Vector.
NOTE: 4049H is the RST 0 NMI Vector.
NOTE: Port E4H is the Non-Maskable Interrupt Latch. Sending a Bit 6 and Bit 7 high to E4 will enable the DRQ and INTRQ Interrupts.
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
If we are here, then the FDC returned CONTROLLER READY.
NOTE: Port F4H is the Floppy drive select and options register. For OUTPUT:
- Bit 0: Drive 0 Select
- Bit 1: Drive 1 Select
- Bit 2: Drive 2 Select
- Bit 3: Drive 3 Select
- Bit 4: Side Select (0 = Select Side 0, 1 = Select Side 1)
- Bit 5: Write Precompensation (0 = Disable WP, 1 = Enable WP)
- Bit 6: Wait State Generation (0 = Disable WSG, 1 = Enable WSG)
- Bit 7: Density Select (0 = Single/FM, 1 = Double/MFM)
590AH – This routine was set as the INTERRUPT VECTOR at 438AH. This routine exits with Register A holding the FLOPPY DISK CONTROLLER status.
590A
NOTE: Port E4H is the Non-Maskable Interrupt Latch. Sending a 0 to E4 will turn off all Non-Maskable Interrupts.
NOTE: Port F4H is the Floppy drive select and options register. For OUTPUT:
- Bit 0: Drive 0 Select
- Bit 1: Drive 1 Select
- Bit 2: Drive 2 Select
- Bit 3: Drive 3 Select
- Bit 4: Side Select (0 = Select Side 0, 1 = Select Side 1)
- Bit 5: Write Precompensation (0 = Disable WP, 1 = Enable WP)
- Bit 6: Wait State Generation (0 = Disable WSG, 1 = Enable WSG)
- Bit 7: Density Select (0 = Single/FM, 1 = Double/MFM)
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
5918H – Routine to position the read head based on the contents of HL (H=Track, L=Sector)
5918
NOTE: Port F4H is the Floppy drive select and options register. For OUTPUT:
- Bit 0: Drive 0 Select
- Bit 1: Drive 1 Select
- Bit 2: Drive 2 Select
- Bit 3: Drive 3 Select
- Bit 4: Side Select (0 = Select Side 0, 1 = Select Side 1)
- Bit 5: Write Precompensation (0 = Disable WP, 1 = Enable WP)
- Bit 6: Wait State Generation (0 = Disable WSG, 1 = Enable WSG)
- Bit 7: Density Select (0 = Single/FM, 1 = Double/MFM)
NOTE: 43EAH is where the DISK SECTOR NUMBER and 43EBH is where the DISK TRACK NUMBER is stored.
The reason this is going to the data register is that the FDC seek command requires that the Track Register contains the track number of the current position of the head and the Data Register contains the desired track number.
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
Z FLAG will be set if that bit is 0 (=NOT BUSY), and NZ FLAG will be set if that bit is 1 (=BUSY).
NOTE: Port F2H is the Floppy Disk Controller SECTOR Register.
5933H – Routine delay Of 2 Lengths (Depending on Entry). Used primarily as a short delay between OUTputting to the FDC and INputting from the FDC.
5933
5939
593DH – MESSAGE and BYTE STORAGE AREA.
593D
593F
5940
5947
5950
5951
5952
5953
5954
5957H – Display NOT A SYSTEM DISK and Freeze the System.
5957
[0033H]
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
5964H – MESSAGE and BYTE STORAGE AREA.
5964
5A53H – Write the Bootstrap, System, and Directory to Diskette.
5A53
[4E00H]
[4E00H]
[4E00H]
- If Register A equals 13H, the Z FLAG is set.
- If A < sector 19, the CARRY FLAG will be set.
- if A >= sector 19, the NO CARRY FLAG will be set.
[4E00H]
[5A7DH]
5AB0H – Write a Track of Data.
5AB0
[5AC6H]
NOTE: Port E4H is the Non-Maskable Interrupt Latch. Sending a 0 to E4 will turn off all Non-Maskable Interrupts.
[4400H]
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
[5AD6H]
NOTE: Port F0H is the FDC Status port on input. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
[5ADEH]
NOTE: Port F4H is the Floppy drive select and options register. For OUTPUT:
- Bit 0: Drive 0 Select
- Bit 1: Drive 1 Select
- Bit 2: Drive 2 Select
- Bit 3: Drive 3 Select
- Bit 4: Side Select (0 = Select Side 0, 1 = Select Side 1)
- Bit 5: Write Precompensation (0 = Disable WP, 1 = Enable WP)
- Bit 6: Wait State Generation (0 = Disable WSG, 1 = Enable WSG)
- Bit 7: Density Select (0 = Single/FM, 1 = Double/MFM)
5AEEH – Verify One Track.
5AEE
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
NOTE: 4463H is the storage location for the old system disk side number.
[5AF6H]
5B35H – Position the Diskette Head to the Track held in Register C.
5B35
Send the bit pattern in sent to Port F0H (the Floppy Disk Control Port). When activated one step pulse is sent in the direction of track 76. Once stepped, and interrupt is generated.
5B55H – Convert Register A into a Two Digit Decimal to be stored at (HL).
[5B5FH]
5B5FH – Continuation of the routine to convert Register A into a Two Digit Decimal to be stored at (HL), jumped here once we have a remainder.
5B5F
5B67H – Display a Message.
5B67
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
5B6DH – MESSAGE and BYTE STORAGE.
5B6D
5B89
5B9D
5BB5H – This is the phrase address list.
5BB5
5BBD
5BC5
5BC8
5BD3
5BD6
5BD9
5BEC
5BF1
5C07
5C0AH – MESSAGE and BYTE STORAGE – Sector Number Table.
5C0A
5C1D
5C1FH – Generate the Track Image Area into the Buffer. On Entry, C contains the Track Number.
5C1F
[5C8CH]
[5C36H]
[5C6BH]
+1=”SAVEA”
- If Register A equals track 40, the Z FLAG is set.
- If A < track 40, the CARRY FLAG will be set.
- if A >= track 40, the NO CARRY FLAG will be set.
[5C55H]
If we are here, then we are at track 40, which Frank Durda IV referred to as “the secret track”.
[5C62H]
5C6BH – Continuation of the Generate the Track Image Area; jumped here when we have reached the end of the SECTOR NUMBER TABLE.
5C6B
5C7BH – Retrieve the Table Addresses.
5C7B
5C89
INC IY
5C8CH – Use the Track Building Table to fill up the table pointed to by DE.
On entry, HL points to the beginning of the table. On exit, DE = DE + the length of the fill, HL points to the NEXT table entry, and flags are set.
5C8C
5C96
OR C
[5CA2H]
5CA2H – Continuation of the routine to Use the Track Building Table to fill up the table pointed to by DE; jumped here if we did not hit the copyright message.
5CA2
5CA9
OR C
[5CB1H]
5CAD
POP HL
5CBC
5CBDH – FORMAT and VERIFY a DISK.
First we need to initialize the hash index buffer to 0’s. A common trick is to set up a pointer to a buffer, the destination is 1 byte higher, and the to put a “0” in the first byte, so the 0 just keeps getting copied from a memory location to the memory location + 1.
5CBD
Next, initialize the system extents with a bunch of FFH’s.
Next, initialize the track counter.
[5B35H]
[4E4AH]
[5B55H]
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
- If Register A equals Track 22, the Z FLAG is set.
- If A < Track 22, the CARRY FLAG will be set.
- if A >= Track 22, the NO CARRY FLAG will be set.
[5D15H]
[5D44H]
[5CEDH]
If we are here then we tried 4 times to verify the track and have no more retries left.
[5CE4H]
[021BH]
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
5D60H – MESSAGE and BYTE STORAGE – Final Data Areas.
5D61
5E00
5F00
6000
6100
6160
6200
Entry Point and Initialization
The actual entry point for the SYS07/SYS overlay is at 57A1H (not 4E00H, which is the error handling routine). This section would contain the main initialization and command dispatch logic for BACKUP and FORMAT operations.
Summary of SYS07/SYS Operations
The SYS07/SYS overlay provides comprehensive BACKUP and FORMAT functionality for TRSDOS v1.3:
- BACKUP Operations: Complete diskette copying with support for limited backup counters, password protection verification, and selective file deletion for protected files that exceed backup limits.
- FORMAT Operations: Disk formatting with track/sector verification, flaw mapping, and diskette naming capabilities.
- Error Handling: Comprehensive error detection and recovery, with retry mechanisms and user-friendly error messages.
- Version Checking: Validation that source diskettes are TRSDOS v1.3 compatible before backup operations.
- Progress Display: Real-time status messages showing current track/sector being processed during read/write/verify operations.
- Memory Management: Efficient use of system buffers and workspace areas for gran-based (3-sector) disk operations.
Technical Notes
Key technical aspects of the SYS07/SYS implementation:
- Gran-based I/O: All disk operations are performed in 3-sector units (grans) for efficiency, with automatic sector sequencing and buffer management.
- Limited Backup System: Implements a protection counter in the boot sector to limit the number of times a diskette can be backed up, with automatic counter decrementation.
- Directory Management: Sophisticated directory processing that can selectively delete files marked with limited backup flags when backup limits are exceeded.
- Dual-Drive Support: Handles both single-drive (disk swapping) and dual-drive backup scenarios with appropriate user prompting.
- Track 40 Handling: Special processing for track 40 operations, likely related to double-density disk format considerations.