0% found this document useful (0 votes)
33 views23 pages

Assembler Notes - SS

The document discusses the design and components of a two-pass assembler. It describes the analysis and synthesis phases of each pass and how symbol tables, object codes, and relocation are handled.

Uploaded by

9txqnq592d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views23 pages

Assembler Notes - SS

The document discusses the design and components of a two-pass assembler. It describes the analysis and synthesis phases of each pass and how symbol tables, object codes, and relocation are handled.

Uploaded by

9txqnq592d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

l peiAssemblySCheme

De iqn spe cificatioon aSsemblen


Ladentiku the intox mation necessAJY
perfosm a task
datq etmchu to
2 Deaiqn a siita ble. 27VOM
deCo rd' the intopmai on.
3-DeteIminethe procedinq necesary
Lobtain and mcun tain the i o rmation.
4.Deter mine he processinq pe c@ASan to
petorm he tasb

Synfheois ntormachio nA
Phoo 1 Seq w rements -& Vic

o n nemonic oPCode leng toi ThIa


ADD
SUB 2 2a
mnemoniC
abl 2d Ju2s

Coel Analysis (n23


pg phase SyrtheS
phase
Tagur
SYmbo ad drel
2 ATN
d data açB8
13 b - >cont>0
Sm.bo 74ble2u t Ahe toqnHN

D3tis
Data stcu rto of the asemblelA
Foge
Date

Analysis Fha0

Analysis phaSe genesate Symbolable


Hence imust_determin addeAs
Sy mbos DSed in theproq0 M:
odetesmine the cddres0f 3ymbo
N it mUst i n d h n a d d r e s o au
the insty uchon_beto Te N in the prq.
Thisistica lleldumumoryallo cation
LOcahon coUntey s u A éd to mem0 ny
all ocahi on
0ontains the add. o nextins tbmtie
LOhRneN En_a labellis tU nd enth
s ma de in sy mbol nd h e i contents
of LCis als ntereduin ST
LGi hen Up date.d bu adding-
enqth eingi? 1A
lengHa o jnsi2 depehds Dpon assemb/y
mhemonic tab le_ha mne mobiccode
g length
Ap crt Pn m he Constmcti on of ST
&LCpro cedino analys T_ phase a/So
h edca th valdity o mhemoni CA
t i n9 to2mnemonic ta b le
tg.en exatto intesmediate. co de whih
ac ao: iftOyntheDiS phCo
SqnthesisPhase ia

CDnsid ex a tafem nt
MoVERBREGN.
Date
M2-
th
Stat atemtnt
synthed
i ze
to h ave 1hing3
drden
In
Addod
t mOstinstpasociated oih Suhmbal
pondind
tom
mnemdhic
nemh

e f c o d & C o r E

mc
MOVERd on SoU rce P
bq a hl
S y m b a l d e p e n d s

Add of lable
availa
ahal
ismad
it 4
ned b
phaoe daican
bedeteymy

/ c opco
mnemanic 7able
has
ymbol fak|
Each entn odd
hame 4 a
onic
mnem.anic fable haS mhem
Opcood lenath
o
The Syn theAis phase
mm h eo h0o fable to generate
faraet roarqm

Srvctu

lwo paSStrunslation-i
1t can handle ruQrc etey hce eaail
LC pro.ceAsin is cdone in 1_pass

Asymbol& intered lin S T


hc pacSs suntheSiz eo he taxget torm
Ding fheadd ndton fo und in T
l Spqs =analua S c e prg
H2 HGot
6 uipoio unis hs liz laspg|S 2g sefraid .
M2-
-SMVS-
PageN
Date
2ha pass
syntheoi.s of
St pa cs
woe
constyuctsTR ef S P foy
n 2ha pass
2
Com poners n tiq
ecta strucfuxes(eg. ST &pncess edL
Data Stnoch
se

Paoe
deufa a cc eS
C -couTltrate
inta

6Veryiev o 2- pacS ac embly


b hlo pin 3A
Singlea translati on ishdn
2 odon2
Cprocesing andconstructioh of he_
m bo table
pro blem of o ruoard xeteenceis tackle
luaingbacepatthing 9 g r pribogbod
hstn heoperahd ioeld of antnsth Containing
toruo are retRr ence isslee blant hitiall
Add. o torcocLrd referehced sy mbel ic
bba u p he-ield Whe h its demninon i

3tuoll 8.
ieigu-aeal szai acfati Gaieg z d
Page No.
SMVS
Date: I

eX MOVGR BREG, oNE221


can b partially synlhsi2ed since oNE
is a fox0adreterence
opcode add. o BREG Lill be at 101 Pax
Acd.of Second apcrand. is ad ded t
Tabla o£ Tncomplete Dns tzuctions TTT
Kinstrvction add., <Symbol>) eg(1o1, ONE
MOV ER BREG oN--101) o 2 toS

Bu h time he ENDD
Sfate ment is process ed
heST Contain 1o16N GNEor
addresS of all the
Sumbal k TIL contain
inD. o a l he tov Wad reteren ceo
Enbr q ol, ONE) DOld be
obta ninghe ad dresS 2 0 pocesse d by
symbo ta ble 4 inser tinq NE om
it in he
opiand ad dei&hediiof the. inP
1pith incomplet e_ad.d reg S
hackpatclhinq e e tpoceige
YaAolving
eterence that havebeen plaed
tin heco de
blsa
TIId erht he butein co.de whtrd theAdd SIS
trunce.d Sum.bolSh0 uld be put
oulh p h i e n t ySbaldinihion
eocudd.2 na isnCoLutt
nco utu
-SMVS
Page Na

a3TJun Date:

0oiqnofaTuooassAss Emblen
Paas Sepaxate the Symbol, mnemo wic
Dpcod k_operand diel ds
2Buld the sumbol table
3. fertos m LC p ro cess inq
4 ConSst
nct intermediate xeprroeu
Tass- Sunthesiee the target pgYam.
aSsTpeinrms analysis of the source prg
2hnn and sqnthesi &A th R
Yas-Tp&0ceseo the IR toSyn thes ize the
ta rattprg-
Advanced Assenbleh Direotivea
RIGIN

tax ORIGIN Sa ddress Spece2


is an <operand pec >
OrKonatat >
Ttindicatep that LC should be e t to
Hhe add relS qiren byKaddres pece=
fiS-2t isoeful Ohen h target pmgram
degn not consittot consecun Ye memon
ThEabiity to uoe ah <ope ran d SPec
IS n 1ORTuIN state ment pro Vides he abil-
t0 p.elfDm LCPrOceing in_a 1elative
LC fAge16)e
t2, sets
LOoP
IN
Inthe pgORIG muLT
CREG,teithdve
So
2o LocP hao 202 es
absaluremahn
addzesy
sathel thah 214 204 we
sets LC.
LAST1
to add.
ORIGLN
L C a n also ORIGIN
wnta 202absolute
EQU OR IGIN 21 acd oiLO.
ssum bal>EgU addYeAs
Suntax SPecisS

SoperCUhd
tahere SaddreS Spec> iSah
KCon&ta nt>

he name umbol oih


addresS pecihcahon
T ee sim pl u associat es the hame
Ssymbo> oih acd ress Space >>
exBAC ESU LOoP.

LTORG
cavit1id aldn 2.2AbaanoubA
The LTORG totement pYmS he
PDaramm toSpecihy bohere the litexals
houd be placed
Bu detault Hhe a ssehmble plac e al he
iterals aPtey the END Statem ent
All Hhe ite rals are allo coute d mem0
Lohich is hou0n 0olite ral poo

ex bhSTART 200n
2 movER AREG 200) to 1 21
movEm AREG A 201) to.s 1 211
LOoP movER AREG A 202) +o 217
D m o rER CREG B 20)0 3218
ADD CREGa'£ 201) t o 3 212
infe 1051sp-pnH adel 6rH cis ilail Huncil etel.
- e s thah.
M2 g reare than
PageNo
-SHVS
ES-e ual. Date

2 BC ANY, NEXT o) +o7 6 2/4


13 LTORG
0) toc o
212 +0o co
NGXTSUBAREG '214)+02 219
BC LT , BACIC 215) +07 1202
17LAST s TOP 2 too o
(13o n ORIGIN LOOP +2
mULT CREGB u)t03 3 2
20 O RIGIN LAS T
2 A DS 21)
22BAcC EgU LooP
DS 1aAT9 21)
24A a ND
212)+60 oo
Iiterals 5 and are adcled to litex
pooin st-2k 6
isst LTORG allo cates the_ a ddyelse
211 and 212 t ihe Valuessand y
A neo litea_posl is now Started.
Value ' is put into pebl in strtemeu
S This alue s alo cated to add.
h e END Jatenc
219LOhelprocesing
Literal E uaed i n S t E r e t e s
Ho location 219 t h secohd pool of
ite yals ahen ihan locatton 212 of th
st pcol._
AI repe senc eD fo iterqls are ordard
eht rences by dinihien
Page No.
-SMVS
Date:

aSS I the as.S.emblo%


Fass-1 LO eA oe olloud inq dafa cbucte

lo PTAB-A table of mnemo niC opco


de
GUnd rel ated into rmathon_
mnemoniC
Opcod e . cqss m nemoniC
ito ma chu n
mo VER S
(o4, opcpde
DS DL instt
START AD R )- lerqth.
1 OPTAB3.
ettina to handte
LodhecladShld indicatestheohethDL&AD
opcodR_
i Coseoponds toan imperahve
of(TS)adedaratiom tatement
OsSmb]er_ state ment fo 0
direcive AD)2
STMTAB SumbolTable-ah SiSbon 1&
9t A
Symbo haddrels lengthulov
bbo LoOP 202
NEXT4
LAST i2164 PiS
b A 2 2dt 214
BACIol 20 2
218

SymTAB
8P.psni
inobp ibse pss
Page No.
-SMVS
Date:

CYMTAB containsa dd ses8 and length


Frocessi ng o an ass
umbly Statenment
beginsOthh pro cess inq f is labl
ield.t
T it contain S symb o+he, Value tha
LCisCopiolintonew entry oSYmTH
Ater hat The tunchioninq of PASS-
CehterS aYDUnd th inteYp Yetaton f
OPTAB entny t y mnemoni
t a t ement ris imperrtie he lenath
machine itrucionisadded to Lc
Lehgta is alO entered inSYmTAB
Oothen state mants 1he reop. Duhne
colled Fo DS R#2 tSD call ed
a d it i l Dpdates LC
aldo A
LITTAB A table o itexals uw ed in h

A LITTAB ent nn Cohtai ns the ifelds


A literod and addrelg 2 ivotlida

literal add re3

9aru Y2 2in3

dotls SAtJo91LTIAB

he rst pa ssseA LITTAB to collect a


itexals Dedin dhe pngrq m
aso anLS drerent itexapossic
moimaine d sinq tbe auxillary table Po6LTAE
giRgl-GRIPSI Bzai edatHT Gclieg g Y38.
-SMVS-
Page No.
Date
his tbl contains the 1it eral omben
sfhe staating itexal o each 1iteral
Pool
The cuxent lite ral pool is t h e la s t poo
in L1TTAB
tohenLTORG or END Statemet Occu
Htesalsin the cuLYrent poo are alecated
addreAseA otartinq hoith th current value
in LC Qnd LG iSin
cxemented.
In th e psq ohen LTORG occrS St
tuooliterals i be qiven addre8ep
2 ahdn 212
At END the thirdi lite ral oill be
given addseS 219

Algo ASELmbleh. Eirst Pascs


loc-CntY O (detault va lue)
pooltab-ptse PooLTAB ( -1
littabptrie
2 LOle next tatem ent S not an ENDD
Ctatehment
a) T labelisprioent thun
thislabel = s ymb al in label hield
Enterthis-label , loc-chti) in SYmTA8
b) I+ gn L76 RG Statem eyt h eh
i)Po ces lteals LITTAR PooLTAB [Poo tob
LITTAB (ittab ptr-1 to al ocate
hmem 4 put he addrein th
a ddseS tield
lhaU pdateiLoc-CntrCACCLO rdinal
-SMVS
Page No.
Date

)pooltab ptY Pooltab-pBx


1) PooLiA BLpool tab- pt littab-pt
) a TART o0RIG)N Ctatement then
oc-Cnty value Spe cihied inopenad
a)T an EU ctatement then.
hic addr = value ot Kaddress Spec
chxreet thesymtab enty ox hislahel.
tothis-label, this adda)

ET a_decla yation atatement thep


cod e =cocleofHhe dedaation Atatema
il) Site -Size Of me.moy qrea vequired
by DCDS
my loc- nts.e loccntr + Size bis
enerate IC (DL, Co de..._
CiN) a v b h A l

A animpesanv& statement theh


3 defom 0 PTA B;
( code amachineopco
to foPA
i) loc-cnty e loC-chtYt InD lehg
operand is q 1itesalthen
) TP t o i s - l i t e r o l l i t e r a l in opeAcnd -held
r e thiteral
LITTAB Gtfab_ pt
itfab - ptitju
Uttab - pty =
opLrand is 9 umbo)
eSe:e
JYmTAB n t n no
o Op¬na-
this- enty sthis-entr)
Generate IC (1S,co
ele)
2 i e

g zel s.
aiPGI-GR9I
aRai adotai Gci2g
-SMVS-
Page No.

Date

8 . f oceasinq D END statement )


a)fextoYm step 2b).
) Generate sC (AD02)
(C)Go to fasS T

tex nediate Co de Form&


wo c at e ma of choice TR
pro cessinq eti u'en u
memon economu
he TC con sicts b et oE IC Units
each TC pnit consict 0f PreldS
1.Addreis
2. RepreDentathon Of he mnemonic 'o
3 Rep reoentati on Of pecode
soperandsb
Addressopco oe perand
iq An IC Unit
ATT
Mhenmguic held a do
Tnto o his held xemainS am
a aunds in

The mne manic held


ContauinS a pair o
Stattement clals, Co cle
SMVS=
Page No.
Date

whr Sfatemunt claiscan be 6/n o


IS,DL and AD.
oyTS cocde i th inst opcode. in the
achine langage
Fo DL& AD de ison o rdinal humben
Joithin h cladS
AD,o1)-means AD ho. tohich is
STA ST

DS
sTART O
3DS 02aetaikEND 02 nirie
oROIN O3 o AAre
E U Oy

LTDRG0S

Tne ymediate Codetoy Dmpe xative


State mcns
(TE
Ihee ar 2 Vanan ts o TC Lau ch dfe
ininYo*maion containim in thei
operand heldss
Addres ald is icdeutical in botb vaiantB

laiaht-T AA

irst operand single digit numbey


wishiSaCo de dor reqicter A
(L-4 f AREGD REG). Oy condition
ode( 1 - 6 LT-ANY) LL

ANY 6
No.
SMVS
Page
Date

Second operand = mon perand


ope ran d clasC co d e .

ConStant Ttes al
ymbo)
O ra C a n s t a n t , the coe. held contains
he intexnalrepkeoentaion of he
Canstaht ise )P
The opexand descdptox to r th Statemout
STA RT 200 ic(C,200),

Eos ymbol or itera, the code i eld_


ContalÝS
the ordinal numbn a thhe
opeiandsRnt y h 9YMTAB ortTTA
ntieo tai a ymbelnxY 2 and a
fteral = '2S OOu d be (s 1 <L35)
EDP.
STA RT 20 O AD, 0)) (C 200D
READ A TS, 09) (S, o)
ooiLooP mov ER AREG, A (IS,ou) (1) < ol)

CUB AREG (TS, 02) D (0)


BC GT, L0 oP LS, 0) (4) (S,o02)
STOP
A PS DLO C1)
LTORG
-SMVS-
Page No.
Date

6LiaeT It diters fom vosuant-T of th


I Ci n dhat the operand fieldso f
th ource ctat emeS are selectively
eplaced by their p ro ces e_d toxns
O DS andAD p svces inq ef th
operan d fel ds is eA ntial to support
LC pro ceAsing9
Llence th eoe felds contain h p x0ceied
Fox IS the operand field s p0 cexsed
onl to idenhfyiterad refer ences
Litexalo axehtered jn LITTAB, and are
s p re0 ented 00 (L m) in TC
S m b o l i c Teferehe e A in S fiare
not 3D ce&ed at aul duuing Pass I

bonSTART20O AD,01) C,200)


READ A (S
ve Loo P mDVER AREG, A (TS, ou) AREG) A

SUB AREG,1 TS02) AREGL o)


BC QT,L00P (TSD) T,L0ofo
STof (TS,0 0)
A DL02) CD
L TORG ADA )
therauan5-

Co m panciono

latniaut- Vasuant -D

Nanant-L of the Tc ONaiant- duce th


appe@rs to reqire exhd LOOYko Pass -IT by
LOOY n Pass-T Since tsanstesynqn he bude
Operond Aelds_qxe oprandprocesing
Completely procekied nm Paus to Pas
he asSem ble

ais pocessing cimplto)1h is pro ces ing mak


the HaJES PasS-. Pass- to pertorm
m oe
heTC ic qut e
compact-itncan be a e) TheICTiS es
CBmpdct a0 the taraet Compadt Since the
Co deitsaP each
Opeand ete
memony perand lo 4
nce typical im perativo sto
lice n) can b isn
ep roented in the samel itsel he nco urCe fom_
no. of B ao an operand
add ses Sn a maching 1 A
TO
nstncthon_2T
mem.oneause mB mem0 reg usemoktB
Pais-T Pass- Fas Paas-
DS DS D
DS
areg
areo
areg
esp gE, gFibd o bp Ibse iDSIsp.- SinH ael GuH cte lal andl etell.
n2- -SMVS
Page No.
Date:

FassLPertamà The ode sit ea e the


uch moxe ppcexSin tWo paas Co
no
Cod oc cupieo more Com paxable hence the
ovesoll memoyxquir
mtmónfhan the od-ent bf the asemblen

K0cEsSing o DeclaSatiens ohd


ASs enmblkADire ctiveo
Ne need tokind aternati veL0.gy
pnceinq DS 4 AD How Aa they
pro cesg din Pall -T
1- i t neces an o Keprecen he add re
Ceah s0urcestatemunt in1c
od i necessary to have an explict
ep seLentah on e DS State mons&
asReblen disectiveo n TC

Art YES
O190 TA
eX STA RT 200 (AD,O) (C20)
AREAL D S 20
5
200)DL02) (C, 20)
S12 DC goDL,l) (C
t is not neces ay to have c epresentatiai
DS AD in IC i4 the IC Contauns
on a d d r e s h e l d .
Page N -SMVS
Date:

t addye eld somitted xep


of S e AD is taSe ntial.

fass Can detRSmine headdre


Ani sEE bnly att n
ohaluzinoh
IC uhitS Hox h START Ahd DS
DC state muat
ADC S tate nLent muot bein JTC the
on&monic. field containg th pai
DLol)
operand hieldn ho Con&ta M in So
No pro ce38 n9 advo cR
ntage
eithen. c00 since Conv exidts in
Cond tant int ma engionDoThR
cine co do ic seqAur

DC
a sej o
in th IC DLDl) uni can beput
START& ORIGIN
The i d ri ye0
C t not senw valu eN into th
STHRT nd RIGIN neceCYy to etaun S
he DC ContanS CTat Emens in the DC
auh ad d rok h ld
LTOR
litezal
checes dor the_pren ence ofa
efeYence in the epeand held 0t e r y
Statenment
Eone existSIt enters he iteral in the
cuent litealpoo n LTTAB
ohe_ TORG state ment appeaY S in S
EOCSIgns m emo ny_ a ddreslo to the_
hte rals in the currentpoal The
addieALA are entesed n
a ddreDs held ot t h r TTAB ent i e o -
as- COud gimpl Com& tnct cunLC
onit p i LTORG State mcu and we au
Subsegaont pncex ne to Pae-T
Valueo t e yao Can be in&ertedin th&
uE c
TagetpspqYam_ o hen his TC
pmcebe4 in Pars-T
Thic equy tD the woC o Po0L IAB and
LITTAB n a mauÐnen analoqao to Pak-T

e x I C by the isst half cOben proßam

START200 AD O) (C2 0o)


MOVER AREG TSOU) CL o1)
mo VEM AREQ A (TS,or() (,o
LOo mov ER AREG,A (TSoU) Va(s, o1)
BC_ANY N EXT (Ts09) 6)(C,o)
LTORG DL, O) CCS
DLO) (C,D
Page
Date:
No. SMUS
his increao e The tas o faL-
9ceincxe.aoeA
ite rals hare t
LIT TAB and TC beth
eyic
tLpla c
fass the Assenmblen
Algo t a g e tc o c l e

1codearea-addre3
pooltab-ptr =l
qddreAR ocode
loC-Chtr =0j
2 0l next Stotemant not an ENDp
tatement
CCleoY machine co oe -
b L an LTORGstate bUHtRY
ment
OProcels literals in LTTABP6OL TAB
LTTH B foolTA B Lpooltab poot
pmCdnq -ptr+ Sinu=
conSta nB. in a DC
Stdtementi. aSSemble he lite rals
in mcchune -C0 de-btfen

iterals
n) poelfab-pts-p 00ltab-_pts+,
o gs
-SMVS-
Page No.

Date:

TEa START DYORIGLV tute ment hCh


oCchty Valuc specihed in Op elard hold
Dsie =0
d a deda Tabon statemonb
)TE a DC State ment than
AsS Omble Hhe constant in machine-
Coce boltay
O)sice= Size e memnon axea eauired
by Dc/DS

(e an imperahve tate ment


Lú) Get operand addOAR frm SYmTAB
O L1TTAB

l)ASSemble inst y uchon in_ machine_cade


b elfen
( ) gize Sze nstu ction

Tcize Fo then
1) Moye onten O macline-co de -but#en
to theCddreA COde-areadddreLR
locct Y
Clb loc-thty E loC-Chtr tSize
Page No. SMVS-
Date 1
8Po cesSingfEND Stutemont
fertax mstep 2b) and 2
P)
6 Lont e
codearea into o utput l e
he aksemble pro
n the form d uc cD Dbj ect mod
at seq re d by a un lcaqGe
editox OY oade
AsSem blen
LOhi ch is th psoduce
e afargatpnara m
argeb_comp utes. machinelang uag s he

You might also like