- 2068 Magh · 3+5 marks
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 |
|---|---|---|
| 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
PROG.ASM --MASM--> PROG.OBJ --LINK--> PROG.EXE --EXE2BIN--> PROG.COM
(optional, for COM)
- Edit: write the source program with an editor and save it as
PROG.ASM. - Assemble:
MASM PROG;The assembler checks the syntax and converts the source to a relocatable object filePROG.OBJ(optionally also the listing.LSTand cross-reference.CRF). Syntax errors are reported here and must be corrected. - Link:
LINK PROG;The linker combines one or more object files and libraries, resolves external references, assigns final segment addresses and producesPROG.EXE(and a.MAPfile). - Convert (optional): for a COM program,
EXE2BIN PROG PROG.COM. - Execute: type
PROGat 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. - Debug:
DEBUG PROG.EXE(orTD) lets the programmer trace the program and view registers, flags and memory.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- EXE and COM programs · Microprocessor, chapter 3 · asked 2×
- Compilation, linking and loading process · Computer Programming, chapter 1