
   THE DOS ENVIRONMENT BLOCK
 
   When the *initial* copy of COMMAND.COM is loaded at boot time, it creates a
   block of memory that will contain the master or global DOS environment. The
   environment of DOS consists of a number of text string variables maintained
   by COMMAND.COM, each variable consisting of a name and an associated string
   having the form
 
                             VARIABLE=string of characters
    
   in which the end of the string is indicated by a zero byte (ASCIIz string).
   The environment usually contains a series of such variables, and the end of
   the environment is indicated by an additional zero byte.  The variables are
   used to pass information to and from the DOS shell COMMAND.COM, batch files
   and, sometimes, application programs.
 
   Variables can be added to the DOS environment via the SET command.  Some of
   these variables, however, are added without user intervention; for example,
   after a hard-disk booting without an AUTOEXEC.BAT file, the DOS environment 
   contains the following two variables:
 
                             PATH=
                             COMSPEC=C:\COMMAND.COM
 
   The variable PATH= tells COMMAND.COM which directories to search for files,
   whereas the variable COMSPEC= tells COMMAND.COM from where to reload itself
   to replace its transient portion located in high RAM.  In addition to these
   variables, other ones (such as PROMPT=) may be present; the contents of the
   environment can be inspected by entering 'SET' from the DOS prompt line.
 
 

   GLOBAL vs. LOCAL ENVIRONMENT
 
   Each program loaded by COMMAND.COM, including any secondary copy of itself,
   such as when running a batch file from another with the instruction:
 
                          [d:][\path]command /C xxxx.BAT
 
   inherits from the 'parent' a static copy of its environment block. Be aware
   that the contents of the DOS environment of the 'child' are not transferred
   or copied to the environment of the 'parent,' and that there is little room
   in the inherited environment for addition or modification of variables.
 
   In setting up an environment variable for the software, especially when the
   variable is being modified (rather than created), you should make sure that
   the modification takes place in the global environment of DOS, and not of a
   secondary command-processor copy, if you wish to preserve the modification.
   Alternatively, running a batch file via a secondary copy of COMMAND.COM is
   an excellent manner to use temporary variables or modifications that do not
   need to be restored or removed at the end of the file.  Notice that the DOS
   3.2+ command CALL, which can also be used to run a batch file from another,
   preserves the environment of the 'child' batch file upon termination of the
   'parent' file.

   Whereas the SET command modifies the current DOS environment block (whether
   it is the global or a local one), switch /E only modifies the global block,
   even when it is issued under a secondary copy of COMMAND.COM (in which case
   the local environment is not changed).  /E access to the global environment
   requires use of an undocumented DOS function (52h) which has been found not
   to work in some buggy DOS 4.00 versions (but works in versions 2.10 through
   3.31 and 4.01).
 
 
 
   ENVIRONMENT SIZE
 
   Depending on the DOS version, the environment's size may be up to 32 kbytes
   (i.e. 32,768 decimal bytes) long.  The default environment size of COMMAND.
   COM, however, is of 160 bytes in versions 2.2x through 3.3x; this space can
   fill up quickly, in which case DOS displays the message 'Out of environment
   space' when attempting to add a new variable or increasing an existing one.
 
   In DOS versions 3.10 and later, the size of the environment can be modified
   by including the following statement in the CONFIG.SYS file:
 
                      SHELL=[d:][\path]COMMAND.COM /P /E:nn
 
   in which [d:] and [\path] are the drive and path specification, P indicates
   that this is to be considered the initial loading of the command processor,
   and /E:nn specifies the size of the environment in <nn> bytes (versions 3.2
   and higher) or <nn> paragraphs (1 paragraph=16 bytes, version 3.1).  Notice
   that version 3.1 allows a maximum environment of 992 bytes (62 paragraphs).
 
   For DOS versions 2.0 up to 3.0, however, the size of the environment can be
   changed only by patching 1 or 2 bytes in the COMMAND.COM file. (This may be
   done by using DEBUG as discussed below.)
 
 ------------------------------------------------------------------------------


   MODIFICATION OF ENVIRONMENT SIZE (DOS 2.X - 3.0)

   The following DEBUG commands describe the patching of COMMAND.COM in MS-DOS
   and IBM-PC-DOS versions 2.00 through 3.00, located in a diskette mounted in
   drive A:

   1. Load: 'DEBUG A:\COMMAND.COM'

   2. Search for the code which sets size: 's 100 L 5600 BB 0A 00 B4 48 CD 21'
      This code disassembles to:
                                    MOV  BX,000A   ;environment in paragraphs
                                    MOV  AH,48     ;fn. allocate memory block
                                    INT  21        ;DOS services interrupt

   3. DEBUG will then display this code address, which will be 'xxxx:0ECE' for
      MS-DOS versions 2.0 and 2.1, and 'xxxx:0F20' for version 3.0; 'xxxx' may
      be any hexadecimal number.  (If you obtain a different address, use that
      one instead.)

   4. Add 1 to this address to get the address of two bytes that determine the
      environment size (0+1=1...8+1=9, 9+1=A, A+1=B...E+1=F, F+1=10 etc), i.e.
      the '0A 00' in item 2.  These two bytes represent the hexadecimal number
      '000A' (corresponding to the decimal number '0010'), which specifies the
      size of the environment in paragraphs (blocks of 16 bytes). Thus, 10x16=
      160 bytes, which is the default size.

        NOTE: The bytes of this hexadecimal number are reversed in order, with
              the least significant byte ('0A') listed first, and the most one
              ('00') listed second. This is due to the way the "little-endian"
              microprocessors used by PC and PC-compatible machines store data
              in memory.

      To modify the environment size change this number to a hexadecimal digit
      between 000B (16x11=176 decimal bytes) and 0800 (16x2,048=32,768 decimal
      bytes) that should also be stored in memory in reversed byte order. This
      range can be entered with the DEBUG commands:

                   'e 0ECF 0B 00' through 'e 0ECF 08 00' for DOS 2.x
      or                   ~~ ~~                  ~~ ~~
                   'e 0F21 0B 00' through 'e 0F21 08 00' for DOS 3.0
                           ~~ ~~                  ~~ ~~

      After patching, write the patch to the COMMAND.COM copy with the command
      'W' and exit DEBUG with the command 'Q'.  The patching should be carried
      out in a copy of COMMAND.COM in a bootable disk(ette) different from the
      copy used to boot the machine.

   5. To see is the patch was successful, reboot with the diskette in drive A,
      and test the modified command intepreter.

      (When you are satisfied that the patch was successful, copy the modified
      COMMAND.COM to the booting disk, *after* saving the original COMMAND.COM
      in a separate diskette in case of conflicts.)

 ------------------------------------------------------------------------------
 [END]
