MS-DOS 6.22 Long Command Line Processing
MS-DOS 6.22 enforces strict character boundaries on command-line
inputs, dictated by the internal design of COMMAND.COM and
the structure of the Program Segment Prefix (PSP). When an entered
command, batch file instruction, or argument list exceeds these
thresholds, the operating system does not dynamically allocate extra
memory; instead, it relies on hardware beeps, silent truncation, and
syntax errors. This article explains the technical mechanics behind how
MS-DOS 6.22 handles inputs that breach standard character limits.
The 127-Character Architecture Limit
The primary constraint on command-line length in MS-DOS 6.22 is the
Program Segment Prefix (PSP), a 256-byte data structure prepared for
every executable program loaded into memory. Offset 80h of
the PSP acts as the unformatted command tail:
- Offset 80h: A single byte indicating the length of the command-line parameters (0–127).
- Offset 81h to FFh: Up to 127 bytes holding the
parameter characters, terminated by a carriage return
(
0Dh).
Because the default Disk Transfer Area (DTA) overlaps this region and
COM files begin code execution immediately at offset 100h,
any command parameter string longer than 127 characters cannot fit
without corrupting program memory. Consequently, MS-DOS limits any
external command tail to a maximum of 127 characters (or 128 characters
including the terminating carriage return).
Interactive Shell Input Processing
When a user types directly into the COMMAND.COM prompt,
the input is managed via MS-DOS interrupt
INT 21h, Function 0Ah (Buffered Input) or internal keyboard
handling routines.
- Buffer Saturation: The keyboard input buffer is configured with a maximum capacity of 128 bytes.
- Audio Feedback: As the user types, characters are stored sequentially. Once the 127th character is entered, the input handler stops reading further keypresses.
- Rejection: Any additional keystrokes trigger an
audible alert (ASCII
07hbell) via the PC speaker, and the additional characters are discarded entirely from the keyboard buffer. The user must press Backspace to edit before they can submit the command with the Enter key.
Batch File and Environment Variable Expansion
Batch processing bypasses the interactive keyboard buffer but encounters the same underlying length limits during execution.
When COMMAND.COM reads a batch file line, it expands
environment variables (e.g., %PATH% or custom variables).
If the resulting expanded line exceeds 127 characters:
- Truncation:
COMMAND.COMsilently chops the line at the 127-character mark. - Malformed Commands: The remainder of the line past character 127 is dropped completely. If an argument, file path, or closing quote falls past this cutoff, the command executes in a partially truncated state.
- Resulting Errors: The system typically emits
runtime errors such as
Bad command or file name,Syntax error, orFile not foundbecause trailing switches and parameters are missing.
Passing
Arguments via EXEC (INT 21h, Function 4Bh)
When an application or shell invokes another program using MS-DOS
EXEC (INT 21h, Function 4Bh), the caller must provide a
parameter block pointing to the command-line tail.
If the calling program attempts to write more than 127 bytes into the command tail buffer:
- MS-DOS only copies up to the length byte specified, capped by the
limits of the target PSP at offset
80h. - Characters beyond byte 127 overflow into the program's code space
(in the case of
.COMfiles) or corrupt memory allocations, typically resulting in an immediate application crash, illegal instruction trap, or system lockup.
Workarounds for Exceeded Limits
Because MS-DOS 6.22 cannot process extended strings natively, third-party software and development tools developed distinct methods to bypass the 127-character barrier:
- Response Files: Compilers and linkers accept an
@filenameargument on the command line. The program reads its full argument list directly from the designated text file, bypassing the PSP command tail entirely. - Environment Variables: Applications read broad
configuration data directly from the DOS environment segment, which can
be configured via
CONFIG.SYS(SHELL=COMMAND.COM /E:xxxx) to hold up to 32,768 bytes. - Alternative Shells: Replacement command interpreters, such as 4DOS, altered command processing to support input buffers up to 255 or 512 characters for internal commands, though calls to legacy DOS executables remained bound by the 127-character PSP constraint.