How MS-DOS 6.22 TYPE Displays Binary Files

The MS-DOS 6.22 TYPE command is an internal shell command designed strictly to display the contents of plain ASCII text files on the screen. When executed against non-text binary files—such as executables (.EXE, .COM), compressed archives (.ZIP), or raw disk images—it does not parse file structures, reject the file, or translate the data into hexadecimal format. Instead, it reads the raw binary stream and pipes it directly to the console, resulting in character mapping, system beeps, screen displacement, and abrupt stops caused by legacy end-of-file markers.

Raw Byte-to-Screen Mapping

The TYPE command reads the target file byte-by-byte into a memory buffer and outputs it through standard DOS input/output interrupts (specifically INT 21h functions). Because the command makes no distinction between text and arbitrary data, the video subsystem interprets every 8-bit byte according to the active hardware code page, which defaults to Code Page 437 in standard US English installations.

  • Printable Characters (Bytes 32–126): These bytes represent standard alphanumeric characters and basic punctuation, displaying normally as readable text.
  • Extended ASCII (Bytes 128–255): In Code Page 437, these values map to graphical symbols, mathematical notations, accented glyphs, and box-drawing elements. On the screen, this appears as an unreadable scramble of lines, blocks, and foreign characters often referred to as "garbage."

Execution of Control Codes

Bytes ranging from 0 to 31 are reserved in the ASCII standard as control characters. Rather than printing a glyph, the console driver executes the instruction tied to that character:

  • Byte 7 (BEL): Triggers the PC speaker, causing the computer to beep repeatedly as the file streams past.
  • Byte 8 (BS): Moves the cursor back one position, overwriting previous characters.
  • Byte 9 (HT): Advances the cursor to the next horizontal tab stop.
  • Byte 10 (LF) and Byte 13 (CR): Advance the display to a new line and return the cursor to the left margin, frequently causing chaotic indentation when received out of sequence.
  • Byte 12 (FF): Interpreted as a form feed, which can clear the screen or cause rapid scrolling.

Premature Termination with EOF (Byte 26 / 0x1A)

One of the most defining behaviors of the TYPE command in MS-DOS 6.22 is how it handles the ASCII End-of-File (EOF) character, represented in hexadecimal as 0x1A (decimal 26, or Ctrl+Z).

Inherited from the CP/M operating system, MS-DOS text utilities rely on 0x1A to signal the conclusion of text data. Even if a binary file is hundreds of kilobytes in size, TYPE will immediately stop processing and return to the command prompt the moment it encounters the first 0x1A byte. As a result, running TYPE on a large binary file often prints only a few unintelligible characters before halting prematurely.

Terminal Corruption via ANSI.SYS

If the system configuration file (CONFIG.SYS) includes the ANSI.SYS device driver, displaying a binary file can alter the terminal environment. Any byte sequences within the binary stream that inadvertently match the ANSI escape prefix (ASCII 27 followed by [) will be processed as display commands. This can unintentionally remap keyboard inputs, alter foreground and background text colors, hide the cursor, or reposition text output to arbitrary screen coordinates until the console is reset.