Assembler
Assembler
Assembler
Assembly Language
An Assembly language is the lowest level
programming language for a computer and
machine dependent .
Assembly language provides the following
three basic features which make
programming a lot easier than in machine
language.
1. Mnemonic Operation Codes.
2. Symbolic Operand Specification.
3. Declaration of data/storage area:
Assembly Language
1.Mnemonic Operation Codes.
Instead of using numeric opcodes (i.e. pattern of 0
& 1), mnemonics are used e.g. ADD, SUB etc.
2. Symbolic Operand Specification.
Symbolic names can be associated with data or
instructions . Operands can be specified in the
form of symbolic references, rather than as
machine addresses of data or instructions.
Assembly Language
3. Declaration of data/storage area:
Data can declared using the decimal
notation. This avoids the manual conversion
of constants into their internal machine
representation.
e.g 5 into (0101)2
10.5 into (41A80000)16
Assembly Language
Assembly language consist of three kinds of
statements
1. Imperative statements
Imperative assembly language statements
indicates actions to be performed during the
execution of the assembled program. Hence
each imperative statement translates into
machine instruction.
General Instruction format is
Label Opcode Operand [,Operand]
Assembly
Mnemonic
Remark
00
STOP
Stops program.
01
ADD
02
SUB
03
MULT
04
LOAD
05
STORE
06
TRANS
07
TRIM
08
DIV
09
READ
10
Assembly
Mnemonic
Remark
11
LIR
12
IIR
13
LOOP
Assembly Language-Declarative
statements
2. Declarative statements:
A declarative statement assembly
language statement declares constants or
storage areas in a program.
e.g.
i) A
DS 1
ii) G
DS
200
These statements simply declares a storage
area of 1 word and block of 200 words
respectively.
Constants are declared using Declare
Constant (DC) statement.
Assembly Language-Assembler
Directives
3. Assembler Directives:
Assembler Directives neither represent
machine instructions instead of that they
direct the assembler to take certain actions
during the process of assembling a
program.
e.g.
START 100
This statement indicates that the first word
of the object program generated by the
assembler should be placed in the memory
location with address 100
END
Assembly Language-Program
Assembl
y
Langua
ge
Program
Analysi
s
Phase
1. Analysis Phase.
2. Synthesis Phase.
Synthe
sis
Phase
Equivale
nt Target
Code
2. EQU
The EQU statement simply defines a new
symbol and gives it the value indicated by
operand expressions.
e.g. FIRTST EQU LAST
Types of Assembler
1. Multi-pass Assembler
2. Single-pass Assembler
An Assembler pass is one complete scan of the
source program input an assembler.
1. Single-pass Assembler:
- Single-pass assembler have the advantage
that every source statement processed only
once.
Types of Assembler
-
Instructions (TII).
-
Types of Assembler
2. Multi-pass Assembler
- Multi pass assemble resolves the problem of
forward reference by using more than one
passes.
- In first pass analysis is takes place in which
LC processing is performed and symbols
defined in the program are entered into the
symbol table.
- During the second pass, statements are
processed or synthesized
to
generate
machine
Equivale
Assembly
Intermediat
Pass II
Pass
instructions.
Language
nt Target
e Code
I
Program
Code
1. OPTAB
(Opcode Table)
Mnemon Class
ic
Opcode
Machine
Opcode/
Routine ID
Lengt
h
LOAD
1 (Imperative)
04
DS
2 (Declarative)
R#7
START
3 ( Directive)
R#11
STORE
1 (Imperative)
05
2. SYMTAB
(Symbol Table)
Symbol
Address
Length
Other
Inform
ation
110
3. LITTAB
(Literal Table)
Literal
Address
=5
110
=1
112
=1
120
POOL TAB
Intermediate
file
Pass 1
OPTAB
SYMTAB
Pass 2
Object
codes
SYMTAB
Pass-I
-Separate the symbol, mnemonic opcode and operand fields.
-Determine the storage required for every assembly language
statement and update the location counter.
- Build the symbol table.
- Construct intermediate code.
Pass-II
- Synthesize the target code by processing intermediate code
generated during Pass-I
Pass-I of an Assembler
LARGEB
START
READ
READ
LOAD
SUB
TRIM
PRINT
STOP
PRINT
STOP
END
FIRST DS
A
DS
B
DS
100
A
B
A
A
LARGEB
A
B
1
1
1
Intermediate Code
Pass-II of an
Assembler
NEXT1
MAX
TEMP
VALUE
BIG
Hash Table
Overflow Table
Thank You