DOSPLUS 3.5 for the Model III - TRAP/CMD Disassembled
Page Customization
Page Index
TRAP/CMD
Other Navigation
Introduction/Summary
DOSPLUS 3.5 TRAP/CMD Disassembly - The Disk Error Trap (Model III)
TRAP/CMD puts a trap for disk errors into high memory: once it is in place, a read, write, verify or format that fails shows the message of the error and the prompt Abort,Cont,Retry,Ignore ?. Its heading reads TRAP - DOSPLUS Disk error trapper - 3.50. It is a load module of 2 blocks, 332 bytes, at 5200H-534BH with the transfer address 5200H, after the two comment records (the name TRAP and the copyright notice). TRAP/CMD is on the Model III master only.
The Parts of TRAP/CMD
| Address | Contents |
|---|---|
| 5200H-524FH | The installation: HMEM$, the two address operands, the hook of DISKIO%, the copy and the message (5200H). |
| 5250H-5270H | A word shown in hexadecimal (5250H). |
| 5271H-52DFH | The heading and the text Driver installed at (5271H). |
| 52E0H-534DH | The resident part, copied above the new HMEM$: the trap and its prompt (52E0H). |
How TRAP Works
TRAP lowers HMEM$ (4411H) by 110 bytes, the length of the resident part 52E0H-534DH, and copies the part to the first byte above the new HMEM$ (523CH). DISKIO% (4488H) is a JP in SYS0/SYS; TRAP keeps its operand, the disk routine it went to (46A4H, or a trap installed before), as the operand of the resident part's CALL, and puts the address of the resident part in its place (522CH). Running TRAP twice puts a second trap in front of the first. The address of the part is shown after Driver installed at (5244H).
The resident part (52E0H) does the function through the old routine. An error code of a function 03H-09H (DREAD, DVERF, DWRITE, SREAD, SWRITE, DWRITA and DFORMT) is trapped, except the code 06H, a sector read with the data address mark of the directory, which the system takes as a result and not an error; errors of DCHECK, DHOME and DSEEK (functions 00H-02H) go back to the caller as they are (52EBH). A trapped error is shown by ERROR@ with bits 7 and 6 set (return, and no frame of asterisks), then the prompt, and a reply of one character is taken by the ROM's line input 0040H (5313H). A (or BREAK) goes to ABORT@, C returns the error to the caller, I returns 00H with the Z FLAG as if the function had worked, and any other reply, R or not, does the function again with the caller's registers (5321H).
A Slip in the Installation
The resident part holds two addresses of its own, the prompt (the operand at 5309H) and the buffer for the reply (530FH), which TRAP must move by the distance from 52E0H to the new place. The prompt is moved right (521CH). For the buffer TRAP adds the distance to the old operand and then stores the distance itself, LD (530FH),BC where LD (530FH),HL was meant (5227H). The moved part therefore takes the reply into the two bytes at the address the distance gives, the new place less 52E0H: with the resident part at FF92H, for one, at ACB2H-ACB3H, inside the memory of the program that called DISKIO%. The prompt still works, since the reply is read back from where it was written, but each reply writes the character and its 0DH over those two bytes of that program.
Differences from the Manual
The manual (Utilities, TRAP) describes the prompt as Abort, Continue, Retry, Ignore?; the file shows Abort,Cont,Retry,Ignore ?. The manual does not say which errors are trapped (only those of the reads, writes, verify and format, and not the code 06H), that BREAK aborts as A does, or that any reply other than A, C and I retries. It says the trap stays until a reset or until a configuration file without TRAP is loaded; TRAP itself has no way to remove the trap.
Variables
TRAP/CMD Variables
| Address Size | Contents |
|---|---|
| 52E2H-52E3H 2 bytes | Old disk routine The operand of the resident part's CALL: the old target of DISKIO% (522FH). |
| 5309H-530AH 2 bytes | Prompt address The operand of LD HL at 5308H, moved at 5220H (521CH). |
| 530FH-5310H 2 bytes | Buffer address The operand of LD HL at 530EH, set to the distance at 5227H (5223H). |
| 534CH-534DH 2 bytes | Reply buffer The character and its 0DH, as loaded (530EH). |
Memory Outside TRAP/CMD
| Address Size | Contents |
|---|---|
| 4411H-4412H 2 bytes | HMEM$ Lowered by 110 bytes (5206H). |
| 4489H-448AH 2 bytes | DISKIO% operand The operand of the JP at 4488H, set to the resident part (5232H). |
Outside Routines
| Address | Contents |
|---|---|
| 4467H | SYS0/SYS: DSPLY@ (5203H, 5241H, 530BH). |
| 4409H | SYS0/SYS: ERROR@ (5305H). |
| 4030H | SYS0/SYS: ABORT@ (5317H, 531EH). |
| 4488H | SYS0/SYS: DISKIO%, hooked (522CH). |
| 0033H | ROM: display a character (524CH, 5258H, 52FFH). |
| 0040H | ROM: line input (5313H). |
Disassembly
5200H - TRAP
TRAP/CMD's transfer address, entered from the DOS command level (TRAP has no parameters). TRAP shows its heading, takes 6EH bytes below HMEM$ for its resident part (52E0H-534DH), sets that part's two address operands for the new place, hooks DISKIO% (4488H) through the operand of its JP at 4489H-448AH, copies the part up and shows Driver installed at with the address in hexadecimal. It returns to the DOS by RET.
5250H - Show a Word in Hexadecimal
Displays Register Pair HL as four hexadecimal digits followed by H, through the ROM's 0033H.
52E0H - The Resident Part: DISKIO%
110 bytes (52E0H-534DH) copied above the new HMEM$ at 523CH; DISKIO% (4488H) jumps here with Register A the function, Register C the drive, Register D the cylinder, Register E the sector and Register Pair HL the buffer. The old disk routine does the function. An error of a function 03H-09H, other than the code 06H, shows the message of the error and the prompt Abort,Cont,Retry,Ignore ?: A or BREAK ends through ABORT@, C returns the error, I returns 00H with the Z FLAG as if the function had worked, and any other reply does the function again. The addresses on this page are those of TRAP/CMD as loaded.