Enhancing PC-DOS (PC Magazine Vol 3 No 14 July 24, 1984 by G. Weissman) NOTE: This doesn't work with DOS 2.1; try it with DOS 2.0 someday. The DOS SET command lets you create a list of text symbols (or variables) called the "environment," which is held in a reserved portion of memory. These symbols can represent longer commands or path names. The variables and their definitions listed in the environment can be interpreted by any program that was designed with this feature in mind. DOS 2.0 documentation includes instructions that can be used to locate the environment. Little use is made of the environment's capability in DOS 2.0 itself except for three symbols that control system characteristics: COMSPEC for the name of the command interpreter; PATH for the list of directories where executable files can be found; and PROMPT for the current definition of the system prompt. To make better use of the environment, you must make changes to the DOS command interpreter, the link between a user and the operating system. Usually COMMAND.COM is the program used as the command interpreter, so much so that COMMAND.COM's own commands (such as COPY, TYPE and DIR) are all that users know. You send commands from batch files or the keyboard to the command interpreter, and it responds by loading and starting other programs or performing tasks such as renaming or deleting files. There were three parts to the modification: modify the COMMAND.COM file to give it extra space, which you must do; finding where the input lines are analyzed by COMMAND.COM; and inserting new code into COMMAND.COM that intercepts the analysis process to substitute symbol values for symbol names. (Only the first and third procedures are necessary here.) The substitution of symbol values for names using the SET command is a powerful tool. Assume you have two file directories: TAXES\DATA\MARCH\EXPNS, and BUDGET\REPORTS\MARCH\TAXES. If you must refer to different files within these two directories, you can use the environment feature to reduce the keystrokes in these names by initially typing: SET D1=\TAXES\DATA\MARCH\EXPNS\ and SET D2=\BUDGET\REPORTS\MARCH\TAXES\. Then you can type 'D1' and 'D2' (including the single-quotation marks) as part of any DOS command and get the same results as if you'd typed the directory names in full. DOS will continue to interpret these abbreviations until you turn off the computer or enter SET D1= to erase the symbol assignment. This procedure is like using variables that represent values rather than the values themselves in a BASIC program. (Without this capability, BASIC would be useless as a programming language.) This modification of the environment permits you to distinguish between characters in a DOS command that are symbols and those that are to be interpreted normally. A symbol name must be inside single quotation marks which is a good character for this purpose -- it has no reserved meaning in DOS, it rarely appears in file names, and it's easy to type. (The remainder of this article describes how the initialization process works after COMMAND.COM is loaded into RAM by DOS. The next article describes the rest of the process.) ----------------------------------------------------------------- Get SET for Speed (from PC Magazine Vol 3 No 15 August 7, 1984 by G. Weissman) The first step is to add 1,024 bytes to the COMMAND.COM program to insert modified code. These 1,024 bytes are more than enough for the changes in this article, so you can use the rest to add improvements of your own. Using a copy of COMMAND.COM, run DEBUG and use the ASSEMBLE command to expand COMMAND.COM: - A 1ED xxxx:01ED ADD DX,3270 xxxx:01F1 [Enter] - A 3AD xxxx:03AD CMP BX,3B0 xxxx:03B1 [Enter] - A 3CD xxxx:03CD SUB BX,390 xxxx:03D1 [Enter] - A 691 xxxx:0691 MOV CX,37BE xxxx::0694 [Enter] - A 6A9 xxxx:06A9 CMP CX,37BE xxxx:06AD [Enter] - A C9D xxxx:0C9D SUB AX,390 xxxx:0CA0 [Enter] - A 140B xxxx:140B CALL 4030 xxxx:140E [Enter] - M 4030 4580 4430 - F 4030 442F 0 - R CX CX 4500 :4900 - N COMMAND.TMP - W writing 4900 bytes - Q You created COMMAND.TMP, a version of COMMAND.COM with space between its data work area and the EXEC handler. The next step is to create a subroutine for symbol substitution via the command processor's environment table. This subroutine will be located at offset 4030 h in the COMMAND.COM file. Run DEBUG on COMMAND.TMP and enter the following: -A 4030 xxxx:4030 MOV SI,2B8B xxxx:4033 MOV BX,3000 xxxx:4036 XOR DX,DX xxxx:4038 MOV ES,[2CA0] xxxx:403C ES: xxxx:403D MOV ES,[0B1C] xxxx:4041 LODSB xxxx:4042 CMP AL,27 xxxx:4044 JZ 4065 xxxx:4046 MOV [BX],AL xxxx:4048 INC BX xxxx:4049 CMP AL,0D xxxx:404B JNZ 4041 xxxx:404D PUSH CS xxxx:404E POP ES xxxx:404F MOV CX,0886 xxxx:4052 OR DX,DX xxxx:4054 JZ 4063 xxxx:4056 MOV SI,3000 xxxx:4059 MOV DI,2B8B xxxx:405C MOVSB xxxx:405D CMP BY [DI-01],0D xxxx:4061 JNZ 405C xxxx:4063 JMP CX xxxx:4065 MOV DX,SI xxxx:4067 MOV DI,0001 xxxx:406A DEC DI xxxx:406B MOV SI,DX xxxx:406D LODSB xxxx:406E CMP AL,0D xxxx:4070 JZ 4046 xxxx:4072 CMP AL,27 xxxx:4074 JNZ 4088 xxxx:4076 MOV AL,3D xxxx:4078 SCASB xxxx:4079 JNZ 4095 xxxx:407B ES: xxxx:407C MOV AL,[DI] xxxx:407E OR AL,AL xxxx:4080 JZ 4041 xxxx:4082 MOV [BX],AL xxxx:4084 INC BX xxxx:4085 INC DI xxxx:4086 JMP 407B xxxx:4088 CMP AL,61 xxxx:408A JB 4092 xxxx:408C CMP AL,7A xxxx:408E JA 4092 xxxx:4090 AND AL,5F xxxx:4092 SCASB xxxx:4093 JZ 406D xxxx:4095 DEC SI xxxx:4096 XOR CX,CX xxxx:4098 MOV AL,CL xxxx:409A DEC CX xxxx:409B REPNZ xxxx:409C SCASB xxxx:409D SCASB xxxx:409E JNZ 406A xxxx:40A0 LODSB xxxx:40A1 CMP AL,27 xxxx:40A3 JZ 4041 xxxx:40A5 CMP AL,0D xxxx:40A7 JZ 4046 xxxx:40A9 JMP 40A0 xxxx:40AC [Enter] - W writing 4900 bytes - Q The final step is to copy the modified command processor over the old COMMAND.COM. Enter: A>COPY COMMAND.TMP COMMAND.COM Reboot the system, loading the new version of COMMAND.COM, and see if everything operates normally. After you make sure your modifications have done no harm, you can test it by entering the command: A>DIR 'COMSPEC' The display should say, "COMMAND.COM 18688" followed by the date and time. Now enter: A>SET X=Hello. This is proof that the substitution works. After that, enter: A>ECHO 'X' and the screen should display the message, "Hello. This is ..."