Design of 2-Pass Assemblers

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Design of 2-Pass Assemblers

Agenda

Introduction
Advanced Assembler Directives
ORIGIN
EQU
LT ORG
Pass I of the Assembler
Data Structure used in Pass I

Algorithm
Intermediate code
Declaration and Assembler Directive Processing
Pass II of the Assembler

OPTAB
SYMTAB
LITTAB
POOLTAB

Introduction
Source
Program

Assembler

Object
Code

Linker

Executable
Code

Loader

Introduction

Convert mnemonic operation codes to thei


r machine language equivalents
Convert symbolic operands to their equiva
lent machine addresses
Build the machine instructions in the prop
er format
Convert the data constants to internal mac
hine representations
Write the object program and the assembl
y listing

Two Pass Assembler

Read from input line

LABEL, OPCODE, OPERAND

Source
program

Intermediate
file

Pass 1
OPTAB

SYMTAB

Pass 2
SYMTAB

Object
codes

Introduction: Design of 2 - Pass Assembler

Pass 1

Separate the Symbol, Mnemonic opcode and operand fi


elds
Build the symbol table
Perform LC Processing
Construct Intermediate Representation

Pass 2

Synthesize the target program

Advanced Assembler Directives

ORIGIN
EQU

Advanced Assembler Directives

ORIGIN
EQU
Syntax:
ORIGIN < Address Specification>

Advanced Assembler Directives

ORIGIN
EQU
Syntax:
<Symbol> EQU <Address Specification>

E.g. MAXLEN EQU 4096

Pass I of Assembler

Pass I Uses following Data Structures


OPTAB
SYMTAB
LITTAB
POOLTAB

Pass I of Assembler

Pass I Uses following Data Structures


OPTAB : A Table of Mnemonics & related info
SYMTAB
LITTAB
POOLTAB

Pass I of Assembler

Pass I Uses following Data Structures


OPTAB
SYMTAB: Symbol Table
LITTAB
POOLTAB

Pass I of Assembler

Pass I Uses following Data Structures


OPTAB
SYMTAB
LITTAB: Table of Literals used in program
POOLTAB

Pass I of Assembler

Pass I Uses following Data Structures


OPTAB
SYMTAB
LITTAB
POOLTAB: A table of information concerning lit
eral pool

Algorithm

Algorithm

You might also like