You are on page 1of 6

2 pass Assembler

- Apeksha Gopale

Sample program Pass 1


Relative add.
Mnemonic inst.

Pass 2
Relative add. Mnemonic
inst.

PG3 START

USING *,BASE

SR

SR 2,2

SR 2,2

2,FOUR

L 2,_ (0,_)

L 2,18(0,12)

2,FIVE

A 2,22(0,12)

2, = F 7

10

A 2,_(0,_)

10

A 2,30(0,12)

ST

2,TEMP

14

ST 2,_(0,_)

14

ST 2,26(0,12)

FOUR DC

F, 4

18

18

0100

FIVE DC

F, 5

22

22

0101

BASE EQU

12

26

26

TEMP DS

1F

26

26

30

30

END

2,2

A 2,_(0,_)

SYMB
OL

VAL
UE

LENGT RELATIVE/ABSOLUTE
H

PG3

FOUR

18

FIVE

22

BASE

12

TEMP

26

LITER
AL

VALU
E

LENGT RELATIVE/ABSOLUTE
H

=F 7

30

Br NO

Availability indicator

NO

NO

12

YES

00

15

NO

R
content of BR

1.Pass 1.
2.LC = 0.
3.Read Card.
4.Search POT ,
IF found GOTO step 11 ,
ELSE Search MOT & GOTO step
5.
5.L= length.
6.Process if any literal present, enter
it in LT.
7.IF symbol present Assign current
value of LC to symbol
8. LC=LC+L.
9.Write copy of card to use in pass 2
10.GOTO STEP 3.
11.Find type of pseudo-op code.

12. IF USING/DROP GOTO step 9.

13. IF EQU , evaluate operand field


and assign value to symbol in label
field. GOTO step 9.
14. IF DC / DS, Adjust LC and
L=length of data field, GOTO step 7.
15. IF END, assign storage locations
to literals and refresh copy file. On to
Pass 2.

1.Pass 2.
2.LC = 0.
3.Read Card from file copy.
4.Search POT ,
IF found GOTO step 13 ,
ELSE Search MOT & GOTO step
5
5.Get bin op code, format, L= length.
6.Find instruction type
(RR/RX/SS/SI/RS)
7.IF RR, evaluate both reg. exp. &
insert into 2nd byte, GOTO step 9
8.IF RX, evaluate reg. & index exp.
And insert in 2nd byte, Calc. EA of
operand, Determine
displacement(D) and base reg(B),
put B in 3rd byte & D in 4th byte,
GOTO step 9
9.Punch assembled instruction.

1.Print assembly listing line


2. LC=LC+L.
3.Goto step 3
4.Find type of pseudo-op code.
5.IF USING/DROP , evaluate
operand, entry in BT, GOTO 18.
6.IF EQU/START , GOTO step 18.
7.IF DC / DS, Adjust LC, for DC
form const. to insert in assembled
prog. and L=length of data field,
GOTO step 10.
8.IF END, generate literals for
entries in LT, STOP.
9.Print listing, GOTO step 3.

Single pass assembler

l
l
l

Data :AX BX CX
DX (16 bit)
Index: SI DI
Pointer:SP BP
Segment: CS DS
SS ES

l
l
l
l
l

DB 1
DW 2
DD 4
DQ 8
DT 10

You might also like