MS-DOS 6.22 FC Command File Comparison Guide

The FC (File Compare) command in MS-DOS 6.22 is a command-line utility used to compare two files or sets of files and display the differences between them. This article explains how the utility operates, detailing its internal mechanics during text and binary comparisons, key switches that modify its behavior, and how it handles mismatched data.

Primary Comparison Modes

The FC command functions using two distinct operational modes: ASCII (text) mode and Binary mode. MS-DOS 6.22 determines the mode automatically based on the file extensions provided, or manually via specific command switches.

1. ASCII Text Comparison

By default, MS-DOS 6.22 treats files without executable or object extensions as ASCII text files. During a text comparison, the utility reads both files line by line into an internal buffer memory.

When a difference between the two files is encountered, FC performs the following steps:

  • It identifies the mismatch point and outputs the differing lines from the first file.
  • It outputs the corresponding differing lines from the second file.
  • It attempts to resynchronize the two files by searching forward for a set of consecutive lines that match in both files. By default, it requires two consecutive matching lines to consider the files resynchronized.
  • If the search buffer exceeds its limit (default is 100 lines) without finding a match, the comparison terminates with the message: "Resynch failed. Files are too different."

2. Binary Comparison

When invoked with the /B switch—or when comparing files with extensions such as .EXE, .COM, .SYS, .OBJ, .BIN, or .LIB—FC performs an exact byte-by-byte comparison.

Unlike ASCII mode, binary mode:

  • Does not attempt to resynchronize after finding differences.
  • Evaluates corresponding memory offsets from the beginning of both files.
  • Outputs differences in a specific hexadecimal format: XXXXXXXX: YY ZZ, where XXXXXXXX is the byte offset from the start of the file, YY is the hex value from the first file, and ZZ is the hex value from the second file.
  • Reports if one file is longer than the other after reaching the end of the shorter file.

Key Configuration Switches

MS-DOS 6.22 allows users to fine-tune how comparisons are evaluated through several switches:

  • /L: Forces an ASCII text comparison, even on files normally recognized as binary.
  • /B: Forces a binary byte-by-byte comparison on any file type.
  • /C: Ignores character case during ASCII comparison (treats uppercase and lowercase as identical).
  • /N: Displays line numbers alongside differences during an ASCII comparison.
  • /W: Compresses tabs and consecutive spaces into a single space, and ignores whitespace at the beginning and end of lines.
  • /T: Prevents FC from expanding tabs into spaces.
  • /LBn: Sets the internal line buffer size to n lines (default is 100) before declaring a resynchronization failure.
  • /n: Specifies the number of consecutive lines that must match to re-establish synchronization following a mismatch (default is 2).

Exit Codes (Errorlevels)

Upon completion, FC returns an exit code (accessible via ERRORLEVEL in batch scripts):

  • 0: The files are identical.
  • 1: Differences were found between the files.
  • 2: At least one file could not be found, or invalid command-line parameters were provided.