Skip to main content

COM vs EXE; assembling, linking, executing

Short answer

.COM programs are limited to 64 KB, have a single segment, use ORG 100H, and no header; DOS sets the stack/DS. .EXE programs can be larger, contain multiple segments, a header with relocation info; the programmer must load DS and set up the stack. The build flow: edit .ASM, assemble to .OBJ, link to .EXE, optionally convert to .COM with EXE2BIN, then execute.

How are .COM and .EXE programs different? Explain assembling, linking and executing process.

Difference between .COM and .EXE

Point.COM.EXE
SizeMax 64 KB, one segmentCan exceed 64 KB, many segments
FormatBinary image with no headerHeader with relocation table
StartORG 100H requiredNo ORG
Stack/DSDOS sets themProgrammer defines stack and loads DS

Assembling, linking and executing

 PROG.ASM --MASM--> PROG.OBJ --LINK--> PROG.EXE --EXE2BIN--> PROG.COM
                                                  (optional, for COM)
  1. Edit: write the source program with an editor and save it as PROG.ASM.
  2. Assemble: MASM PROG; The assembler checks the syntax and converts the source to a relocatable object file PROG.OBJ (optionally also the listing .LST and cross-reference .CRF). Syntax errors are reported here and must be corrected.
  3. Link: LINK PROG; The linker combines one or more object files and libraries, resolves external references, assigns final segment addresses and produces PROG.EXE (and a .MAP file).
  4. Convert (optional): for a COM program, EXE2BIN PROG PROG.COM.
  5. Execute: type PROG at the DOS prompt. The loader reads the file, creates a PSP, loads the program into memory, relocates its segment references (for .EXE) and transfers control to the entry point.
  6. Debug: DEBUG PROG.EXE (or TD) lets the programmer trace the program and view registers, flags and memory.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 3 questions →