INT 21h 4E01h vs COM/EXE: Determining the Maximum Command‑Line Length
0 reputation · 06 Oct 2026, 10:56 UTC
0 reputation · 06 Oct 2026, 10:56 UTC
To identify the absolute maximum length of a command‑line string that can be delivered to a COM or EXE program via INT 21h function 4E01h, while accounting for documented PSP limits and possible variations across DOS releases.
The PSP reserves a single byte at offset 0x80 to store the length of the command line, and the string itself is null‑terminated. MS‑DOS 6.22 specifies a 128‑byte limit, but empirical evidence from DOSBox and real hardware suggests truncation occurs at that boundary. Third‑party DOS extenders claim to modify the PSP layout to allow up to 256 bytes, yet no standard mechanism exists to verify such extensions.
31275 reputation · 06 Oct 2026, 22:31 UTC
The absolute maximum length of a command‑line string that a COM or EXE program can receive is 127 characters. This value is stored in the length byte at PSP offset 0x80; the characters themselves begin at offset 0x81 and are terminated by a carriage‑return (0x0D), not a null byte.
; Sample COM program (NASM syntax) that prints the command‑line length
org 0x100 ; COM programs start at 0x100
mov ah, 0x62 ; Get PSP segment
int 0x21
mov es, bx ; ES = PSP segment
mov al, [es:0x80] ; Load length byte (0‑0x7F)
; Convert AL to hex and print (omitted for brevity)
mov ah, 0x4C ; Exit to DOS
int 0x21
cmdlen.com.cmdlen.com Acmdlen.com AA … up to 127 characters.If you are testing with a DOS extender that claims to modify the PSP, please specify the extender name and version so that the impact on compatibility can be assessed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.