SP Unit-2
SP Unit-2
Chapter-3
Assembler
Assembler is system software which is used to translate assembly level language into machine
level language program code
Functions of assembler
First we are analyzing the problem statement next we are maintaining the what are the databases
using design proposes next we are getting one format of those database and write algorithm for
the statement and look overview of these steps
• The first pass defines the symbols and literals here we cannot find out the offset value
• The second pass generates the instruction addresses means the offset value.
Step1: statement of a problem
Consider the following source program which has to be converted into machine language(object
program)
JOHN START N0
USING 15
L 1, FIVE
A 1 FOUR
ST 1 TEMP
FOUR DC F‟4‟
FIVE DC F‟5‟
TEMP DS 1F
Pass 1 pass2
0 l 1,-(0,15) 0 l 1,16(0,15)
4 A 1,-(0,15) 4 A 1,12(0,15)
8 ST 1,-(0,15) 8 ST 1,20(0,15)
12 4 12 4
16 5 16 5
20 - 20 -
Note: the load instruction add instruction and store instruction are RX instruction format so we
are using relative address 0,4and 8
Pass 1: database
4. POT(pseudo operation table)-it is used to store the all pseudo opcodes in our source program
and corresponding actions
5. ST(symbol table):it is used to store all the symbol /labels used in our program and its
corresponding value
6. LT(literal table): it is used to store all the literals/constants used in our program and its
assigned location
Pass 2: databases
3. MOT:it is used to store all directives or mnemonics and its length, binary opcode and
instruction format
4. POT: it is used to store all directives and its action corresponding index
5. ST(symbol table)-it is used to prepare by pass 1 it consists of each label and its value
6. BT(base table)-it is used to store which registers are currently specified as base register by
USING pseudo opcode and it specifies the contents of these registers
7. INST-this is a work space used to store each instruction as its various parts.
9. Punch card: it is also work space used for converting the assembled instructions in the format
needed by the loader.
Format of database
After the second step the third step will be format of those above mentioned databases.
MOT table
Codes
Instruction formats
• 000=RR(2 bytes)
• 001=RX(4 bytes)
• 010=RS(4 bytes)
• 011=SI(4 bytes)
• 100 =SS(6 bytes)
POT table
Format
Symbol table
• It is a variable table
• Same table is used in both pass1 and pass2
• The size of the table is 14 bytes per entry
• The length field indicates the length in bytes of the instruction to which symbol is
attached
• Absolute means the value of the symbol doesn‟t change if the program is moved in core
Format
Literal table
Format
Base table
• It is a variable table
• It is used to specify the base register
• It is used only in pass2
• The size of this table is 4 bytes per entry
After the third step next we will go to fourth step of a design that is algorithms and flowcharts of
an assemblers
The important purpose of a pass1 assembler is to assign location to each instruction and data
defining
Pseudo-ops and define values for symbols appearining in the label field of source program.
ALGORITHM:
1. First we are initialized location counter value is zero because of the relocate location is first
zero value after that based on the instruction formats that will be increased.
Pseudo-ops it will the attach to the location counter and definition of symbols in pass1.
6. If it is not pseudo-opcode that is machine opcode search for MOT for matching with with the
source
The purpose of pass2 is to process each card to find the values and its offset values
ALGORITHM
4. If it is USING pseudo-op or DROP pseudo opcode, then they may require addition processing
in pass2
7. If it is END pseudo opcode terminate pass2.before terminating pass2 generating the code for
literals and symbols.
9. If it is a machine opcode then it will store in to the MOT entry and to find length and binary
opcode and format of the instruction format.
11. It means we will search which type of instruction format it is whether RR, RX, RS, SS etc
STEP 5:Look For Modularity