DOSPLUS 3.5 for the Model III - CODIR/CMD Disassembled
Page Customization
Page Index
CODIR/CMD
Other Navigation
Introduction/Summary
DOSPLUS 3.5 CODIR/CMD Disassembly - CO-DIR 2.1, the Cursor Oriented Directory (Model III)
CODIR/CMD is CO-DIR 2.1 by Hunt K. Brand, licensed to Micro-Systems Software, run from the DOS command level as CODIR with the parameters of CAT; its title reads CO-DIR 2.1 - Cursor Oriented DIR. (C) 1983 by Hunt K. Brand. It is a load module of 30 blocks, 3745 bytes, at 8000H-8EA0H with the transfer address 8000H, after the two comment records (the name CODIR and the copyright notice). CODIR/CMD is on the Model III master only, but the program runs on both models: the byte 49H at 0125H, in the Model III ROM, picks the Model III's command buffer 4225H and HMEM$ 4411H, else the Model I's 4318H and 4049H (8000H, 8060H). The configuring program CODIR21/MOD on the master has no page.
CODIR runs CAT with the parameters typed after its name, through CMNDI@, with ABORT@ pointed at its own end (885AH) and a hook in the display driver at 401EH (8AD6H) that saves every line shown into a buffer from 9000H, 64 bytes a line, up to HMEM$ less 80H, clicking port FFH for each character. Then two blinking cursors, on a file's name and 12 places to its right where CODIR puts its marks, pick a file on the screens kept in the buffer, and a key runs a DOS command on it. All sounds go out through bit 0 of port FFH, the cassette output (88E7H).
The Parts of CODIR/CMD
| Address | Contents |
|---|---|
| 8000H-8158H | The start: the command line CAT, the title, the hooks, the listing and the first file (8000H, 8102H). |
| 8159H-82F8H | The cursors, the keys and the moves of the cursors (8159H, 81D9H). |
| 82F9H-8433H | The commands D, A, F, V, H and S, the search (82F9H, 83B2H). |
| 8434H-86FAH | The commands on the file: K, G, O, J, Z, F and M, P and C, L, the run on a cleared screen and R (8434H, 8520H, 8561H, 85C3H, 8605H, 8690H, 86AAH, 86E8H). |
| 86FBH-8869H | The line input, ENTER, the return to the cursors and the end through ABORT@ (86FBH, 87FEH, 883CH, 885AH). |
| 886DH-8A9CH | The decimal number, the running of a command line, the tones, the places of the cursors, the command line of the screen, the drive question, a key and the comparison of a name (886DH, 88BFH, 88E7H, 8918H, 8958H, 89CBH, 8A50H, 8A78H). |
| 8A9DH-8B9AH | The buffer, the display hook and the scrolling of the screens (8A9DH, 8AD6H, 8B4CH). |
| 8B9BH-8EA0H | The variables, the texts and the command line (8B9BH, 8BF2H). |
How CODIR Works
The display hook counts the places of each line and fills the rest of a line with spaces at its carriage return, with the mark 8FH after the last line; it is taken out by the graphic 85H that CODIR shows after CAT, by a full buffer or by BREAK at the end of a line (8AD6H). CODIR then shows the last screen saved, finds the last line with files on the screen and puts the cursors on the first file, line 3 (80ADH). The arrows move the cursors a line or a column of 15 characters, scrolling the screens through the buffer, and SHIFT with the up arrow goes to the first screen; empty places and files marked with an asterisk are passed over unless the space bar is held (81D9H, 8938H). BREAK or CLEAR ends CODIR.
D and A run CAT again on a drive asked for (D with SHIFT adds (I), A gives (I,A)) into a new buffer (8339H); F runs FREE :d, V shows the title and the licence, H the keys, S searches (83B2H). The other keys copy the file's name from the screen to 8E40H with :d, the drive of the listing, after it; with SHIFT (a lower case key) a password is asked for first and put after a period (8434H). Each asks its question on the command line, the last line of the screen, Y for yes, and builds its command line from the first word of its question: Kill, Clear (Z), List (L, and with @PR for P), Copy name:d :e,T (C), Diskdump (M), Rename (R), Load (O) and Do (J); ENTER runs a CMD file, or any file with the space bar held, as a program, and any other through BASIC name:d -F:03 (87FEH). O, J and ENTER leave CODIR through CMNDI@ (8831H); the others run through CMNDI@ and return (88C9H), K, Z, R and C putting a mark (an asterisk, Z, R or the drive) next to the file. G shows the size: the end of the file in sectors, a part sector counted as one, divided by four, as nnk or <k (8520H).
Differences from the Manual
The title says 1983 (the manual 1982). The test of the title (8090H) looks only at the H of Hunt, after the listing; a changed letter gives 50 warnings (C) NAME MODIFIED! RE-BOOT! and the return to the DOS (8090H). The cursors pass over empty places and files marked with an asterisk by K; nothing tests for system files (8938H). A space at the question of a drive cancels it with the high tone, as any key but a drive, the backspace and ENTER does (the manual: spaces are ignored) (89DEH). G shows the size with a lower case k, and <k for a file of fewer than four sectors; an error of OPEN@ is posted by ERROR@ and ends CODIR (855BH). The copy adds the parameter T after a comma; BASIC is always given -F:03 (the manual: the number set with CODIR2/MOD). Closing the buffer, at the normal end of the listing too, sounds the high tone (the manual: a low tone) (8B43H).
Variables
CODIR/CMD Variables
| Address Size | Contents |
|---|---|
| 8B9BH-8B9FH 5 bytes | Buffer The screen shown, the last byte saved and the count of the line (8AD6H). |
| 8BAAH-8BABH 2 bytes | End of the buffer HMEM$ less 80H (807EH). |
| 8BCAH-8BD5H 12 bytes | Search (83CBH). |
| 8BE0H-8BEEH 15 bytes | Cursors The cursor, its row and column, the characters under the cursors, the drive and the place of a command line (8159H). |
| 8BEFH-8BF1H 3 bytes | Modes Of the line input and the drive question (86FBH). |
| 8D0BH-8D0CH 2 bytes | Default drive (8A19H). |
| 8E37H-8E85H 79 bytes | Command line The command word before the name at 8E40H (8434H). |
| 8E86H-8EC5H 64 bytes | Copy The command line run (88C9H). |
| 9000H to HMEM$ less 80H | The screens 64 bytes a line, 15 lines a screen (8A9DH). |
Memory Outside CODIR/CMD
| Address Size | Contents |
|---|---|
| 3C00H-3FFFH 1024 bytes | Video RAM The listing, line 16 the command line (8B7FH). |
| 3840H, 3880H 2 bytes | Keyboard The row of ENTER, CLEAR, BREAK, the arrows and the space bar, and the row of SHIFT (81B2H). |
| 401EH-401FH 2 bytes | Display driver Hooked during CAT (8AC9H). |
| 4020H-4021H 2 bytes | Cursor (89AFH). |
| 4031H-4032H 2 bytes | ABORT@ Pointed at 885AH during CAT (805DH). |
| 4049H, 4411H 2 bytes | HMEM$ Of the Model I and the Model III (8067H). |
| 4225H, 4318H 64 bytes | Command line Of the Model III and the Model I (800DH). |
Outside Routines
| Address | Contents |
|---|---|
| 4405H | SYS0/SYS: CMNDI@ (88E0H, 8839H). |
| 4424H | SYS0/SYS: OPEN@ (853DH). |
| 4409H | SYS0/SYS: ERROR@ (855BH). |
| 4467H | SYS0/SYS: DSPLY@ (8044H). |
| 402DH | SYS0/SYS: EXIT@ (814CH). |
| 002BH | ROM: scan the keyboard (816FH). |
| 0033H | ROM: display a character (89AAH). |
| 01C9H | ROM: clear the screen (89C1H). |
| 0125H | ROM: the byte 49H of the Model III ROM (8006H). |
Disassembly
8000H - CODIR
CODIR/CMD's transfer address, entered from the DOS command level as CODIR with the parameters of CAT. CO-DIR 2.1 by Hunt K. Brand runs CAT through CMNDI@ while its own display hook (8AD6H) saves every line shown into a buffer from 9000H, then lets two blinking cursors pick a file on the screens kept there and runs a DOS command on it. The program runs on the Model I and the Model III: the byte 49H at 0125H (the Model III ROM) picks the Model III's command buffer 4225H and HMEM$ 4411H, else the Model I's 4318H and 4049H.
814FH - Leaving CODIR
BREAK or CLEAR sounds the low tone and returns to the DOS through EXIT@.
8159H - The Cursors
The character at the cursor (8BE0H) and the one 12 places to its right (8BEDH, where CODIR marks a file) are shown as graphic blocks for a time and then as they are, while the keyboard is scanned through 002BH. A key in the row 3840H held down makes the shown time shorter (4BH scans in place of FFH). A key goes to 81A1H.
81D9H - Moving the Cursors
The arrows held down in the row 3840H move the cursor: up and down a line (rows 0 to the last row at 823AH, from line 3 of the screen), the screen scrolled through the buffer at the top and the bottom; left and right a column of 15 characters (0 to 3). SHIFT with the up arrow goes to the first screen of the buffer. Places with nothing or a file marked with an asterisk are passed over (8938H) unless the space bar is held.
82F9H - The Commands
The key of 8BE4H, made upper case: D and A list another drive (SHIFT with D adds (I), A gives (I,A)), F the free space map, V the title and the licence, H the keys on the command line; S searches; the keys of the list at 8CA8H (C G J K L M O P R Z and ENTER) work on the file at the cursor, with SHIFT (a lower case key) asking for a password first. Any other key sounds the high tone.
83B2H - S - The Search
Search for: takes up to 12 characters into 8BCAH (ENTER alone keeps the last ones, all question marks at the start). From the place after the cursor, each file shown is compared: a search starting with a slash compares the extension (8A78H), another the name from its first character (8A88H), a question mark matching any character. A file found keeps the cursor with the low tone; the end of the buffer sounds the high tone.
8434H - A Command on the File
The file at the cursor is copied from the screen to 8E40H; a file marked with an asterisk sounds the high tone. With SHIFT held (8BEFH 80H) Password: asks for up to eight characters, put after a period. Then :d, the drive of the listing, is added and the key's command is run: K kills, and the other keys go on at 84EAH.
8520H - G - The Size of the File
The file is opened (OPEN@ with the name line 8E40H as its control block) and its size in sectors, a part sector counted as one, is divided by four and shown as kilobytes, nnk, or <k for none; an error of OPEN@ is posted by ERROR@ and CODIR ends.
8561H - O, J and Z - LOAD, DO and CLEAR
O runs LOAD name:d and J runs DO name:d through CMNDI@ (8831H), so CODIR ends; Z runs CLEAR name:d after two warning tones and marks the file with Z.
85C3H - F and M - FREE and DISKDUMP
F asks for a drive and runs FREE :d; M runs DISKDUMP name:d. Both save the screen, run the command on a cleared screen (86AAH) and ask for BREAK or CLEAR (the DOS) or another key (the directory again).
8605H - P and C - Printing and Copying
P runs List name:d @PR after the warning tone. C asks for a drive other than the listing's (the same drive sounds the high tone) and runs Copy name:d :e,T, marking the file with the drive it went to.
8690H - L - Listing the File
List name:d on a cleared screen (86AAH), then BREAK or CLEAR for the DOS, any other key for the directory.
86AAH - Running a Command on a Cleared Screen
The command line on the stack is shown at the top of a cleared screen and run through CMNDI@ (88C9H). Then the question Press <BREAK or CLEAR> for Dos: BREAK or CLEAR ends CODIR, any other key brings the screen of the buffer back with the title and a pause.
86E8H - R - Renaming the File
Rename to : takes up to 12 characters (86FBH), puts the new name over the old one on the screen and runs Rename name:d newname, marking the file with R.
86FBH - The Line Input
Takes characters into the field on the command line between the border 85H before it and 8AH after it: the backspace (08H) takes one back, a code below 1FH other than ENTER sounds the high tone, BREAK, CLEAR and SHIFT with the left arrow (18H) cancel. ENTER puts the field, upper case, after a space at 8BEAH (8BCAH for the search, a period before a password), and for the rename onto the screen and into the command Rename.
87FEH - ENTER - Running the File
A file with the extension CMD, or any file while the space bar is held, is run as a program: its name is the command line. Any other file is run as BASIC name:d -F:03. The screen is cleared, the command line shown and given to CMNDI@ (4405H), so CODIR ends.
883CH - Back to the Cursors
883CH shows the title on the command line, 8844H sounds the low tone, 8849H the high tone; then 884CH waits until no key but an arrow or the space bar is held and shows the cursors again (8159H).
885AH - CODIR's ABORT@
While CAT runs, ABORT@ (4030H) jumps here (805DH): ABORT@ is set back, the display hook is taken out, the high tone sounds and CODIR returns to the DOS through EXIT@.
886DH - A Decimal Number and k
Displays Register Pair HL as a decimal number by the powers of ten at 8BA0H, with no zeros before the first digit (8BC8H counts the digits shown), then the letter k; with no digit shown, < before the k.
88BFH - Running a Command Line
88BFH shows the command line at Register Pair HL on the command line of the screen first. 88C9H copies up to 64 bytes from Register Pair HL to 8E86H, leaving out every 00H, and runs the copy through CMNDI@; the command returns here and the low tone sounds.
88E7H - The Tones
Three tones through bit 0 of port FFH, the cassette output: 88E7H the warning (5AH cycles, half period 64H), 88EFH the low tone of a command done (14H cycles, C8H), 88F7H the high tone of an error (50H cycles, 0FH). The half period is put into the operand 8901H of the LD B at 8900H. Register Pair AF and Register Pair BC are kept.
8918H - The Places of the Cursors
8918H puts back the characters under the two cursors and returns the cursor's address; 8927H steps Register Pair HL 12 places on and keeps the character there at 8BECH; 8930H gives the Z FLAG while the space bar is held; 8938H gives the Z FLAG (Register A 80H) for a place to pass over: nothing at the cursor, or an asterisk 12 places on, unless the space bar is held; 8945H tests only the asterisk.
8958H - The Command Line of the Screen
8958H shows the name at 8E40H on the command line and puts the cursor at 3FD8H after it; 896AH also shows the question at Register Pair HL and takes a key (y becomes Y), shown when printable; 8992H clears the command line and 8997H shows a text up to its 03H or 0DH at the cursor; 89A9H displays Register A through the ROM's 0033H; 89AFH clears the command line (3FC0H); 89C0H clears the screen.
89CBH - Which Drive
Shows which drive (d)? (8CFDH, the default drive at 8D0BH) and takes one or two characters ended by ENTER, the backspace taking one back: Register A returns the drive, Register C the second character or 00H, and the answer becomes the default. ENTER alone gives the default drive (8BF1H is 80H from 812DH). Any other key, a space too, sounds the high tone and returns 80H, the question cancelled. 89CEH shows the question at Register Pair HL.
8A48H - A Pause
Waits Register C times 256 turns of a DJNZ loop (00H in Register C for 256 times).
8A50H - A Key with a Blinking Block
Shows a graphic block and a space by turns at the cursor (4020H) while the ROM's 002BH is scanned, 256 scans each (the LD C,3CH has no use), until a key: Register A returns it and the cursor's place is left a space. Register Pair BC, Register Pair DE and Register Pair HL are kept.
8A78H - Comparing a Name
8A78H looks for the slash in the eight characters after Register Pair HL and compares the extension after it with the three characters after Register Pair DE; 8A88H compares Register B characters after Register Pair HL and Register Pair DE. A question mark at Register Pair DE matches any character and a 0DH there ends the comparison: the Z FLAG (Register A 80H) for a match.
8A9DH - The Buffer and the Display Hook
The mark 8FH goes below the buffer (8FC0H) and after its first screen (93C0H), the first 1024 bytes from 9000H are spaces, the place of the last byte saved (8B9DH) is 8FFCH and the count of a line 44H, so the first line saved ends at 903FH. The display driver's address at 401EH is kept in the CALL at 8AD6H and 8AD6H put in its place.
8AD6H - The Display Hook
Each character is displayed by the driver (the CALL's operand 8AD7H), a click sent to port FFH, and then saved at 8B9DH on: a 0DH fills the rest of the line of 64 places with spaces and puts the mark 8FH after it. The graphic 85H (shown at 80B2H after CAT), the buffer reaching 8BAAH, or BREAK at the end of a line takes the hook out (8B47H).
8B4CH - Scrolling the Screens
8B4CH shows the screen one line back in the buffer, 8B63H one line on; each returns the Z FLAG (Register A 8FH) at the mark at the start or the end of the buffer. 8B59H saves the screen into the buffer and shows the screen at Register Pair HL; 8B7FH copies 15 lines from Register Pair HL to the screen (Register A 80H, the NZ FLAG); 8B8CH copies the screen's 15 lines back to the buffer, so changes made on it are kept.
8B9BH - The Variables and Tables
The pointers of the buffer, the powers of ten, the warning of a changed title, the search, the words CAT and CMD, the cursor and the state of a command. 00H as loaded where CODIR sets the value itself.
8BF2H - The Texts
The title and the licence, the commands CAT with its options, the help line, the questions and prompts (each ended by 03H) and the command line built at 8E37H-8E85H, which as loaded holds a second copy of the title, written over before it is used.