Vous êtes sur la page 1sur 10

Assembler

Designing Procedure
• Problem definition
• Define data structure
• Specify algorithm
• Modularity check (whether the program can
be subdivided into independent programming
units)
• Repeat above steps on modules
Problem Definition
Source Program
JOHN START 0
USING *,15
L 1, FIVE
A 1, FOUR
ST 1, TEMP
FOUR DC F’4’
FIVE DC F’5’
TEMP DS 1F
END
Design Issues
• The program contains symbols which has to be
replaced by relative location
• Relative locations of instructions and data could
not be determined before assembling the
program
• One way is to assemble the program according
to known information so that the relative
addresses can be determined (first pass)
• These addresses can be replaced with the
symbols (second pass)
Intermediate Steps to Assemble the Program
Source Program First Pass Second Pass
Rel. Add. Mnemonic Inst. Rel. Add. Mnemonic Inst.

JOHN START 0
USING *,15
L 1, FIVE 0 L 1,-(0,15) 0 L 1,16(0,15)
A 1, FOUR 4 A 1,-(0,15) 4 A 1,12(0,15)
ST 1, TEMP 8 ST 1,-(0,15) 8 ST 1,20(0,15)
FOUR DC F’4’ 12 4 12 4
FIVE DC F’5’ 16 5 16 5
TEMP DS 1F 20 - 20 -
END
Design Issues (Contd.)
• Steps performed in First Pass
– Determine length of machine instruction (MOTGET1)
– Keep track of location counter (LC)
– Remember values of symbols until pass 2 (STSTO)
– Process some pseudo-ops
– Remember literals
• Steps performed in Second Pass
– Lookup values of symbols (STGET)
– Generate instructions (MOTGET2)
– Generate data for DC, DS and literals
– Process pseudo-ops (POTGET2)
Pass 1 Assembler: An Overview
Initialize

Read USING
DROP

Store Label in
Label or Yes
Card?
ST with LC END
Value (STSTO) Type? GOTO Pass 2
No DS
DC
Search Pseudo-op Found
Table (POTGET) Determine length of
Not Found data space required
Search Machine-op
Table (MOTGET)

Get Length of Process Literals Update Location


Instruction (LITSTO) Counter (LC)
Pass 2 Assembler: an Overview
Initialize

Read

Search Pseudo-op Found END CLEAN-UP &


Type?
Table (POT) EXIT

DC
DC
Not Found
Convert and

USING

DROP
Search Machine-op output constant
Table (MOT)
Determine length
of data space
Get Instruction length,
type and binary code Indicate available
base register (BT)
Evaluate operand expressions by Indicate unavailable
searching for values of symbols base register (BT)

Assemble together the Update Location Counter


parts of the instruction (LC)
Format of Data Bases
• Machine-Op table and Pseudo-Op table are
the static table from where the assembler find
the length and its binary equivalent op-code
Instruction format
Mnemonic Binary Op- Instruction Instruction Not used in 000 = RR
001 = RX
op-code code length format this design 010 = RS
(4 bytes) (1 byte) (2 bits) (3 bits) (3 bits) 011 = SI
100 = SS

Instruction length
Machine Op Table; 6-bytes per entry 01 = 1 half-word = 2 bytes
10 = 2 half-word = 4 bytes
11 = 3 half-word = 6 bytes

Pseudo-op (5 bytes) Address of routine to process


pseudo-op (3 bytes)

Pseudo Op Table; 8-bytes per entry


Format of Data Bases (Contd.)
• Symbol table and Literal table are changed
according to the entries in the assembly
program

Symbol Value Length Relocation


(8 bytes) (4 bytes) (1 bytes) (2 bytes)

Symbol Table for Pass1 and Pass2, 14 bytes per entry

• Base table contains the base register reference


and its value
Base Register No. Base Register Content

Vous aimerez peut-être aussi