Chapter 8 - Utility Commands Description of the ConIX internal utility commands, available for use on the command line. - CONTENTS - __________________________________________________________________ 8. Utility Commands...................................... 8-1 8.1 = (Equals): Set Disk Variables.................... 8-1 8.2 ATRIB: Get/Set File Attributes.................... 8-2 8.3 BDEC: Convert Binary to Decimal................... 8-3 8.4 BOT: Print Bottom Address of ConIX................ 8-3 8.5 BTOP: Print BDOS Top Address...................... 8-4 8.6 BYE: Exit to CP/M................................. 8-4 8.7 CHR: Convert ASCII to Hex......................... 8-4 8.8 CLS: Output Clear Screen Sequence................. 8-4 8.9 COPY: Copy a Disk File............................ 8-5 8.10 DECB: Convert Decimal to Binary................... 8-5 8.11 DEL: Delete Files with Confirmation............... 8-6 8.12 DIR: List Directory............................... 8-6 8.13 ECHO: Print Arguments............................. 8-8 8.14 ERA: Erase Files.................................. 8-9 8.15 EXAM: Examine Memory.............................. 8-9 8.16 EXEC: Execute Arguments........................... 8-9 8.17 FILL: Fill Memory with a Constant................. 8-10 8.18 FIND: Find File in Search Path.................... 8-10 8.19 FLUSH: Empty the Print Spooler.................... 8-11 8.20 HXPR: Convert Hex to ASCII........................ 8-11 8.21 IN: Input Data From a Port........................ 8-11 - i - 8.22 INDEX: Find String................................ 8-11 8.23 LOG: Log-In a Drive............................... 8-12 8.24 MOVE: Copy Memory................................. 8-13 8.25 OPT: Enter ConIX Options.......................... 8-13 8.25.1 +/-AF: Set Archive File Location............. 8-14 8.25.2 +/-BC: Set Boot Command...................... 8-15 8.25.3 +BP: Set Bell in Prompt...................... 8-15 8.25.4 -BP: Remove Bell in Prompt................... 8-15 8.25.5 +/-CD: Set Data Files Location............... 8-15 8.25.6 +/-CS: Set Clear String Sequence............. 8-15 8.25.7 +/-CX: Set ConIX Program Location............ 8-16 8.25.8 +/-DC: Set Number of DIR Columns............. 8-16 8.25.9 +DL: Auto-Login on Disk Reset................ 8-16 8.25.10 -DL: No Login on Disk Reset.................. 8-17 8.25.11 +DR: Disk Reset on Warm Boot................. 8-17 8.25.12 -DR: No Reset on Warm Boot................... 8-17 8.25.13 +DW: Enable Disk Wait Control................ 8-17 8.25.14 -DW: Disable Disk Wait Control............... 8-17 8.25.15 +/-ER: Restore ConIX Environment............. 8-17 8.25.16 +/-ES: Save ConIX Environment................ 8-18 8.25.17 +/-FC: Set Function Character Keys........... 8-18 8.25.18 +/-FK: Set Function Keys Lead-in............. 8-19 8.25.19 +GS: Set the GOSUB Stack..................... 8-19 8.25.20 -GS: Restore the GOSUB Stack................. 8-19 8.25.21 +/-IA: Set Input Port Address................ 8-20 8.25.22 +/-IB: Set Input Buffer Length............... 8-20 8.25.23 +/-IP: Set Input Port Device................. 8-20 8.25.24 +/-MM: Set Memory Management................. 8-21 - ii - 8.25.25 +/-OA: Set Output Port Address............... 8-21 8.25.26 +/-OB: Set Output Buffer Length.............. 8-22 8.25.27 +/-OP: Set Output Port Device................ 8-22 8.25.28 +PC: Enable Command Print.................... 8-23 8.25.29 -PC: Disable Command Print................... 8-23 8.25.30 +/-PF: Set Pipe File Location................ 8-23 8.25.31 +PR: Enable Transcript Mode.................. 8-23 8.25.32 -PR: Disable Transcript Mode................. 8-24 8.25.33 +PS: Set Print Spooling...................... 8-24 8.25.34 -PS: Disable Print Spooling.................. 8-24 8.25.35 +SA: Enable Archive Searching................ 8-25 8.25.36 -SA: Disable Archive Searching............... 8-25 8.25.37 +SB: Set BDOS Address (&0006)................ 8-25 8.25.38 -SB: Reset BDOS Address...................... 8-26 8.25.39 +/-SL: Set Screen Length..................... 8-26 8.25.40 +SO: Enable Spooler on Output................ 8-26 8.25.41 -SO: Disable Spooler on Output............... 8-26 8.25.42 +/-SP: Set Disk Search Path.................. 8-26 8.25.43 +SS: Set the SWITCH Stack.................... 8-27 8.25.44 -SS: Restore the SWITCH Stack................ 8-27 8.25.45 +/-ST: Set Sleep Time Constant............... 8-27 8.25.46 +TA: Set Type-Ahead Buffer................... 8-28 8.25.47 -TA: Reset Type-Ahead Buffer................. 8-28 8.25.48 +/-TC: Set Type-Ahead Cancel Character....... 8-28 8.25.49 +TE: Enable Type-Ahead Echo.................. 8-28 8.25.50 -TE: Disable Type-Ahead Echo................. 8-29 8.25.51 +TR: Enable Command Tracer................... 8-29 8.25.52 -TR: Disable Command Tracer.................. 8-29 - iii - 8.25.53 +UC: Set Upper Case Mapping.................. 8-29 8.25.54 -UC: Disable Upper Case Mapping.............. 8-29 8.25.55 +/-VF: Set Variable File Location............ 8-30 8.25.56 +XD: Enable ExpanDisk References............. 8-30 8.25.57 -XD: Disable ExpanDisk References............ 8-30 8.25.58 +/-XS: Set Extension Search List............. 8-30 8.25.59 +XU: Set Extended User Areas................. 8-30 8.25.60 -XU: Disable Extended User Areas............. 8-31 8.26 OUT: Output Data to a Port........................ 8-31 8.27 READ: Read a File into Memory..................... 8-31 8.28 REN: Rename a Disk File........................... 8-31 8.29 RESET: Reset Disks................................ 8-32 8.30 SET: Set Disk Variables........................... 8-32 8.31 SRCH: Search for a Byte in Memory................. 8-33 8.32 TEXT: Read Text with Editing...................... 8-34 8.33 TOP: Print Top Address of ConIX................... 8-34 8.34 TYPE: List File Contents.......................... 8-35 8.35 UDIR: List Files Through User Areas............... 8-35 8.36 WP: Write Protect Disks........................... 8-35 8.37 WRITE: Write Memory to a File..................... 8-36 8.38 XSTAT: Print Exit Status.......................... 8-36 8.39 ZAP: Modify Memory................................ 8-37 8.40 Command Name Conflicts............................ 8-37 - iv - ConIX Operating System Utility Commands 8. Utility Commands There are two major classifications of commands under the ConIX environment. The first is the disk-based commands, which are executable programs stored on disk in files whose names end with a .COM extension. These commands are loaded from disk into memory each time they are requested on the command line. The second classification is the internal commands, which are executable programs that are resident within ConIX itself. They are loaded from the main CONIX.COM file, and executed directly from the memory which ConIX occupies. These built-in functions are used for such mundane tasks as listing, examining, erasing, and renaming files. Also available are commands that allow access to system memory. The sections that follow will detail the usage of the ConIX internal utility commands. 8.1 = (Equals): Set Disk Variables = (value) The `=' or Equals command is used to set the contents of the 52 disk-based letter variables. The variable to be set is specified by a single upper/lower case letter, a-z or A-Z. Its value may be supplied as the following argument on the command line. If no value is given, a line of raw (uneditable) console input will be taken as the value. For example, the command line: = a "hello" will set the variable $A to contain the string "hello". Similarly, the command: = a hello will also set the $A variable to the value of "hello". The only difference is that, in the latter case, the value of the variable was taken from the console input stream instead of the command line. This is most useful for setting a variable from the output stream of a program, as: dir | = a where $A is set to the first line of the output from the DIR command. Any control characters passed through the input stream of the command will not be stripped, but stored as data within the variable. For example, the sequence: 8-1 Utility Commands ConIX Operating System = a g<-hello where you typed a `g' by mistake, hit backspace, then typed the correct string. The $A variable will contain the backspace control character (CTRL-H), since the variable is set to the raw input from the keyboard. The end of input is signaled by the or CTRL-M character. To input with editing, use: getl |@ = where the GETL command will read a line of editable input from the system keyboard into the given variable. The contents of all letter variables are stored in the disk file A:0/VARS.SET. This file is created with its SYStem attribute set, and will therefore not appear in a regular directory listing. If the file does not exist, it will be created when a variable is set. Each variable stored in the file is assigned a maximum space of 255 bytes. The directory location of the variables file is settable via the OPT +/-VF internal command. Should the command line argument be null (""), or the input contain only a blank line, the variable will be reset to contain no value. All letter variables are initialized to hold no data value. If the variable had a value and was later reset to null, its entry slot is freed from the disk variable file. This slot may later be occupied by the same or another variable. Disk space is not freed by this action. 8.2 ATRIB: Get/Set File Attributes atrib <#num> <#action> There are special attributes which may be set in the name of a file that indicate certain things about the way it is stored. For example, the SYStem or DIRectory attribute determines whether or not the file will be printed in a regular directory listing. There is also the R/O (Read-Only) and R/W (Read-Write) attribute which determines if a file may be modified. The ATRIB command allows you to manipulate these file attributes. The num argument refers to the particular attribute bit, a number which may range from 0-11. Each attribute number corresponds the setting of the high-bit of one of the twelve possible characters in a filename. The action argument determines the action that is to take place on the specified attribute. If action is 0, the attribute is reset to zero (the hi-bit turned off). If action is 1, the attribute bit will be activated. If action is 2, the current setting of the attribute will be listed. The filename argument specifies the file that is to be affected by this action. 8-2 ConIX Operating System Utility Commands Although 12 attributes are available, only two are actually pre- assigned certain meanings. They are: tab(@); lw(.5i)0 l l. #9@0 = R/W@1 = R/O #10@0 = DIR@1 = SYS The others are available for your own purposes. To illustrate, let's say you wanted to find if a file has its SYS attribute set. You may type: atrib 10 2 foo.asm 0 which prints the setting of the tenth attribute bit of the file FOO.ASM. In this case it is zero, indicating that the file is DIR. You may now decide to change it to SYS, as: atrib 10 1 foo.asm which sets the tenth attribute to an ``on'' value, thus making the file SYS. Examining this attribute would now show: atrib 10 2 foo.asm 1 where the `1' indicates that the attribute bit is set. 8.3 BDEC: Convert Binary to Decimal bdec (&num) BDEC will convert the 16-bit hexadecimal number, num, given as its argument into its decimal equivalent. For example: bdec ffff 65535 where FFFF hex is equal to 65535 decimal. 8.4 BOT: Print Bottom Address of ConIX bot The BOT internal command prints the bottom or ending address of ConIX in memory. This address references the first byte after the last memory location occupied by ConIX. Memory between this address and the start of the BDOS (as reported by the BTOP command) is not used by any system or application software, and is 8-3 Utility Commands ConIX Operating System available for private data storage. Note that this area may be lengthened by specifying a lower relocation address at INSTALL time. 8.5 BTOP: Print BDOS Top Address btop BTOP is used to determine the top or starting address of the CP/M BDOS in memory. This address points to the first byte of the JMP instruction into the original CP/M syscall decoder. 8.6 BYE: Exit to CP/M bye The BYE command will terminate the execution of ConIX, and return control to the resident CP/M CCP. This command, in effect, performs a BIOS warm boot operation, which causes CP/M and the CCP to be reloaded from the system tracks of the A: disk, and then executed. Of course, be sure that the disk in A: contains a CP/M system image before executing BYE. 8.7 CHR: Convert ASCII to Hex chr (string) CHR will convert and print the hexadecimal equivalent of the ASCII character string given as its first argument. For example, the command: chr "hello" 68 65 6C 6C 6F where `h' was converted to 68 hex, `e' to 65, etc. 8.8 CLS: Output Clear Screen Sequence cls CLS will output the contents of the clear screen sequence, as set by the OPT +/-CS internal command. This feature was chosen so as to provide portability between systems that use different character sequences to clear the terminal screen. 8-4 ConIX Operating System Utility Commands 8.9 COPY: Copy a Disk File copy = This command will copy the contents of the disk file source to the file dest. For example: copy foo.sav=foo.asm will make a copy of the file FOO.ASM in FOO.SAV. The destination file must be non-existent, or else an error message will be printed and the copy function will be aborted. Additionally, you may copy from a source file that is stored in a different disk or user area, as: copy foo.sav=b:10/foo.asm where the source file resides on B:10/ and the copy will be made in the current default directory. If the copy is also to reside in a different directory, specify the disk and/or user area as: copy b:10/foo.sav=b:10/foo.asm where the copy will be made in B:10/, the same directory that contains the source file. If the filename and extension specification in dest is not supplied, the source filename will be assumed, as: copy a:=b:foo.asm where a copy of B:0/FOO.ASM is made in A:0/. Note that the COPY command uses TPA memory from location 100 until the top of ConIX (if necessary) to buffer the read/writes. Programs or data residing in the TPA may be overwritten by this function. Note that COPY strips the R/O (read-only) attribute bit when creating the destination file. 8.10 DECB: Convert Decimal to Binary decb (#num) DECB will convert the decimal number, num, given as its argument, into its 16-bit hexadecimal equivalent. For example: decb 65535 FFFF 8-5 Utility Commands ConIX Operating System where 65535 decimal is equal to FFFF hex. 8.11 DEL: Delete Files with Confirmation del The DEL command is used for deleting disk files with user- interactive questioning. For each file that is specified or matched, the user is asked to confirm whether or not the file is to be deleted. Respond with a `y' to erase the file, or any other character to leave it on disk. These responses are read in ``raw'' mode as single characters, therefore no carriage return is necessary after your response. Any combination of filenames or patterns (using the `*' and `?' characters) may be specified as arguments to DEL. For example: del foo.asm 10/*.com A:00/FOO.ASM (y/n) ? y A:10/FOO.COM (y/n) ? n A:10/BAR.COM (y/n) ? where only the first file, FOO.ASM, was deleted since the user responded with a `y' affirmative. Note that the command: del *.* is quite powerful, although not dangerous at all, since you are given the ability to selectively delete the matched files. It is recommended if you have a disk with many files to clean up, and do not want to specify each one on the command line. 8.12 DIR: List Directory dir (file(s)) The DIR command is used to list the files stored in the disk directory. Any combination of filenames or patterns (using the `?' and `*' characters) may be specified as arguments to DIR. For example: dir foo.asm *.com A:00 FOO ASM A:00 FOO COM : BAR COM where the requested file and any files matching the given pattern were listed. If no file arguments are specified, the current disk directory will be listed, as: 8-6 ConIX Operating System Utility Commands dir A:00 FOO ASM : FOO COM : BAR COM If only a disk and/or user area is specified, the entire directory of that disk and user area will be listed, as in: dir b: 10/ B:00 FOOBAR ASM A:10 FOOSAV ASM : BARSAV ASM Note that the extra white space before and after the listed filenames is used to indicate whether a file has its SYStem (invisible) or R/O (read-only) attributes set. If the file is stored with its invisible attribute set, it can only be listed by specifying a pattern or its exact filename, and its name will be enclosed in parenthesis to indicate the setting of this attribute. A file which is stored with its read-only attribute set will be listed with an asterisk to the right of its name. For example, let's say the directory of A:01 contained the following files: TEST.ASM - Read Only, TEST.HEX - System, and TEST.COM - Read Only and System. The command: dir 1/ A:01 TEST ASM * lists only one file, TEST.ASM, which is read-only. The other two files are not listed because they have the invisible attribute set. We can, therefore, define ``invisible'' as meaning that the file will not be printed in a regular directory listing. This feature can be defeated by typing: dir 1/*.* A:01 TEST ASM *: (TEST HEX) : (TEST COM)* which lists all the files in the directory, including the invisible ones. The total number of all files listed is stored in the $$0 hex variable, which is accessible as: bdec $$0 3 which, after the previous example, would be 3, since that many files were listed. 8-7 Utility Commands ConIX Operating System 8.13 ECHO: Print Arguments echo (arg(s)) (\>#column) . . . The simplest form of the ECHO command occurs when it is used to display its arguments on the console screen, as: echo hello world! HELLO WORLD! where the two arguments HELLO and WORLD! were output to the console screen. ECHO also contains a special formatting instruction which may be used to generate columnar output. For example: echo 1 \>5 2 \>10 3 \>15 4 1 2 3 4 where ``\>5'' indicates a tab to column 5, ``\>10'' to column 10, etc. If the actual column number is greater than the one requested, no tab will take place. The tabified format is achieved through the output of the appropriate number of space characters. ECHO terminates each line of output with a CR/LF sequence. If this is not desired, simply place two backslashes after the last character in the last argument, as: echo hello\\; echo \ there! HELLO THERE! where the first ECHO didn't terminate the output line with a CR/LF so that the second could continue from that point. This is most useful for prompting for user input within Command Language programs. ECHO is also useful for outputting strings to memory or system devices. For example, to feed a sheet of paper out of your printer, you can use: echo ^l\\ > :lst which will send a form-feed (CTRL-L) character to the system printer device. 8-8 ConIX Operating System Utility Commands 8.14 ERA: Erase Files era The ERA command is used to erase files stored in the disk directory. Each file which is specified or matched by a pattern (using the `?' and `*' characters) will be removed without confirmation, as in: era foo.asm 10/*.com Only error messages are printed after the invocation of ERA to indicate a bad or non-existent filename or pattern. A returned prompt should be taken as an indication that the requested files were successfully deleted. Users that are left rather uncomfortable by the silence of ERA should use the DEL command instead, which prompts for each individual file to be deleted. 8.15 EXAM: Examine Memory exam <&start> <&end> EXAM is used to examine the contents of system memory. The hex data values in memory from the start to end addresses will be listed to the console screen. The right margin of the listing will contain an ASCII interpretation of the data in memory. If the data at a particular memory location is a printable character (20 hex to 7E hex), it will be printed in ASCII as that character. Otherwise, a `.' will be substituted in its place. If the hi-bit of the character is on, it will be interpreted as if it had been off. The value of the first and last byte printed is saved in the hex variables $$0 and $$1, respectively. 8.16 EXEC: Execute Arguments exec (arg(s)) EXEC takes its arguments and transmits them back into the input command line to be re-parsed. In effect, it's like EXEC types the input once again for you. It is mainly intended for use with the ConIX variables. To illustrate, let's say the variable $A contained the string: dir>dir.out which appears to be a command that would execute the DIR command with its output redirected into the file DIR.OUT. If you were to try and execute the contents of this variable as: 8-9 Utility Commands ConIX Operating System $a DIR>DIR.OUT? you'd get an error, because ConIX does not ``parse'' the characters within the variable, and didn't determine that output redirection was requested. To get this to function properly, use the EXEC command, as: exec $a which would then reparse the contents of the $A variable as its argument into the proper command sequence. If you wanted to execute $A more conveniently, you could set the variable to contain the EXEC command, as: exec dir>dir.out and then you could simply type: $a to execute the command. Note that any arguments to EXEC which were specified in double quotes will remain in double quotes when reparsed. Additionally, EXEC can only reparse up to 128 characters. Excess characters will cause an ``overflow'' message to be printed. 8.17 FILL: Fill Memory with a Constant fill <&start> <&end> <&value> The FILL command is used to fill an area of system memory from the start to end addresses with the specified value. The most common usage is: fill 100 fff 0 which will zero memory so you can see what a program modified in memory after it executes. 8.18 FIND: Find File in Search Path find The FIND command is used to locate a file in the search path. If the given filename contains no disk or user area reference, a search through the path will be performed. Otherwise, FIND will look only in the specified directory. If the file is found, its full disk and user specification, including the filename itself, will be printed to the screen. Bad exit status will be returned 8-10 ConIX Operating System Utility Commands if the file cannot be found. 8.19 FLUSH: Empty the Print Spooler flush The FLUSH command is used to wait until all characters in the spool file have been sent to the printer. This is useful in combination with the OPT -PS command, which is used to turn the spooler off. Use a FLUSH beforehand to make sure that the spooler is not disabled while there are still characters in it that are waiting to be sent to the printer. 8.20 HXPR: Convert Hex to ASCII hxpr (&numlist) HXPR will convert the 8-bit hex numbers given as its arguments into their ASCII equivalents. These characters will be printed to the screen, as in: hxpr 68 65 6C 6C 6F hello where 68 was converted to `h', 65 to `e', and so on. 8.21 IN: Input Data From a Port in <&port> The IN command is used to read and print the value at the specified system machine port, as in: in 20 FF where FF is the hex value read from system port #20 hex, and is saved in the $$0 hex variable. Legal port numbers range from 0 to FF, which is the standard number of ports that the 8080/Z80 processors can address. 8.22 INDEX: Find String index (str2) INDEX is used to search for the occurrence of the string str1 within str2. If found, the character position of the match is stored in $$0, and good exit status is returned. Otherwise, $$0 is set to zero, and INDEX returns bad exit status. For example: 8-11 Utility Commands ConIX Operating System index hello abchellodef xstat 00 bdec $$0 4 This command sequence indicates that the string HELLO was found within the string ABCHELLODEF, starting at the fourth character. Good exit status was also returned. If str2 is omitted, the input stream is searched for a match of str1. Each line which contains str1 within it will be printed to the screen. If a match occurs, $$0 will be set to the character position of the first match, and $$1 to the last. Bad exit status will be returned if no match occurred. For example, index test < file.txt will list each line read from the given input file, FILE.TXT, that contains the character string TEST. 8.23 LOG: Log-In a Drive log (drive(s)) When CP/M is initially booted, all disk drives, except for A:, come up in a ``reset state'', namely CP/M does not yet know of their existence. That's why the first time you type ``B:'' there is a delay while CP/M tries to figure out what kind of a drive it is, and what is stored in the directory. This process is called the Disk Login, and is used mainly to determine the amount of free space that is available for writing onto the disk. From then on, every time the disk directory is accessed, CP/M compares it to what the directory should be. If they differ, then the disk was probably changed, and the drive is set to read only. The LOG command is used to activate the disk login vector. The specified drives are referenced by a single letter (A-P) corresponding to the drive to be logged in. For example: log b will cause drive B: to be logged in. Similarly, log bcd will cause drive B:, C: and D: to be activated. If the drive specification is eliminated, as: log then all drives appearing in the disk search path will be logged in. This is especially useful for conveniently activating your 8-12 ConIX Operating System Utility Commands drives for auto searching after a disk reset. Note that any drives which were already activated will not be logged in again. Any drive which is unlogged must be ready and on-line, since the login process requires a disk to be loaded in the drive. If there is none, the system may hang. If a question mark is given as an argument to LOG, a single letter corresponding to each currently logged-in disk will be printed to the screen. For example: log ? AB indicates that drives A: and B: are currently activated. 8.24 MOVE: Copy Memory move <&start> <&end> <&new> MOVE will move or copy memory from one region to another. The block to be copied is specified by the start and end addresses. The location to which it is to be copied is specified as new. The amount of memory which will be changed is determined by the size of the source block. 8.25 OPT: Enter ConIX Options opt +/-/?