Sie sind auf Seite 1von 38

Pass-I & Pass-II

T.E.(Computer Engineering.)
SYSTEM PROGRAMING
Unit-I
Introduction
What is system programming ?
Need of system software.
Basics of assembly language.
Overview of assembly language.
Facilities provided by assembly language.
Assembler ..
Overview of assembler.
Working of assembler .
Pass-I and Pass-II assembler
Assembler 2
What is system programming ?
System Programming:-
System programming is the activity of designing and
implementing system programs. A system program is a program that
is required for the effective execution of a general user program.
Example:-
1. Compiler.
2. Loaders.
3. Macro Process.
Assembler 3
What is system programming ?
Various stages of its processing
Assembler 4
Namely
Editing
Storage Translation Relocation Linking
Execution
INPUT OUTPUT
GENERAL USER PROGRAM
Type of Software :-
System Software:- Compiler, Editor, file management utilities,
Drivers.
Real Time Software:- Monitoring / Analyzes /Controls.
Business Software :- Banking Software with large database.
Engineering Software :- This s/w having algorithms Ex-
Automotive stress analysis .
Embedded Software:- It is resides in read only memory & is used to
control products .
Personal Computer Software :- The personal computer software
make has own application .
Web-Based Software :- Ex- Web Browser.
Assembler 5
Basics Of Assembly Language
We can program by writing a series of M/C code instruction in the
computer, it is called a programming in machine language.
Assembler 6
Overview Of Assembly Language
Assembly language program is the collection of
assembly language statement , each statement is of
following format.
Assembler 7
Overview of Assembly Processor
Definition:- It is system software which convert or
translates the assembly language program in
equivalent machine language.
Assembler 8
Working of Assembler:-
Database of Machine Code
Assembler 9
Instruction Machine code
JMP FF
MOV A, B FA
MVI A,XX FB XX
MVI B,YY FC YY
ADD A,B FD
HLT AC
Ex
Label Program Location
Counter
Object Code
ORG 0100h
0100h FB
Start : MVI A, 0 0101h 00
MVI B, 5 0102h FC
ADD A,B 0103h 05
HLT 0104h FD
END Start 0105h AC
0106h
Assembler 10
Backward Reference:-
Location Counter Program
0100 Next: MVI A, 00h
------- ---------------------
------- ----------------------
0105 JMP NEXT
Assembler 11
Forward Reference:-
Location Counter Program
0100 JMP NEXT
------- ---------------------
------- ----------------------
0105 Next: MVI A, 00h
Passes:-
APASS is one complete reading of given source program from beginning to end.
Due to the forward references problem assembler Assemble the program in two
passes.
Assembler 12
Pass-I:-
In the Pass-I, assembler reads the program line by line, finds out value for location
counter for each statement and prepares Symbol Table correctly . In Pass-I no
object code is generated.
Pass-II:-
Assembler reads whole source program from start to end . At this time it generates
machine code for each instruction. Here already built Symbol Table is referred in
order to generate machine code .
Design of Two Pass Assembler
Assembler 13
Concept of Literals:-
Literal are the immediate data specified as an operand in the instruction itself .
Ex:-
Assembler 14
General Design Procedure Of Two Pass:-
1. Specify 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 to 5 On Modules.
Assembler 15
Specify Problem:-
Assembly Language Program:-
Assembler 16
Ref.No. Source ALP LC
0
JOHN start 0
--
1
Using * ,15
0
2
L 1, FIVE
0
3
A 1, FOUR
4
4
ST 1, TEMP
8
5
FOUR DC F 4
12
6
FIVE DC F 5
16
7
TEMP DS F 1F
20
8
END
24
Pass-I Output:-
Symbol Address/Value
JOHN 0
FOUR 12
FIVE 16
TEMP 20
Assembler 17
Pass-II Output:-
LC OBJECT CODE
0
0 L 1, 16(0,15)
4 A 1, 12(0,15)
8 ST 1, 20(0,15)
12 00 00 00 04
16 00 00 00 05
20 ? ? ? ?
24
Assembler 18
Explanation:-
1. JOHN start 0
JOHN Label indicating module name.
start Directive.
0 Initial value of Location Counter(LC).
This is a directive statement which declares that , JOHN is a name of module
And it also initiates the LC with initial value as zero.
2. Using Directive.
* Initial value of Location Counter(LC).
15 Base Register.
This is pseudo-op which declares register is as base register and its contents
as a value of location counter.
Assembler 19
3. L 1 , FIVE
This instruction load the register no. 1 with the value referred by FIVE. This is
an Imperative Statement.
4. A 1 , FOUR
This statement adds the contents of location Four with the contents of no. 1 .
5. FOUR DC F 4
FOUR Symbolic name.
DC Declare constant.
FFull word 32-bit.
4 Value of data.
This statement declare constant with value 4 store as full word .
6. FIVE DC F 5
FIVE Symbolic name.
DC Declare constant.
FFull word 32-bit.
5 Value of data
Assembler 20
7. TEMP DS F 1F
TEMP Symbolic name.
DS Declare storage.
1F No. of item required and each item is full word (32 bit)
8. END
It is a pseudo-op which instructs more statement after this statement, so
assembler stops here.
Assembler 21
Specify Data Structures
Pass-I:-
During pass-I , the following database are used,
1. Input source assembly language program.
2. Location counter(LC).
3. Machine opcode table(MOT).
4. Pseudo-opcode table(POT).
5. Symbol table(ST).
Literal table(LT).
Pass-II:-
During pass-I , the following database are used,
1. Input source assembly language program.
2. Location counter(LC).
3. Machine opcode table(MOT).
4. Symbol table(ST).
5. Literal table(LT).
6. Base table(BT).
7. Object code (Obj. file)
Assembler 22
Flowchart For Pass-I:-
Assembler 23
Initialize
Read
Label
Search Pseudo-op
Table
POTGET
Store Label in
Symbol Table with
LC
STSTO
Search Machine
code of op Table
MOTGET
Type
Go to
Pass-II
Determine length of
Data space require
A
B
C
Yes
No
Found End
Using
Drop
DS,DC
A B C
Get Length Of
Instruction
Process
Literal
LT
Update Location Counter LC
Assembler 24
L + 1 + FIVE = Length
Pass I Data Base:-
1. Input source program
2 A location counter (LC) used to keep track of each instruction location.
3 The Machine operation table (MOT) that indicates the symbolic mnemonic for
each instruction and its length.
4 The Pseudo- operation table (POT) that indicates the symbolic mnemonic and
action to be taken for each pseudo-op in Pass-I.
5 A table , the Symbol Table (ST), That is used to store each label and its
corresponding value.
6 A table, the Literal Table (LT) that is used to store each liter encountered and its
corresponding assigned location.
7 A copy of the I/p to be used later by Pass-II. This may be stored in a secondary
storage device , such as magnetic tap, disk or drum or the original source deck may
be read the assembler a second time for Pass-II.
Assembler 25
Flowchart For Pass-II:-
Assembler 26
Initialize
Read
Search Pseudo-
op
(POTGET)
Search Machine
OP (MOTGET)
Get instruction
length, type ,
Binary code
Type ?
Cleanup
& Exit
Convert &
Output Cont
Determined
Length of Data
space
A D E C B
DS
DC
Not Found
Found
Using DROP
Evaluate
Expression by
searching for
values of Symbols
Assembled
together part of
instruction
(INST)
Indicate available
Base- Reg.
Update Location
counter (LC)
Indicate
Unavailable
Base- Reg.
B A C D E
Using
DROP
Assembler 27
Pass II Data Base:-
1. Copy Of source program input to Pass-I.
2. Location Counter (LC).
3. MOT that indicate for each instruction
1. Symbolic Mnemonic.
2. Length.
3. Binary Machine op-code.
4. Format.
POT that indicates for each pseudo-op take symbolic mnemonic and the action to
be taken in Pass-II.
4. The Symbol Table (ST) prepared by Pass-I containing each label and its
corresponding value.
5. Base Table that indicates which registers are currently specified as base reg.
by USING Pseudo-op and what are the specified contents of these register.
6. INST- it is a work space , that is used to hold instruction as its various part are
being assembled together.
Assembler 28
Relation of Pass-I and Pass-II and their Data Structure:-
Assembler 29
LT
PASS -I
PASS-II
ST
LC
SOURCE ALP PROGRAM
BT
MOT
POT -I
POT-II
Obj.
Code
Data Bases In Pass-II Assembler:-
Assembler 30
Structure:-
Database
Fixed
(static)
Dynamic
(Variable)
POT-I, POT-
II
MOT
ST
LT
BT
LC
Definition of Database :-
Fixed Or Static:-
The database where the structure and the contain of these tables are fixed during
the entire execution of assembler are called as fixed or static database.
Dynamic OR Variable:-
The database where the structure and the contain of these tables are variable
during the entire execution of assembler are called as Dynamic OR Variable
database.
Assembler 31
Format of Databases
Machine op-code Table (MOT).
Pseudo Op-code Table (POT).
Symbol Table (ST).
Literal Table (LT).
Base Table (BT).
Assembler 32
1. Machine Op-code Table:-
This is fixed type of database. It is used to store all the possible
instructions and related information for the assembler (Instruction set). This
table is used in both the passes
Assembler 33
Mnemonic
Opcode
4 Byte
Binary
Opcode
1 Byte
Length
2 Bit
Instruction
Format
3 Bit
Reserved
3 Bit
L 5A 10 001 xxx
A 5C 10 000 xxx
01- 2 byte
10- 4 byte
11- 6 byte
000 RR
001 RX
010 - RS
011 - SI
100- SS
Pseudo-Opcode Table:- 8 bytes/entry
Assembler has set of function to process the pseudo opcode. The POT store
the pseudo-opcode and address of function, which will be use to process
that pseudo-opcode.
Assembler 34
Pseudo-Opcode
5 Bytes
Address of Function
3 Bytes= 24 bit address
USING P1 USING
DROP P1 DROP
Symbol Table:- 14 bytes /entry
Symbol Table
8 Bytes
Value
4 Bytes
Length
1 Bytes
Relocation
1 Byte
John 0000 01 A
Four 0010 01 R
. .. .
Assembler 35
Literal Table :-
Structure of L.T. is similar to the structure of S.T. The symbol
field of L.T. may be replaced with assembler generated
temporary labels for the literal.
Assembler 36
Base Table:- 4 Bytes/ Entry
Entry No.
Reg. No.
Availability
Indicator
Address
3 Bytes
1 Yes Error
2 No
..
..
14
15 Yes Error
Assembler 37
References:
John J. Donovan, System Programming , TMH.
D. M. Dhamdhere, System Programming & Operating
System, TMH, 2
nd
Edition, 2008.
D. M. Dhamdhere, System Programming, 1
st
Edition,
2011.
Assembler 38

Das könnte Ihnen auch gefallen