ASSEMBLY, LINKING AND LOADING
Question: Write short notes on Assembly, Linking and Loading.) (10 Marks)
1. INTRODUCTION
Assembly and linking are the last steps in the compilation process — they turn a list of
instructions into an image of the program's bits in memory.
Loading actually puts the program in memory so that it can be executed.
Most compilers create the instruction-level program in the form of human-readable
assembly language.
📌 (Draw the diagram — "Program generation from compilation through loading" — as
shown in the book)
2. ASSEMBLY
The assembler's job is to translate symbolic assembly language into object code (bit-level
representations).
The assembler handles instruction formats and translates labels into addresses.
The simplest form uses absolute addresses — the starting address is specified by the
programmer.
Label Processing — Two Pass Assembler:
First Pass:
Scans the code to find the address of each label.
Stores label name and address in a symbol table.
Uses a Program Location Counter (PLC) to track current memory location.
Second Pass:
Looks up each label in the symbol table and substitutes its value into the instruction.
📌 (Draw the diagram — "Symbol table processing during assembly" — as shown in the
book)
ORG Statement:
ORG 2000 sets the PLC to 2000 — placing the start of the program at location 2000.
3. LINKING
A linker stitches together several smaller object files into one executable.
The linker operates on object files created by the assembler.
Key Terms:
Entry Point — the place in the file where a label is defined.
External Reference — the place where the label is used.
The linker's main job is to resolve external references based on available entry points.
📌 (Draw the diagram — "External references and entry points" — as shown in the book)
Two Phases of Linker:
Phase 1 — Determines the starting address of each object file using a load map.
Phase 2 — Merges all symbol tables and changes relative addresses into actual addresses. If
a label is not found, an error message is sent.
4. LOADING
The loader brings the program into memory for execution.
Loading is the final step — it places the executable binary into the correct memory locations
so the CPU can begin execution.
SUMMARY
Step Tool Function
Assembly Assembler Assembly language → Object code
Linking Linker Object files → Executable binary
Loading Loader Places program into memory