---
title: "COM vs EXE; assembling, linking, executing"
subject: "Microprocessor"
chapter: 3
key: "semester_4/microprocessor:com-exe-assembling-linking"
source: https://www.bctengineer.com/q/semester_4/microprocessor/com-exe-assembling-linking
site: BCT Engineering
---

# COM vs EXE; assembling, linking, executing

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2068 Magh, 3+5 marks
- Video: [Assembler, Linker, Loader of Microprocessor - 8086 Microprocessor - MPMC](https://www.youtube.com/watch?v=-CXRTSWBqLI) — Padmasri Naban
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/com-exe-assembling-linking
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

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

## 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.

## Answer

#### Difference between .COM and .EXE
| Point | .COM | .EXE |
|---|---|---|
| Size | Max 64 KB, one segment | Can exceed 64 KB, many segments |
| Format | Binary image with no header | Header with relocation table |
| Start | `ORG 100H` required | No ORG |
| Stack/DS | DOS sets them | Programmer defines stack and loads DS |

#### Assembling, linking and executing
```text
 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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does MASM PROG; produce?
   A. PROG.EXE
   B. Relocatable object file PROG.OBJ
   C. PROG.COM
   D. A memory map only
   Answer: B. The assembler checks syntax and creates PROG.OBJ (optionally .LST and .CRF). (Key point: Assemble step)

2. What does LINK do?
   A. Combines object files and libraries, resolves externals and produces .EXE
   B. Checks syntax
   C. Loads into memory
   D. Traces the program
   Answer: A. The linker resolves external references and assigns final segment addresses. (Key point: Linker)

3. How is a .COM file produced?
   A. EXE2BIN after LINK
   B. MASM directly
   C. DEBUG
   D. Editing the .OBJ
   Answer: A. EXE2BIN converts the EXE to COM. (Key point: COM creation)

4. What does the loader do on execution?
   A. Creates a PSP, relocates segment references, loads and transfers control to the entry point
   B. Assembles the file
   C. Links libraries
   D. Writes the .MAP file
   Answer: A. Loading creates the PSP and applies relocation before control transfer. (Key point: Loader)

## Related in Microprocessor

- [EXE and COM programs](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aexe-vs-com-programs) — Microprocessor, chapter 3, asked 2×

## Related in other subjects

- [Compilation, linking and loading process](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acompile-link-load-process) — Computer Programming, chapter 1
