You are on page 1of 19

Systems Programming

Assembler
Compiler Vs Assembly
What is an assembler?

• An assembler is a type of computer program that takes in


basic instructions and converts them into a pattern of bits that the
computer's processor can use to perform basic operations. The
assembler's job is to convert assembler or assembly language code
into machine code that the computer can then read and execute.
Object code

Object code is the machine-readable code


that is generated by the compiler, and it
serves as an intermediate step between the
source code and the final executable code.
Object code files are specific to the target
architecture and operating system and are
typically stored in a binary file format.
Types of assemblers

1. One-Pass Assembler
• These assemblers perform the whole conversion of assembly code to
machine code in one go.
• Symbol table and opcode tables are defined.
• keep the record of the location counter.
• Also, processes the pseudo instructions.
Types of assemblers
2. Multi-Pass/Two-Pass Assembler
• These assemblers first process the assembly code and store values in
the opcode table and symbol table. And then in the second step, they
generate the machine code using these tables.
• Finally, converts the opcode into the corresponding numeric opcode.
• Generates machine code according to values of literals and symbols.
Some Important Terms
• Opcode table: They store the value of mnemonics (The symbolic
representation of the opcode (machine level instruction) is
called mnemonics) and their corresponding numeric values.
• Symbol table: They store the value of programming language
symbols used by the programmer, and their corresponding numeric
values.
• Location Counter: It stores the address of the location where the
current instruction will be stored.
Two pass assembler process
Two pass assembler process
Pass 1
Pass 1
Pass 1
Pass 1
Pass 1
Pass 1
How to generate
object code?
Example-2

You might also like