Assembler, Linker, Loader
Assembler, Linker, Loader
Assembler, Linker, Loader
Andrew Tanenbaum
Structured Computer Organization
(c) 2006 Pearson Education, Inc.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Running Programs
Steps that the computer goes through to run a
program:
Memory
Machine language
program
(executable file)
Input Data
Data entered
during execution
CPU
Computed results
Program Output
Program Execution
Steps taken by the CPU to run a program
(instructions are in machine language):
1. Fetch an instruction
2. Decode (interpret) the instruction
3. Retrieve data, if needed
4. Execute (perform) actual processing
5. Store the results, if needed
Program Errors
a) Syntax Errors:
a) Runtime error:
Divide by zero
Invalid input data
a) Logical errors:
Computer Languages
Machine Language
Assembly Language
Uses mnemonics
Machine-dependent
Not usually portable
Machine Language
a)
a)
Instructions:
Example:
Operation
Address
0010
0100
0011
Assembly Language
a)
b)
c)
d)
e)
f)
Price
Tax
Cost
High-level language
A programming language which uses statements
consisting of English-like keywords such as "FOR",
"PRINT" or IF, ... etc.
Each statement corresponds to several machine
language instructions (one-to-many correspondence).
Much easier to program than in assembly language.
Data are referenced using descriptive names
Operations can be described using familiar symbols
Example:
Cost := Price + Tax
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Compilation
Source
Program
Input
a)
b)
c)
d)
Compiler
Target Program
Target
Program
Output
Assembly
Language
Compiler
Assembly
Language
Assembler
Machine
Language
Executable program
Output from linker/loader
Machine language program linked with necessary libraries
& other files
Files usually have extension .exe or '.out'
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
What is a Linker?
a) A program that pulls other programs together
so that they can run.
b) Most programs are very large and consist of
several modules.
c) Even small programs use existing code
provided by the programming environment
called libraries.
d) The linker pulls everything together, makes
sure that references to other parts of the
program (code) are resolved.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education
Role of Loader
Source
Program
Assembler
Object
Program
Loader
Object
program
ready for
execution
Memory
Source
Program
Assembler
Object
Program
Linker
Executable
Code
Loader
Object
program
ready for
execution