Académique Documents
Professionnel Documents
Culture Documents
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)
Read
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)
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