[go: up one dir, main page]

0% found this document useful (0 votes)
231 views40 pages

Assembler

The document describes the design of an assembler program. It discusses the purpose of an assembler to accept assembly code and generate machine code. It outlines the general design procedure including specifying the problem, data structures, algorithms and modularity. It describes the databases used by the assembler in the two passes - the symbol table, machine operation table, pseudo operation table, literal table and base table. It provides examples of the formats of these tables and flowcharts of the two passes.

Uploaded by

AASTHA JOSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
231 views40 pages

Assembler

The document describes the design of an assembler program. It discusses the purpose of an assembler to accept assembly code and generate machine code. It outlines the general design procedure including specifying the problem, data structures, algorithms and modularity. It describes the databases used by the assembler in the two passes - the symbol table, machine operation table, pseudo operation table, literal table and base table. It provides examples of the formats of these tables and flowcharts of the two passes.

Uploaded by

AASTHA JOSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

System Programming (168913)

Assembler

Mr. M.R.Solanki
Sr. Lecturer,
Infrormation Technology,
SBMP
Students will be able to:

 Describe the working of an Assembler


 Enlist the list of databases during assembler
passes
 Describe each database used in PASS1 and
PASS2 of an Assembler
 Draw flowcharts of PASS1 and PASS2 phases of
an assembler

2
Assembler
An assembler is a program that accepts an assembly
level program and produces its machine language
equivalent along with information for the loader

3
General Design Procedure for Assembler
1. Specify the Problem
2. Specify Data Structures
3. Define format of Data Structures
4. Specify Algorithm
5. Look for Modularity (capability of one program
to be subdivided into independent programming
units)
6. Repeat 1 through 5 on modules

4
General Design Procedure for Assembler
Statement of Problem

Generate the relative addresses of entire program?

5
General Design Procedure for Assembler
Statement of Problem:

The first pass can not predict the address of


offset so it is indicated by _

6
General Design Procedure for Assembler
Statement of Problem:

As an assembler, we can go back and fill the


offsets as shown in the program

7
General Design Procedure for Assembler
Statement of Problem:
An assembler does the following tasks:
 Generate instructions:
A. Evaluate Mnemonics in the operation field to
produce its machine code
B. Evaluate the subfields: Find the value of each
symbol, process literals and assign addresses
 Process Pseudo ops

8
“NOTE”
#Because Symbols i.e. JHON, FIVE, FOUR, TEMP
are appearing before they are defined, it is
convenient to make two passes over the input

# The First pass has only to define the symbols

# The second pass generates instructions and


addresses

9
General Design Procedure for Assembler
Statement of Problem:

10
General Design Procedure for Assembler
Statement of Problem:

11
General Design Procedure for Assembler

Statement of Problem:

12
General Design Procedure for Assembler

PASS 2 Overview: Evaluate Fields and Generate Code 13


General Design Procedure for Assembler
Data Structure (Databases)-PASS1
Abbrevi Name Working
ation

MOT Machine – Indicates symbolic mnemonic for each


Operation-Table instruction and its length

POT Pseudo- Indicates symbolic mnemonic and action


Operation-Table to be taken for each pseudo-op in PASS 1

ST Symbol Table Stores each label and its corresponding


value
LT Literal Table Stores each literal encountered and its
corresponding assigned location

14
General Design Procedure for Assembler
Data Structure (Databases) – PASS2
Abbrevi Name Working
ation

MOT Machine – (a) Symbolic mnemonic (b) length (C)


Operation-Table binary machine-opcode (d) format

POT Pseudo- Pseudo-op mnemonic and the action to


Operation-Table be taken in pass2

ST & LT Symbol Table & Prepared by pass 1, containing each


Literal Table label/symbol & literal with its
corresponding value
BT Base Table Registers currently specified as base
registers by USING pseudo-op and
content of this register
15
General Design Procedure for Assembler

16
General Design Procedure for Assembler
Format of Databases: MOT – Pass1 & Pass2

17
General Design Procedure for Assembler
Format of Databases: POT – Pass1 & Pass2

18
General Design Procedure for Assembler
Format of Databases: ST - Pass1 & Pass2

19
General Design Procedure for Assembler
Format of Databases: ST - Pass1 & Pass2
The relative location tells the assembler
whether the value of the symbol is:

• Absolute- “A” (doesn’t change if the program


is moved somewhere else in the core from the
current place)
• Relative – “R” (can change relative to the base
in the core)

NOTE: The symbol with statement having EQU


pseudo-op has always absolute location – “A”
20
“NOTE”

The Format of Literal Table is same as Symbol


Table

21
General Design Procedure for Assembler
Format of Databases: BT - Pass2

22
General Design Procedure for Assembler
Assembly Program to demonstrate tables

23
General Design Procedure for Assembler
Assembly Program to demonstrate tables

24
“NOTE”

* = Present Instruction
Literals are stored in LT when they are
identified in Instructions but their
locations are decided by LTORG when
END pseudo op comes.

25
Detailed PASS 1 Flowchart

26
General Design Procedure for Assembler
Symbol Table

27
“NOTE”

For the symbol having EQU pseudo-op, we have


to put the constant mentioned after EQU in
the symbol table instead of LC value.

28
General Design Procedure for Assembler
Literal Table

The First literal is encountered at statement 11


 Its value will be the first address of literal area
 The last instruction(BR 14) is placed at address 40 . The
next available address is 42 because BR takes 2 bytes (40
and 41)
 The LTORG pseudo-op places the first literal at the
address immediately after the last instruction (BR) by
adding 8 bytes (next double word boundary -8 bytes) that
is at 40+8 = 48
29
General Design Procedure for Assembler
PASS2 Task

30
General Design Procedure for Assembler
Base Table

31
General Design Procedure for Assembler
PASS2 – Generated Code for Program

32
General Design Procedure for Assembler
PASS2 – Generated Code for Program

33
“NOTE”
#A card is a unit of information i.e. one statement

#We can add Pseudo-Op START in Flowchart. The


symbol on this statement will be inserted in the
symbol table with present LC location.

34
Detailed PASS 2 Flowchart

35
General Design Procedure for Assembler
PASS2 – Generated Code for Program

36
37
Any questions?
You can find me at
manish_ratilal2002@yahoo.com

38
Credits
• Systems Programming, John J. Donovan,TMH
• http://www.simotime.com/simoi370.htm
• Floating Point Representation -
https://www.doc.ic.ac.uk/~eedwards/compsys/float/
• http://www.edwardbosworth.com/My3121Textbook_HTM/MyText3121_Ch09_V
1.htm

39
40

You might also like