SS 1,2,3
SS 1,2,3
~~ule1]
Introduction to System Software
SYSTEM SOFTWARE l) \1111lln1th111 ",11fflv11n·: Apph,,1111111 1.11Jlwure nlloW(
rntl 11· •·r tn it·• 111111111111 0111 or 111111c ,pcc1f1<. •11~k~.
(.lll~~
11 ll.'finl' '~ ,lrm
,til'lltion
"ifl"
,ofh11.rl''
RI'\'. I hi\\ ii I 1II
\hn 11,1 lhi• , ' ITl•, ,·nl
i\ppllrn11n11 ,ut1W,lfl t,wu~<' 011 ;in 11pphu1111111 or
prnhk1111 Jo hi' ulvcrl. 'I yp1c11I 11ppl1ca11on~ 111~luclc
1111 - 111 11
1 " ' h•111•,
m ,on\\Til't'. . uuhiRlliul a111nrn,11u111, hurnu'\' M>frware, cduc.illonal
"' . 1.
J ,, •
n, ,nllw111c. mrc11' ·11 ~oh ware. ,1.,u,ha~c~. ,,nd ('ompurcr
pr<flllf ""h N-11,r<'n \pplkntion \tlll11nn• and Sy~h•m l!;IJlll•~•
.i,11111n', llll lll 111,\I) l)lfflirrm·t• hclWl.'1'11 Sy~ll•m ',11ff>l'ltr1 and !\pplicali11n
Or
n {, ~'Sl!'m ,nnw1U"t' diffCl'l'nt ,·-,,, "iolhrnrc
'
" •v n111>llca1 io11 The fnllow111p lnhlc 1llu,11ar1 s 1he key 1.llffercnce~ hetwccn
dl'l1 rc? Or 120201 0JI) sy~1c111 ~ollware and apphcarmn ,oliwarc:
NII 'led '.Trrcncc.-. hchH>en S)~lcm Son ware and Table I: D11Tcrc11cc bclwccn System $fJflware and
~11lion Softwart _ _ __ _ _
MJP.'i."'I ,. ·'l '<li'hiare. (2019(04])
Busih for Sy,tem Software Application Software I
" ('.o:npl c ~ofrn are Com orison
-,:r.tt "' , ~re •s ~el c i •ns~clions or program.s Basic SyMcm Sof1wan::t\pplica11onSoft\\;;;/
{lat cc11a.n t3Sl.. on digual computers.
-'.'.i'!i 1J .:-art) manages sy.'>lcm when run, perform
~of Computer Soft-l'are
resources I
and ~pi:c1fic tas~. they arc '
provide~ a platform dc,igncd for. ~
--11.-a.-r .::- ti!:' ~ a:,,--'ied into 1wo major categories. for applicauon
~! st.er:' Son" are: S) stem software consists of 8 soflware lo run. ,
~ · nrograms that suppon the operation of a Language System Software is Application Software 1s
~ n he!p,- run the computer hardware and wriuen 111 a low- wrillen in a high-lc,c:I
.:amp.er ~ str:"11 System Software refers to !he level langu0ge. 1.c. l:inguagc like Ja\'3.
~ " f ,) ,iem .md a:1 utility programs 1ha1 manage assembl Ian a e. C++..neL \'B, etc.
IX ~ rec;ources at a low level. Run System Software Appl cation Sofm are 1
starts running when run, a,, anu when the I
SJstem software 1.., a 1enn for the programs 1hat handle the system is turned u,-cr re<JUe,,b.
!be ;::nmng of our computer's hardware. Examples for on. and runs till the
SJ>'.mn 5"wVare are Operaung system. compiler, s stem is shutdown.
l!SC!lihk:r. macro ~ssor, loader or linker. debugger, Requirement A system 1s unable Application ,oft\\J.re j,,
la! ed:lc,r. da1abase management systems (l>Omc of 10 run wilh0u1 el'en not required 10
system sof1ware. run the >) ,1c111: it i,
b 2:ld. software engineering cools.
11~e1 ~ cilk
These softv.are·s malce it possible for the user to focus Purpose System Sof1war1." i, Applt~~uon s,,tb-;in• i-J
Oil ao application or other problem to be solved, t-=-~=---~C:..:.'ll:.:C.:.:ra:.:.l•..cU=o:::se , ·ciftc- UIE£."-'
1,11hout ne{.-d°ing to know the dc1a1ls of how the Examples Opernting system. Microsoft Ofikt-.1
m:icii1ne work~ internally Components of system
'°ftware ~ shown in figure I.I
Physjg) Machmc
lPholoshop, AntmJllun
Soll\\ ,rrc. cl<'.
-
Qu~s 2) Gire lhe Classilicutinn of s~ , 11•m Son,, arc in
de1ail.
, J
and frc m II co111puk r
Unin~l:.illcr: An unimt,illc1 ,s a u1ll11y lhnt
An a~scmhler 1s a progr,un 1hat takes basic coarpll'I'
.
1n~1r11ctmns
' and ~·omcrt~ them into a panern
(brnm) <h!!llsl tb,11 rh~ computer· s pr<Xl'ssor caa
"~
rcnlO\C, a JllllfHIIH ..t\ well .• ~ ,iny :1,Mltlllll'tl fk'do1111 tis hus1c oprnutons. These mstrnc1ions•b0"
cntncs m the \ystem files. When vou 111,1al1 a as n.~srmbl)' hm1-:uni:e
program lhc opcr.tllll!! s, slc111 rt•cunl\ lhc Or
infonnauon ·1 u,c to run rile software 111 the An asscmhler is a progrum that accepts as .,,,. 111
system files. fhc u11ins1allcr deletes !tics ;mJ
11
a~:'~ ~hl:' languilgl program (source) and procflldl;
folder; from lht' hard 1.hsk, as well as rl!mows m,td11nc l,mguage equivalent (object code) along IYilb
program entries from thi: svstt:m files. mforniiltron for the loader. Assembler program co-
macms. assembler directives, and ins:ructions.
M ti I (' 5
I I \11 I/Jll11111~1•1
11\ld\lfl
'" \11 1111,·1111111, ti, hn~w1111• sy 1u11 pmv1cln progr.umnr"
I\ 1111 1.11 11111, lhul ,1111 111 It !In• ,111d rlchn •mg of
nrt"tfo cf lo> I' 1th I
fllllJI Ill" M,1ny U h lf'lrlll lfC ,,v "' .,, ,l111111g the C
.I 1v, 11d111g11111v 111 .,11 lu 11111c I nrl 1hc11 rrmovrng> l>ug
Ml f' lllfllltr,1 In 1, f.11111 ,n progr,1111, lo th cnurc pro,c• ol prutrilm
1lrvt•l11p111 111 rrof' 11111}' ur nl v,,n1111N •111 •c ,uul cffmt~
111 tlNt'll 111,l remove them m.,y .,lu, Ix- ma1lc ~• v,,nou~
,111~c lkhugplnv I I IWU Mcp rno<.C\S 1h.,1 begin, wlu:n
v1111 l1111f ,n r•1nr ., Tl' ,1111 ul" uccc~,1ul rc,1 c.,sc
l) 1J,·1r1111inu111111 ul 1h c~nc 11111111c ,md lnc,,1,on nl the
t.1,, an u111,11tu,•1t1111 to lint,,., 111111 lu,ut,,,. ,11,1•·c1cd ,·,11" .. ,1h111 th progr.im
lhf- ';ill<lll\ I) J>h <>f Juil.ll,.
1H' 2) I 1~1111,( 1hr crro1
Clo
h(' n dt1111I 11bm11 hnl., r ,nd hmdrr )J'~tc111 Device l)rlvl'f,
Prn,.:ruuuuer, c,m m,m1pular l/0 ut~rc, d1rcc1ly by
!:'\"'-
(lOltJ(O l )l r.:"dinr or wntmg the mcmnr, -m,,ppcd 110 rcg1,1e1s
However 11 " bcllcr p1ugrJmmong pr.iCIIGC 10 CJII
,,f rollc-.1111!l anJ ~ombming valious funcuons thul acccs, the mcmory,mappcJ 1/0. The>¢
imo •' ""i.lc lilc thai c.m t~ loaded
functions ure called dc~ice driver;
.u,J e\~tmcd I mkmg can be A de,1ce driver is wftwarc module which manage... the
~. "hen Ille source code i, 1mn~lu1c(I commumca11un with and the control 01, " ,pcc1fic 110
J tune. "ht11 the progmm is lomfctl device. or type of device It 1> the task 01 1hc device Jmcr
utc-J b) th~ ln:1tll!I', :md c1 en nt run 10 convert 1hc logicul reque~,, from the user into ,pec1fic
n>grJm,. On early computer sy,1ems. commands directed 10 tllc device ii,elf.
IIl3llu.llh· • On modem •>••ems. linking
~ f117.:::j""".11U,"' l~ b1 progmm, L'nllcd linkers,
For example. a user requc~t 10 write a record 10 a floppy
disk would be realised ,vilhm 1hc de1·ice dnver a, J scnc:.,
cru..131 rok '" softwlll1! development bet'!lu:.e of ac1ions. such as checking for 1he presence nt a disk in
0 SCN!l!!C ~0111p1 arion. lns1eod of organizing u lhe dnve. locating the hie ·v1,1 the dis~ dircctOI),
11., one monolitluc sourt:c file. we can posiuoninl!l the beads e1c
It -nuller. more manageublo: modults 1ha1
modified and romp1kd ~pard1cly When we change Qucs 5) What b mncro proees~or and tut t>ditor?
modules, v.e ,imply recompile ii and re-ltl)k 1he Ans: Marr o Processors
"'"---'--'- t1 IbcM h!l\1ng to recompile th<! olher files. A macro is a uni1 llf spec1fica1ions 1or program gencrn11on
through expansion. Ma,ms are spe,:i;u c0<k 1r:1gmem, !hat
of Uni.er arc defined once in the p, ogram anti ure used repeuu,·el}
I..:=lilr2 Loader: 11:o: 1,nkJng loadllr performs nil
by calling them from vuriou, plJce,. w1tl11n 1hc program. It
and relocn1 on operation, and linked progrum
1s similar 10 the suhprogrJm in the scn,c 1h;11 bolh cJn be
un:u 1he mam mcmnl) tor execution. used 10 organiLc the progr.1111 better b) ,cparating-out tlle
l.lnka;:e Editor: a 1ml age cduor produce u Iinked frequently used fragment ,mo a di1tcrtnt bkick Th~ m.1in
of the program called as a toad module or program cal I, this blo.:k oJ coJi: .L~ anu ,1 hen necdtd. B,,1h
= "---'=·le 1ma~e Th1\ load module I\ wriucn 01110 a of them can huve ,111 assor:,arcd hsl ot par,un,·,c~
.J) for l21Cr cxccu11on.
V =nic IJnJm. rlu~ linking ru,1111mc, the linking A 11111cm pro..-essor " " prvg.1,1m lhJI ,(1pies ., ,1rc.11n ,,t
~eu,11011 !l/l1C Any ,ub r,m1111~ 1, lomkd tc~I from 11nc pl,1L·c to a111ltlm, 111,1kmg ., ,, st,•m.111, sci ot
1hc: r \I ol tlw pmgr.un ,vhcn i1 " li11,1 1dflln,c111c11ts .,~ II 1ln,•s so, M.1~·m pn-.cs.,,11, ,trc otten
, 11 t Jlc<l tlyru1n11c lt1,uJi11g 0 1 lm1d on c,IIJ. cn1bcd1tccl 111 111hcr pn1gr,11th. ,1,,h a, ,Ncmbkr- and
compiler,. Suntclimcs lh••~ at~ ,1,1111l,1l,11w po.•~r~ms 1ha1
cnn be used 111 pm,·c,, ,111) km,1,,1 1c,1.
1 ut dll 111 •1,111111,' ,yMum It ,upics
u1,lny
from 11 1or,1gc ,It- 11, 111 11 ru111111111·1·s .M,11·111 1mKc,su1~ h11v1· hc,·11 u,cd f,,r l.111gu.1J!C .:~pan,ion
cmor) \\ lll'rC.: the protf ,,m rnu lhc11 h,· ,. irnu,•d, Cill'llnin~ m·11· 11111,•u,1~•· r,,11,11111"1> that""" b,: c,pri:ss~d in
Imler, loader, ,an ,ho 11:pl,1tc rn1U,1I .uldrc,Nc., tc,m, 111 ,·,1s11nr l,111gu,1gc co11npu11,•111sl. lor ,ystem,111c
1,·~1 rcpluw1m•111, thal n•q111re dcci,mn m,1kmg. ;md fnr
r I adt.ln:,,cs. Mo,t lu,ulch lunw1111 w1tl1111J1 us.·r
\emenl The} ,uc 1m1,iMc lu rlw m,·1, hu1 ,11,• ,, IC\I 1vlun1111111111: 1,· /!· <'llll,hlulnal CXlhlClltln ot m,1tc11al
11.,bk u1 ihl} Ill 1hc orernlllll;! ,y,1t·111 hnm :111 HI \II hit•).
<,.
~,
"""p,,.,.h,:, .,.., -
Cf'lnlptkr ,,. c.J.k C
"""fa,-""""'=
ccw:r,aua C.u::r-.Jc AD,- on
1hc 1d1111(' d.."JICndcru Jo 1rurc, n t "(!Ille' ~,,1
~11, "-111,, .i« Ar"C'
\ , , c.•mhltr: 1n,t111d 1nn lc•mmt. ,1ddn.'"ing ftlOOt'~
~,=
pl.Jffiwm X 12/ld J,'d &."t.dt- nan. . pbtlunn )' 'J C,H111>ll<:r : ttg1,1cr- Cnumt'C1 , lyr,c). Ul.1&:hmc m,trn._:11,11i,.
J1 n~: ·,II o f 1hc ,c -.oun:c, u t .1 co 111rutm)I' ~) , 1cm T
ln1t•rprr,~r
I l1:11rr I .$: tJ.'i It.lo /nlufau ut ') ,h.'111 ma1:htm·•
lntcT('lh'.cr o .inothcr CA..unp. t:- fc:1 ~c ~ lwl,.t'1 n t;.vr &, JJ,,rd*•rT
~"1111 .1, 1'4-·d , , uJh\~f\" 1ur
An lnlUpn:tcr,,. ttlw.trr: •luch CllfUffl • ~ , a aw lmft·fN:JUll•nl !hey 1tff
ntu:n ,n 4 lu¥h le, rl 1.uJGUJ .. nw o m.ac:lune k d c:odt for hlrd•ure luhi:tlf,,n ,,d, , mput und ,,..,,_ Id jJ ( ·,11 fjt l tlt· ,lj.'O 1111d lilj:l \' ol ,1,l"t"lllhkr.
h, Im I t n Uic J:-t,PI lf.lfm uf u.n ut~ 1ht fflffDtJfy i111',.o,llon. dirt ,,p.rJIIII~ ., ..tC'IJI KU • • Cnd, npUUU/ulltul 111 ,1 l"Ompill•I. .,ml
pu f,Jc: or tn.t I th ,ntc • ttr , C.Ukd • taun.:.c UJJaDw:dUI) t~UU~CfJ pmgt.Jln~ ,md thd cOmf'Utt'r ....... 11 f mLm,• ur 111drp1,•11dcm1ly ,1\\rlnt,kJ ,utt11h1gr.am1t-
, m th I cont , pre-. wnttc11 ,n • luPJ lt:td f,xur~· I SJ 11Jth11uyli the ,ipptn.,lfwu cutk a. . . . ,
M.l"l,l,tl'I'. Tttc, llR' u!ionl a., ilOngc l°"-'11tion5 und also
fl,c C (JC Cf lilt rn 1 •,:t I lnu.o .a .an ~.ua&:d du"df by UK' IUlt J\11,a,c omd "''IJ
lrC44ucadJ'. . . \o In 11111) •\ ~h•m ,1111\\lll~ II I\ ntlt".!l,,11\ ll• \.111\\,li, I~ .. ,
1,, 1,trJ,,rm etlUln 'l)«W IWK:ltum. Thero ma 5
In-
f'ltJCTM.111 I fil,!U ff" I.A
~ la HL,_Ob---'---''--']
fts:,un I •.,: I1,tcrp 11 f e r
,. ~~m ull w Mi <J", luffl t10f1 " ' he mct-m,,,,..,,
Op,:~t.mg f) m un he tootul ,m almou linf
u..n&iun • comJHlfer lrom , dltJI.M, 1tli111.e1 .,_,..J ridll
' ~ UJ "'l"'"'(,mp,m n .i.tld "°"ch M:l \ tt
m 1111w '"' h l lt'l 111/14 \ \ h tl 11 llll tulSt
lJ \f, mmy iod lkj,•l1lt'f\
'I IJ.at.1 10111111
h lu,1,u.i,;110 11 I 111111o1I•
"•"""- <11<h ol wlU<h 11 24 bila m lcnllb- Tallla 1.2
l"ffl below lllllica1es Ibo nlllllbcn, ..........
_,uflhnc .......
urJ,,.......I!"-----------.,
C-S 1
iii )Cond_itio~~ Jump instrUCIIOOS test the sc occ the ;1sscmblcr d_ocs not know the uctuul 1
Tabl~ 1..2: T,
( ond1uon 3 cod< and JUntps according]~ ~\,en: the program will be lauded, it cunnot nu~kcouon 3)
conJ1uon T Jl::Q. JGT. ' , ·tf) ch:mgcs 111 the nddrcsscs used by 11 c lhc
.\lncmonic Sumbu
A 0
,-arnplc. JL • . oc.,; ; .~,•cr. the :.1sscmblcr c:111 ident ify.for the 1; 11
11 ..is uf th!! obJCCt program tluu need modificnti . lhoi.c
s;~grurn
. CUil Jnstruct1on: _1\v~ ins
on
X loda nerisft:r: ..,c,J 1~v .-.l....4T----.:.r.,: 1, 1 Subr0uu n_~ 10 .,,.rfom1 ,ubroutrne hnkagc, 11
,11..
an, pro' 1dcu r 4)
J.inJ..:u?t rt;:istcr ..,-t-J "1 (\'Q."\..,l
L
:i
l 1sUB: To Jump \ll obJL'Ct 1~rog~un Lhat cont~ms ~he in fo nnmion nccc.."i,
I
1
t-..n, fer 10 ... err the rrturr. " ~
RSUB: To Return . i{onn llu.s k1~1d ~r mod1ffon t1on is called a reloc:b~o
a f tbt' ~ 1 1n:-uu,:uon - P" ,r,un. L1kcw1sc. if we londcd Ute program be•• . e
PC p ~ Counter ('l.~t.tir. " the In bOth c.:t•C!! the return 3ddress 1s stored 1i1'>£ " 742O, U1c JSUB ms1rucuon· would need be olllrung nt
~ t'i.:,i;:.\.I <ru,'1?ll.'1t1.'t'\: :,dd"'- 10 chnn e
er C\ 0..'"\1i...:n
ldcbed
re!!1,tcrL ,o~B JOS456 to correspond 10 Ute new address of RDREc g d
St2rus word a..,o:,t..::::" 'w,"'-'
- d ouipul Instruction: Input
SIi
nforn.tJoa.. -i.:lud:ir.~ _ C,~u.:-n ,l Input :m~r.iuons arc e,ecuted by traosfc Nott that no mnuer where Lhc program is loaded, RDREC
Coo..:,CC• Ourp,utbo~ e.1ch time. The .target pon is s i~ always 1~36 bytes pas1 the starting address of the
!-Ul"'C \,t: Ea
The"e fl\ e rc21 , ter,. :tll~,l W SIC n.1.:hJn(' tl, pertC1rm
-b, 7he1~ 1 s bits of the register A. ch de r0grnn1. Tins means. thal we can solve the relocation
ma .. t .. ,mple U,l..., I" .1 .......,w- ~ .:..,~o." .~ ~g\l.!.fC' 3..~i~ed 3 umque S bn code to send and ~roblcm in the following way:
In the s~ ~tc:m Sofru .m:. :hi,; .. L-.("C ~\1th.:. :J1cctto;al (b13-.ind rontr0I ._ ,gni b . 1l \Vhr.! n ~te ass~mbler gt!nera1e~ the object code for lhe
~enc, of opcraucm rode-. ro ,;,.id m the unller-::~,J.ui_g JSUB mstrucuon we are considering, it will insen the iQ Fonna1
The Te.,I Dence lTD ) ms~cti_on_tests or c
of a....-'-Cmbler- .10d l::lcr- ~ ~..:re-J for :he address of RD REC rela_tiv~ 10 the stan of the program. Code, next foor for •
on \\llether 3 gi,en UO de,,cc 1s m ready
C\.ecUtJ('I- or ...,x:n!::lh Ll.'1g"......;.: ~ n us 1s I.he reason we m1tmhsed lhe location counter for register 2 11te
~d or rece,, e d:it:1 from the com puter.
10 Ofor the assembly. according to the no
·31 Data Formats: The , a.n=d SIC -ruch!n< ..upport> 1;t11e mll!-t be muoduced m the program •
the registers section U.e
on1) th, lntegef'- .::r...1 Clua.rac-..er ....,.i..:a fo'i:"..ll!> There i~ de,,ce £Cb read: for acrual data transfer. 2) The ass~mbler .will_also produce a command for hex 5, F_isrcplac«11>ybQ-6)
no hard\\~ to <.0pport [he -r\-,.,.;il"lf:-p('tnl r::i.-nbcf'. DlLl ,RD1
311d Wn1e Data (WD) _ are used lo loader. mstructmg It to add the beginning address fo
Sbll 4h11
3nd \\THC d,u from or to the specified UO de ,he program to the address field in the JSUB
@pcodc I Re21S1,r I j ~
lntccer. ~ , torcd ol'- .:.: bit b ~ n:unber- ="~Jti\C
,clu~ ~ rqm:-.e-1ed .i, : , ro~'c~nL C~cter instrt1ction at load ti me.
_ Input and Qurput: Input and Ourput are perfo
dat.1 are ,ton:d u, .,: ~r " t-- t .\SCII rode~ For example, COMPa
n.mstemn!! 1 b)1C JI a :ime to or from the rigb Ques 11) Discuss SIC/XE mnchine architecture in detail.
~, Instruction Fonnn."-: ~ - .ach:ne z::.;::-J.:ooc, m the b::.s of iei= .~ tJCCllillul:llor). The Test Device contentsolrcguierAlltldS).A,,S (0..-, ..
Or
,t•ndanhcr- of SIC !we the fo!lo".n, : • b:t fa= lflS!l1lCDOO tJ:SI,. whcth"1' the addres.<ed device is read Opcode A S
\\1'31 are the various addressing modes supported by
sen,:I or "'''""' a byt< of data. R<ad Data {RD), s1CJXE? With the help of an example, explain ho\\ to fmd Dow 0000 I0000 t o1
t:p.xdc J; .a:1;~
D-""i\\'Di arc u.sed forreadinz or writing the data. 1nrgel address during assembling in each case. (2018 [09]) iii) Fonn~t 3 (3 Bytes) t =
The fl .ii ~ ,. 1.. u ~ u, m:!1a.tc: tie mde,ed Or operauon eodc, next 6
Jddrr~,me >Cle 01 Data )!o,emenl and Storage Definition: b11s contain displ
STA. LDL S1L LDX. STX (A - Accum WiUi reference to the standard SIC/XE model, discuss the
dal:i ronnats, instruction formats and addr~g modes. operand
51 .\dd~sing \fodes: SIC <.. ppo.-:, rv..:t rype, of L -1.mkaer Register. X - Index Register). all u
J.Cfd~v•rn!!m,)(fe-,,. b,,e ~orcl LDCfL STCH associated with ch Or
Dircd Addr~i~ \lode: r.. mi~ mock the fla!! u:.C~ l-b:1e. There are oo memory-memory \\'rile noles on lhe architecture of SIC/XE. (2017 [041)
bit , = 0 Here the tarfe' s.cHre-,.-. ~ <pectfie.:I b; instrucoons. Storage definitions are: Or
•.he .ietuai .:i.ddrc: , De u:mrwcuoc 11--..e~ 11 WORD-0:Sl:-l\'ORDCONSTANT Explain with suitable examples, how the different
uJ RES\\ -0\"E--WORDVARIABLE insl ruction formats and addressing modes of SIC/XE
11/ /nde.u,1 ~ddressin:, \fode: Jo th:, r.iodc to< fl?!!
"1 = 1 Hen: the- L?J1::t Jddre.., .. compJ:af
l.
.adding .1k! -:.~ .iodd.rc-. ,peo!jcd an
0;
mw..:o.m lt)I!
wJ BYTE-0:S"E-BYTE CONSTANT
"I RESB-0:,."E--BYIEVARIABLE
are handled during assembling.
Or
(2017 [OS])
:llld the OOlllcllt> o( c!>< fudcx Regis,,,r I X J Lisi and explain th e dilTcrcnt addressing modes and
Talilir J.J: T \ fk? tJ( A d d ~ !\fodo illSSC Ques lOJ II bat \\ill ruippen if a SIC program is I instruction formals used in SIC/XE architecture. (2019[0S])
\ddn.•~•..ID 0 l\ lodt fug Hit J ...r:?d .\dd~ in a location dilferent from the s tarting ad Or
D,ru:t TA - Jdrc:u specified in th e program? II ill the program ., Explain lhe architectu~e of an SIC machine. (2020[05])
JnduL-d TA=~c--.i. ... X proptrl) ? Justif) iour ans" er. (20191
, ok: P.Jcnlht:,1, re p ~ the i.:oo!aru. uf .a r~g; r Or Ans: SIC/XE Mac hine Architecture
or nl<.:mOf) £ 1plain "' jl.b an tumple bu\\ relocation probl nu~ is same as SIC with certain additional componems
hant!Jtd IJ, • n .,,,..mbler? (2020f and features. XE stands for Ex tra equipment
J11 .. 1ruc1io11 St:1 : T1lC' Lommon mp u: : arc Ii Memory: Max imum memory avail able on II SIC/XE
a1;:complJtj']c:d u,mr, lhc m I.tu' on t-cl pm,.dc.d /Jy be ,y,tem is I Megabyte (220 bytes).
Am 1r.iblt: 10 h;nc more Lhan one pr
51( m ~me T m ~l)flelo '1 ructi !ICU,i:LJ'c
'!lu mm.m:-<d .'l ft,llow 4 memory c1J1d other resource 2J Jtcg:Mcn,: Addi tional B, S, T, and P regis10r.. nru
J DJta 1 r.in .. ft-r In,lrunioo : TI1c m 1.d m ad\ancc ex.ac1Jy whjch provided by S!C/XIJ, in uddit ion 10 the n: e1siors of SIC:
1m1ru1.lJ011 lf .ii Lc.;;,d and ~ or. rep tcr for
v,1.c.urrcni ly jn thh way, \fncmonlc ~lllh!:,! _ Succlul u,e
,-.1mplr,Ll1A LDX SI A Sf )( n lJu; progr,mh were a\\CmbJ
II J Bus~ !!!JIMer
r \oo-1Ul,>ul tJYcrfap or w~led \J
·\rilhmtlic OptruUon lml.roction: The b ll \ 4 _ Ciencrnl wor~c,u 1111er
Jt1th mcl1t opt:t Jl 1t,11 , 11 he d ,nc t ,ctj m,oh ·, - 5 C,entirn l workl '!l 0,__j_lMC:r
M ' 11 tm,c tt',~ 1 r 11 J\ nc,1 pracucaJ to phm
rq~1...,1c:r A I or 1.·1.umph:, ACJL \ l. O '1 Ll )• I, JflOJIIIJlg· pOlnl uccumuliuur
t" ct: twn 'JI ' ly -'•C' u u;.i!Jy de, no! knCJw cxaclJy
1)/\ ('(J\1J> C4K hlla)
J ;it \lo II I,. Lfw11t::... e ,.u;lly ti,,w lr,nr thcy WJJI run,
,. B T~h. r,Oh Scn~7tr• • -
1\,xi ~1.,n"c .,dd~,,1111_! 111odc, are av .
11111""""
11111111')'
C-10
fom1nt 3 ,n,tnicnon. JnM\ittl_! cmmot be
nilab1, l'I\Jgllllll
11 I X b I' C
dl1p/at1drr11 6) I
b) ea.~ (ii): lf 1 = 0. n = Jworo ~\'Cl\ b) t;tq:Cl , n cd1;1tc (Ir 1nd1n.-.:t ndd~,,mg modes "~•ii.";' cu1111ter
· · The ,~•111 )telnllVC 0 0
a ~ IOC.'ltion ,~ fctchN and uluc ,n "'ml 01 1 JdJi,:,,1111_! 111,iJc, no::
rclnt1\'C () 01 IOCKXKJOIXX, loaci llltl
1, talcn a., add= of operand ,3Juc Th•' "
called ~1ndittct Addrec<>inJf 1mmcd1ntc
Add=.~g is indicated b,, prcfi, .
Ba-'<' RclalhC
..\ddrcssini: \lode Di,placcme~ttcr.
between o10 4
I
IJei
Indexed.
Addrcssmg I I I I O O 0011 00000000 ii)
.__~
addn:s,. t\ the Jocanon of operand. Tot, i> ~ + (PC) 15plal.'tllleii
furgcl Address
TA = (B) + (X) + disp I) ADDF., .... ..
called "Simple .\ddressinl( Noce:"P"
PC-progrn t = 006000 +00090 +300:: 6390
T ..\ = Lootion of operand b=O
P=I ~ll,placcmc::: ~~unter For~
I\") Format 4 (4 Bytes) e = 1: lt IS =e :15 format 3
Program Counter signed integer 12 bii With reference 10 the given, in address 6390 the val added ,,.. Ace -
wrJt an e~va =. hex digits (S b11>) for addrc<--C> Rclathr .\ddrCSSing
1 aded in the regisler is OOC303. ue lridJ~
\lod~ Displacement lies
tha! reqmre mo:-c than I:! bus to be rcp=nted ~rogrom n i x b p e disp/addrcss
~ ...... a....._
___ ____
bciwccn - 2048 t ~ Counter iii)
6t,,: I bll H,n i b11 J b11 I !,n I bit 2'lb1t
Opcode ~ I r
b l p e :,ddrz,,., _ O TA = address Dtld or
b =0. P = 4 format 4 Relative I O O O I O 0000 001 J 0000 RMo-~ .._,_
\.. .,)
(Foano~ instruction Addressing ~sCOIIQ&•- .
y msuucuoo~ TA = Displacanair iv)!ll!trncUoa WW. ..... .,_
Aai; bits DiN,cl Addressing
b = 0. P = 3 field ,·aJue or Target Address
Mod• TA = (PC)+ disp
Realster~~ 11
For example. -JSLl3 RDREC jump 10 the (Format format 3 a) ADDR bJ S1J11R c, 1aQ
add.re-, !036 instrUction) instruc:tion 003000 + 30 = 3030 Note:~-~~
6ba I I I I 1 1 .:!O TA = 'Displacement +
ba bi1 bo: ·bit 'bll 'bit bit (B) + (}.') With reference lo given above, in address 3030 the ForQaoiple,ADl>RSJI ........ . _,
0000 JO 0 I D , D 1 0 , J I OOOOOOJI OOOO!IOll 0110
b= l. P= o B -Base re~ ter value loaded in the register is 003600.
0pa,ac C X l, p C BasrRelatin s -----------
•
6 Oh;"1 Inc!ued Addressing
X - Index register
Direct n i x b P e disp/address 7) n:gi.ua
lnpat111110...:-.SIOJE
B 0
Code 1\!ode Addressing
IX=l D1splacemen1 1s 12 bii illStlUcticxL\ ia fie - - - - - . .
5/ Addressin,: Modes and Rag Bits: foe possible unsigned regislcr. 0 I 0 O' 0 0 000000110000 samellleCflaaaiab!IIJll• -... i.
this, tbcn:-specjal i o ~ lllirl
addressing modes plus the comb1ru.uon~ arc ai.
follov.·s.
,) Direct (:t.. b, and p All Set to 0): ()per.ind
ltddrcs, g~ :,,. ,1t 1' n and , are both <.e1 to the
same ,-:tlue, either ,o or ,t V.'lu.le m generd! that Program Counter b =0. P= I
I
Displacement
between Oto.1()95
TA = Displacement +
(PC)+ (X)
PC - program countu
lies
Target Address
TA =
=
displacement
30
~-die--
fordaia"---•ou
associared 1/0di:lias, 1-caa lie•
l/0 Chanacls - . . .
dcvi~ The . . . . "' q
Rdalhe Inde•ed X - Index Register Program n i x b p e disp/address
".alue" I, tf ,.er 10 0 for formal 3 one can ..,,ume byacbanncJii~'1•
Ad~g~!ode D1splacemen1 is 12 bit Counter
that !he rc.,1 of !he flag, (x. b. p. :.od e) arc u.ed D111 <RD) and Wdt-
X= I signed integer
a., ~ p.ltt of !he ;,ddre,s of !he opcrdlld, to mal.e Relative 0 0 0 0 0110 0000 0000 writc dala froaa
Displacement lics
!he format comp.a,blc to !he SIC format between - 2048 to 2047 Addressing .§!Q
1i) Rdati•e <Either b or p F.qual to I and !he JlO
Other One to OJ: The llddrc,~ of !he oper..nd The gi, en below shows the contents of regisiers B, Target Address .1{10
l>bould be Jdded ,JO the current value stored at the PC , X ;ind of ~elected memory location TA =(PC) + disp
B rcgislcr (if b = I/ or lO the "aluc •torcd al the = 003000 + 600
PC regi,1cr (11 p = I/ 3030 I oo36()(J 1 =3600
ui) lmmediak (i = 1, n = 0/: The open.nd ,·alue 1, mi = 006000
3(1J(J I 1()3/JOO I CPC/c: With reference to the given nbove, in nddress 3600 the
:Jrc:ady enclo>Cd on the m,trucuon (i.e.. '1tc:• on value lauded in the register is I03000.
003000
!he fo.<I l ')J].(J b11!. of !he 111,tructwn). Dirccl Addrcs.ing n I x h p c dl,p/address
CX/
IV) lndirtod (j = (I, n = Ii: The opcn,r,d v.alue pomL, (/(JOO'JO I 1 0 0 0 I 0000 1100 OOl I O(l(l() 001 l
10 :in ;uldrc,ss !hal hold, me Slddrc,s l<,r Ille 6391J I ()(_)(. lQ3 I
I-
opcr..nd value Turgcl Adclrc~s
('3(JJ ()(/3(/3() TA ~ cllsplncement
v) lnd1:u:d Ii. = J 1: Vli.luc 10 be added to the value
0C.103
l>IOn:d 31 the registu x 11, obtain rc.d uddrc•• of
!he opennd. llui CIUl be combrncd w1ll1 lilly of
1he vuluc lo11dcd In lhu 1ullls11,r for 1h11 uddross 0CJ03
C-14 S 10111 Sofiwurc (Module I )
B.Tcch. Fif\h Scmc.,tcr TP Soli-ed Series (Sysicm Sof\w11rc) y~ -
- ~ .,.,11011 to
C-1 5
COMP K.100 COMPARE NEW INDE.\: V . Jnll',J --=--i;ATA STOREDYTETI IATWASRTu\o
instruction will be the second byte of SRT! and the urgel TO JOO 1\1.~ S'fCII Program 11
•
addrc.ss for the STCH instruction wiU be the second by1e
ofSTIU. ADDLP LOOP IF INDEX IS LESS 11.i ••.
JLT SIC/XE: Sample SuhrouUnt Call ond Rttord Input OprnUoM
300 - -~ oUTDEV TEST OUTPUT D!!VtCE
TO oUTLP LOOP UNTIL DEVICE JS READY JSUB RI!AD CALL R1!AD SllBROUT!NE
The 11,"\'. instruction will ag:tin add Ito the v:uuc in regis1er ONE-WORD VARlABLE JEQ DATA LOAD DATA DYTE INTO
!INDEX RESW I l'O~ JJ)CH REGISTER A
X and the loop \\ill contin"i.e in this w:iy until :ill 11 b)1CS 4'1DEX VALUE
have been copied from STR I 10 STR2. ARRAY VARlAB - oUTDEV WRITE ONE BYTE TO OUTPUT
WORDS EACH LEs-1~ \VD DEVICE
Program S
ALPHA RESW 100 SUBROf/llNE TO READ 100-
_SI C : ~11!<_!-oo- · BETA RESW 100 BYTE RECORD
1tions
LDX ZERO
_ EX REGISTI:R GAMMA RESW 100 IRl!AD LDX #0 INITIALIZE INDEX REGISTER
MOVEcH lDO! snu. X TOO
LOAD OiARACTER FROM
STRI INTO REG A
ZERO
K300
WORDO
WORD 300
ONE-WORD CONSTAN"fs
~ X'05'
oifll)E" ~B I
BYTE X'Fl' INPUT DEVJCENUMBER
OUTPUT DEVICE NUMBER
ONJ!,BYTEVARJABLE
J LDT #100
RLOOP TD
TOO
INlTJALIZE REGISTER TTO 100
INDEV TEST INPUT DEVICE
I STCR SllQx STORE CHARACTER INTO 11lREE WORD 3 oA'f/1
JEQ
TIX
snu ZO) t~-pJain the subroutine call and record input
RLOOP LOOP IF DEVJCE IS BUSY
El.EVEN ADD I TO INDEX. cm!PARE RD INDEV READ ONE BYTE
Progr.un8 oues . ns ;0 SIC aod SIC/XE machine. INTO
RESULTTO II SIC/XE: 5,unpl• Looping and Indexing Opernlions opCr.,UO REGISTER A
JLT \to\lEaf LOOP IF INDEX IS LESS LOS 13 INITIALIZE REGISTERS TO 3' STCH RECORD. STORE DATA BYTE INTO
THAN II : Subroutine Call aod Record Input Ope~tions. X RECORD
LDT #JOG 1NmALJZE REGISTER T To 3~
LOX Ii() INTT!ALIZE INDEX REG!..,,__ ,iJIS following progr.uns shows the, bow the mstructmns TlXR
T ADD I TO INDEX AND
TOO " '"" '!It• sed 10 read a I 00-byte record fr!)m an input device COMPARETO 100
ISTR1 ADDLP LOA ALPHA. LOAD WORD FROM ALpu.
cnnbe " · · th.
. memory. The ~ad opern~on 1_n 1s example is placed
BYTE C TEST II-BYTE STRING JLT RLOOP LOOP IF INDEX IS LESS THAN
Sl"RIXG CONSTANT
X INTO REGISTER A "" ,nio brouline. This subrouune 1s called fiom lhe main 100
ISTIU RESB II I i-BYTE \' AAL\l!L.E
ADD BETA. X ADD WORD FROM BETA il1 ' su111 using the JSUB instruction. At the end of the RSUB EXJT FROM SUBROlJTINE
STA GAMMA STORE THE RESULT IN RSUB instruction, which re1urns
ON&WORDCONSTAI\.S . ;. WORD IN GAMMA A P"'grn ·ne there ,is an
ubrou1t . th 'll
!ZERO WORDO
ADD 3 TO INDEX VALUE ~uol lo the instruction nt ,o ows the JSUB.
~ _\\'ORDJI ADDR S. X
CO~IPR X. T COMPARE NEW INDEX VALUE
T0300 READ subroutine iiselr consisis of a loop. Each
Program 6 sbo-., the same loop as above for SIC/XE. ADDLP LOOP IF INDEX VALUE IS LEss INDEV BYTE X'Fl ' INPUT DEVICE NmffiER
JLT ~~ution f this loop reads I byte of data from the input
~ mam diff=cc tS that lhe instruction TIXR is used in THAN300 . . The bytes of data that are read are s1ored in a !(JO.
ei1cv1ce. IRECORD RESB 100 100-BYTE BUFFER FOR INPUT
place of TIX.
ffer area labelled RECORD. RECORD
b)IC bu
Program6
ARRAY VARIABLES- JOO
WORDS EACH Program 10 Ques 21) Consider tl1e memory contents shown io the
SIC/XE: Sampi, LooDinl! :1.11d Indcxiw, Operations
11'TI1AUZE REGIS1:ER TTO 11 ALPHA RESW 100 SIC: Som pl• Subroutine Call and R<eord Input Operations follo\\ing figure: (2020[04D
LDT ~11
LDX =O i?sTilAUZE INDEX REGISJER BETA RESW 100 - JSUB READ CALL READ SUBROUTINE J
TOO GAMMA RESW 100 (X) 000090
MOVEOt LOCH STRI . X LOAD CHARACTER FROM STRJ 3·030 003600 (PC) 003000
NTOREGA Ques 19) Explain the 1/0 operations in SIC and SUBROUTINE TO READ 100-
(B) 006000
STOf STIU. X STORE CHARACTER INTO S'llU SIC/XE machine. 3600
ADD I TO INDEX. COMPARE ' BYTE RECORD 103000
7lXR T
RESULTTO 11
Ans: Input and Output Operations IRE,10 LDX ZERO INITIALIZE INDEX REGISTER
TOO
JLT ~OVEC: LOOP IF INDEX JS LESS THAN 6390 O0C303
H II Progr.un 9 shows the example of inpul and ou1put on SIC, RLOOP ID INDEV TEST INPUT DEVICE!
1bis program fragment reads l byte of data from device JEQ RLOOP LOOP IF DEVICE JS BUSY
C303 003030
Fl and copies it 10 device 05. The actu:il input of data is RD INDEV READ ONE BYTE INTO
C "TEST 11-BYTESTIUNGC ONSTANT REGISTER A
ISTRI BYTE
SllW'.G
performed using the RD instruction. Executing the RO STCH RECORD. STORE DATA BYTE INTO What would be loaded to register A \\ilh the following
.
:STR2 _RESB Ii instruction transfer l byte of data from this device inio the X RECORD inslruclions?
.!HIYIE VARIABLE
rigb1most byte of register A. Before the RD can be TIX KIOO ADD I TO INDEX AND i) 03C300
Programs 7 and 8 show the eitamples of loopmg and executed the input device must be ready to transmit the COMPARE TO 100 ii) 022030
mdexmg operations. data. JLT RLOOP LOOP IF INDEX IS LESS THAN
100
RSUB l!XJT FROM SUBROUTINI! Ans·
011.)o
Program 7 Output is performed in the same way First the program
i\lnchinc Instruction Value
SfC: Samo!• Looping and 1Ddain2 Ooerations uses TD to check whether the output device is ready to
Loaded
LOA ZERO N1TIALIZE l]l;DEX YALUE TO 0 receive a byte of data. Then the byte to be wriuen is Hex Binary
into
STA INDEX loaded into the rightmost byte of regiMer A and 1he WD l~D[;V BYTE X'rl' INPUT Dl!VICI! NUMBl!R op n I xb pc dis1)/nddres l 'nrRCI Reglste
IADDLP LOX INDRX LOAD INDEX VALUE INrO instruction is used IO transmit ii IO the device, The same !Ru:rnm RllSB 100 100-BY'l'Il UUflfll!R f,OR INPUT
REGISTERX s udtlres r .\
LOA ALPHA. X LOAD WORD f'ROM ALPHA procedure is used in SIC/XE. JUJCORD ~
ONB-WORD CONSTANTS
INTO REGISTER A IIJ I(() WORD (I 03C30 00000 1 11 I 0 0 0011 0000 6-190 OOCJ03
ADD BETA.X ADD WORD FROM BETA Program 9 0 0000
,~l!'I WORD 100 0
'-- .
STA GAMMA. STORE THE RESULT fN A WORD SIC: Sample Input and Output Operali<!_ll!'
X fNGA,~MA IJNLOOP TD INDEV TEST INPUT DEVfCI? 022030 00000 IO 0 0 I 0 0000 OOt t 3030 103000
i'rogru111 11 ,hows lhc s11111c Jcchnlquu us ubovc ror 0 (l()(l(l
LDA INDEX ADD 3 TO INDEX VALUE JEQ INLOOP LOOP UNTIL DEVICE IS Rl!ADY SIC/Xii.
.ADD TH RD JNDEV RF-AD...QNE DYTE JNT.O~
;::=------== ::: - 6) Write o sequence or instrucU
Q'J: ,\LPI-IA equal to 4 • BETA _ ;ns ror SIC/XE vr,
1 and BETA ore delined ns In • Assume U1nt
1otJJf,\
> -• intc addressing for the constants program. Use ALPHA
BETA
RESW
1J11"'"' . RESW
. ,\ ssemblY Code GAMMA RESW
,\"5• LDA BETA DELTA RESW
LDS #4
Assembly Language programm ing a MULR S,A
Qucs IO) Write a sequence or instructions for SIC/XE
Assembt llct SUB #9 to divide BETA by GAMMA, setting ALPHA to the
~
STA ALPHA value of the quotient, rounded to the nearest Integer.
Use register-to-register Instructions to make the
S'tj
m1110hsc indc•., n,gis,
calculation as efficient as possible.
LD:\
Ll)Cll "°
LOCl, X 103d chor from LOC cr1o 0
RESW
SIC ~ND SIC/XE ~1ovECH
STCH LOC'l. X ,,ore char ,n10 L ~ lo "I ALPHA Ans: Assembly Code
TIXR T Jdd I 10 mdc.. com >. LOA BETA
PROGRAMM ING EXAMPLES JLT \IOVECH loop 11 "less <hon• f:"''°ll
15
7) Write SIC instrucUons to swap the values or OIVF GAMMA
(111 ..,., and BETA. FIX
Q ues I) Assume lhnl 100 words of dab arc stored BYr£ c ·m.1,.1;,tcr of computer .1pplications ~Ll'- STA ALPHA
from LO C l . \\ rite a SIC program to cop) these words LOCI ,\ssernbly Code
RESB 31 A,,s:
to another location in memo11 Slllrtiog from LOC2. LOC LOA ALPHA
Ans: Ques ~) Suppose that ALPHA is an arra STA GAMMA ALPHA RESW
LOT •.;1 words. \\ rite a sequence or inst ruction for S~ or IOQ LOA BETA BETA RESW
uutW1sc ~-ttcrT 10 31
LOX CIO STA ALPHA GAMMA RESW
iruo.ali-.c Jndc., recuJcr to 0 set all 100 eJe111ents of the nr roy to 1. Use 1• C/)(c to
\IOVECH LOCH LOC'I.X load chu from LOCI 10 re~ A LOA GAMMA
addresSing and register to register instrucUo 1111Dtdi11, STA
STCH LOO. X '10rC dt.r 1010 ~ BETA Qucs 11) Write a sequence of instructions for SIC/XE
TTXR T :dJ I lO mdc't. c o ~ to 31
process.., efficient as pos.tjblc. ns lo lllakt
Or to clear a 20-byte string lo all blanks.
\1O\ cCH loop 1 l"Jcs, mm· 31
JLT
Let ,·nmER be an army or JOO words ALPHA RESW Ans: As.semhly Code
LOCI
LOC:!
BYTE C JOO Word; o...•
RESB 31
sequence of iostn1ctions for SIC to set all 100
Wr11t a BETA RESW
RESW
LOX ZERO
of the am!) 10 I (20tlfllleab GAMMA LOOP LOCH BLANK
Or l7[05JJ STCH STRl,X
Ques 2 ) Write sequeott of instruction for SIC to copy Write an SIC/XE program lo add the eletn Que! 8) Write a sequence of instructions for SIC to set TCX TWENTY
from STRJ to STR2. array ..\.I.PR.\. of 100 words and store thetllts_or II ALPHA equnl to the integer portion of BETA .,. JLT LOOP
Ans: Le, the <mng ,, ·'JtST SlRl:\G- 'The leogih of lln.s GAMMA. la (;:"-'11
20[04b
GAMMA. Assume that ALPHA and BETA.
<tong " I I mcludmg blanl. character be:\\ ecn the 1wo w:Assembly Code
"onl< -n:srand -STIU!'1o- The =ne :ilon!!\\1liJ Ans: . LOA BETA STRJ RESW 20
lengih c-Jn be defined a,, ,J,o,;11 bclo\\ - • BLANK BYTE C ..
LDS ;3 DIV GAMMA ZERO
STRI LDT # 300 STA ALPHA WORD 0
BYTE C"TEST STRl'G
TWENTY
I.E.'\ \\ORD WORD 20
I LOX # I
The above ,tong should be copied into anolher smng sa) ,\DDLP LOA ALPHA,X
ADD BETA.X ALPHA RESW Ques 12) 3Write u sequence of instructions for SIC/XE
STR2. So. ,,z.e of -.irmg STR2 must be 11 and can be
declan:d a, ,ho" n belo"'. STA GAMMA,X BETA RESW lo clear a 20-byte string to all blanks. Use immediate
STR2 RESB II
ADDR s.x GAMMA RESW nddres.sing and register-to-register instructions to
COPY START 1000 COMPR X.T . make the process ns efficient ns possible..
FIRST STL RETADR Sun ID< retum :addres, "tudi "in L JLT ADOLP Ques 9) Write a sequence of instructions for SIC/XE Ans: Assemhlv Code
LOX ZERO X=O to dilide DETA by GAMMA, setting ALPHA to the . . LDT #20
LI LOCH STRI.>. LI A=STRJ IX ALPHA RESW 100
STCH STTU. X STR2!Xl = A
loleger portion of the quotient and DELTA to Uie LOX
BETA RES\\ 100 #0
TIX LE..,_. .\ = X~ J rtmoinder. Use r egister-to-register instructions to LOOP
GAMMA RES\\ 100 LOCH ffl)
JLT LI IHX<l..E.'G, pu, LI make the calculation ns efficient ns possible.
LOL RETADR Gd th<""""' >ddrns uoo L
STCH STRl,X
Ques 5) Wrile a sequence of instructions fl Or
RSUB ~um lo O~ TIXR T
ALPHA equal lo the product of BETA and \\'rite n sequence of instruction for SIC/XE to divide
STR I BYTE C'TE.ST STRJll;G JLT
LE./1. WORD II A~ume thal ALPHA. BETA and GAMMA. BETA by GAMMA ond lo store list integer quotient in LOOP
STR2 RESB 11 !LPHA and rcmninder in' DELTA.
ZERO WORD0 Ans: ,usembl) Code (2017 [03])
RCTADR RES\\ J To """' lhc rdum ;.ddrc:,, STRI RESW 20
Es;D FIRST
I.DA BETA An;: Assembly Code
~UL GAMMA
LDA BETA Que.~ 13) SupllOc'iC that ALPHA Is on a ~· of 100 "'lltd.~
Ques 3) Wrile a program for a SIC/XE machine to
STA ALPHA
LDS GAMMA IL~ dcflncd In pro,:ram 7, Write n sequence of Instructions
copy a siring "master of computer appHation\" from DIVR S, A for SIC to set all 100 clcmc11ts of tho army to 0.
I, OCl and lo LOC2. STA ALPHA
ALPHA RESW Ans: As.~cmbly Code
Ans: MULR S, A
81::TA RLSW LOS LOA ZBRO
LDT #J l rn111ah\C' reg-i~l 1011 RllTA
GA~~IA RLSW SUOR A, S SI',\ INOli)I.
,DRl~T,A J.QQC
I
C-lH
o T«h. r,rn, Scmr,trr tr Solttd Serles (Sy•lrm Softu,"•rt) lt1\J " Pmam111111l11n 1111d A~1c111hlo11 CModult 2)
,ly 1..an.•ion••
,\Utlllt
LDI\ I.DA INDEX
ll:.RO C.19
STA ,\J,J'llA, i..
ADD #)
IVRRl!C wx Zl!RO
COMI' l.hNGTl l 10 LIYr
LOA INlltX INDl'X \\'l,001' 0UTl'U1' HIOO
STA Jl!Q WLOQp LOS
Al>n JIT Otm R #(}
TIIIU.L LDCII HLOQp
10 IU!CORo,x 'fl)
~"l'A »-DL\ ARRI RI.SW
WO INOJW
<"OMP LF.NGnl WORD 30 ou1·rur JP,Q J(J.QOp
l(l(J()
WORD 0 TIX Ll!NO'n J
TIX lNDEX JI.T RO INOPV
T\\LJ\T \' WLOQp
COMJ>I(
Que,, 16) Supl)OM' ll1a1 Al.l'IL\ nncl BETA 0~ lb
ll,T LOOP
RSUO A.S
o JP,Q
arrn)S nf 100 wonl~. Anothe r nrmy or CA:~lt l!XJT
b) mulllpl ylna I,\ STCII llUJ'FJ!R.X
clemen ls nrc oblolnt'd WORD
IND[.'{ RLs\\' COrmiJlOndlni: Al.Pl!, \ ckmrn l b) 4 n11cl Oddln
llit ZJ:RO 0 nxR T
Al l'IIA REsW corrci,pondln~ UETA ckmcnl ~.
aUit lJ'NOlll WORD JLT Rl.QOp
100
I ourrllf ovm X '05' l!XIR STX STX
Ans: As,,tmbl) Code LENGTH
RHCORD RIJSD 100 RSUO
zt;Ro WORD #3
0 LOS
K.300 WORD LOT #JOO 9) Wrlle o subrou llnc for SIC lhut wlll rcod w
~
100
LOX
lllREE \\ORO 3
AODLOOP LOA "°
ALPIIA,X QutS 1010 11 hurrer, 111 In progru m 10, The record moy IND!!V BYTE X Pl '
rttor lcni:t h from I In 100 bytes. The end or record Is LC!NG1'II Rl!SW
Qucs 14) Suppo.,c that ALPHA Is nn am) of 100
\lllrd& .MUI #4 I
bt o•:r wllh 11 "null" churuc tcr (ASCU code 00). 111c
ll.S def'mf.CI lo proi:,-:u n 7. \\'rile 11 ~
ADD BETA, X llUPreR Reso
of ln.~ctl ons 100
lo o. Use STA GAMM A,X 111irk~ln c Hhould pince the lcnglh or the record rcod
ror S IC/XE lo set an 100 demm ts of lhe 1UT11) s.x Into o ,.arlnhlc nomcd LENGT
1ubro H.
ADDR Ques 21) Wrllc u r;c11ucnc c or Instructions for SIC/XE
Immediate ~ and rq:isw- -lo-n,gi stcr COMPR X,T , A~ mbly Code lo clear u 20-bylc string lo all hlunk.1.
Instruc tion, to make the p ~ as dlldm t :as possible
.
JLl ADDI.OOP Ans, JSUB RDRl!C
Ans: Assem bl) Couc Ans: Assemb ly Code
LOS ,wJ LOX ZERO
ALPHA RESW 100 LOOP •LOCH BLANK
•300
LOOP
IDT
LOX
LOA
,o
II()
BETA
GAMMA
RF..SW
RESW
LOS
100
100
#3
I RDREC
RLOOI'
LOX
TD
JEQ
ZERO
INDl!V
RLOOp
STCH
T1X
JLT
STRI.X
TWl!NTY
LOOP
STA Al.PRA.X LDT #300 RD STRI RESW 20
■ INDl!V
ADDR s.x LOX #0 COMP BLANK BYTE c··
NULL ZERO
CO\{J>R X. T ADDLOOP LOA ALPIIA,X Jl!Q WORD 0
l!XIT TWl!NTY WORD
JLT ALPHA,X 20
LOOP
Ml:L #4
STCH BUFFER,X
lo m
TJX KIOO Ques 22) Write a se11uence or lns lructfons for SIC
JLT ALPHA = IIETA- 9+GAM MA. (2018[03D
ALPHA RESW 100 Ques 17) Suppose that ALPHA is an urray or 100 "'ords. RLOOP
Write a 5e(JUeDce of lnstrucl lons for SIC/XE to llod
lbt l!XIT STX LENGTII Ans: Sequen ce oflnslru ellon~ for SIC
or 100 maximu m element in the aml) and store r ewlts la
MAX. RSUO LOA Dl!TA
Que:s 15) Soppos e that ALPH A is an lllTa) LOS #9
lo
,.ords. Wriie a sequence of Instruc tion for SIC/XE Ans! Assemb l) Code MUL S,A
store ADD GAMMA
arrang e the JOO words in ascmd ing order and LOS #3
ZERO WORD 0 STA ALPIIA
resull in an arra) BET.A or 100 demm u. LOT #300
NULL WORD
LOX #() 0
Am: Assem bly Code CLOOP LOA ALPHA,X KIOO WORD
START ALPIIA RESWL
SORT 0
LOX COMP MAX JNDev BYTE X'PI'
OUTER L'-'!)EX
LOS ARRI JC JLT NOCH Ll:NGTII RESW I Ques 23) Let A,B nnd C ore urroy, or 10 " Ord oacb.
LOX Ill)
STA MAX BUFFl'.R RESB JOO Write u SIC/XE proi:nam lo odd lh~ cor=1J(>odi.n,:
l"i~ER LDT ARRI.X NOCH ADDR s,x clemcn l~ or A und II und blon• the re\ult In C.
COMPR S ,T (2018(06))
JLT LOOP
COMPR X. T QutS20) Wrlle o subrou llnc for SIC/XE llrnl wlll re11d
JLT CLOOP JO, The record
Jf.Q LOOP 1 ricord lnlo a buffer, us In progru m Ans:
R."1O S.A Ill) be uny lenglh from 1 to 100 bytes.
The end or ll)S #J
RMO T.$
ALPHA RESW 100 rtt0rd Is marked with u " null" churuet cr (ASCII code I DT 1.10
RMO
R.~10
A ,T
WORD ·32768 tllJ, llie subrout ine should pince lhc length of lhe
1
I.DX rro
X.A MAX
WJrd rend Into u vnrlnhlc named LE NGTH, Use
LOA -\,\
LOX INDEX ADDI !'
uddrcu lng nnd rcglsler-10-rc111, 1~r
Qua l8J Sup ~ I.hat RECO RD contJ<lm a loo.i,,t,
STS AARIJC laun<diate AOll ll,\
lnittuclloru, to mukc lhc proce~s u~ effldcnt 11~ pou lhle,
RMO
n,cord. Wriu, a w brouline for SIC IJ1a1 will wrl&t dllt
A)(
STA C' X
STT ARRI.X
X.A
rta,rd oo lo devlet: OS. A111:~ mhly Code Allllll S,X
LOOP RMO
JSUU RDlll'C- l'OMl'K S, I
ADD •l Am: Aut,mbly Code 111 Alli>! I'
COMP !.a-GTI-1 JSlll WJUU:C
HI'S\\ 111
RMOA. X RMOA J(
JLT INSER ~l)KJ;C
I.DX 1m~w to
HO
I HI S\\ .l_(l
,u,\l!t l'r<•~nimm,ni: nnJ ·\,,emhkn tMooule 2)
R n-_-h. Ftt'h s,n-.~:~ TP :,,-/1"'1 Srrir- \S\, 1ernSotl\lo ,~, t,.U\..°'
C-~ ~.ltt\: \"""''
, uc,crill\' the rnrim~, t) pc., ur a-.scml>lcr,,
c;.2 1
Qur- 15"1 \~riht 1hr :i..~'t'mblcr output foniu. • ~ , ..~1 Or Que, 27) Dc.~rlbc llte o.<~cml>lcr dolu ,1ruclure.
~ n O,e ..,t,j e.-< pr,.•~ m rom\91 ,if u...~'ttllb I. Op
- ASSEMBLER · - Btttll) d~rit><- ,~ rorm~t or ot\it« ltr. a., 11 1
,..ptL'-' und t110-pt1.\l, ~cml>lcr. Or
~c., or 01''1 AD and S\' MTAD durinjt the
l nr• lll Or Whot urc ll1e
_,,,.rstoo b,. SIC !1..""'-' Rlbter. ~ \\ I '
tl,,tmbllni: pl"OCCM? Sprdry ll1t ll-.t-. or nch du ing
\n,:: \.~ b.1-Y ()u!pllt 1-' ,\{tll,lll 'Ol\i{x'( ~ "tllJI
Que!> 2-il \\lut i,. ll.<Sembltt~ Dd'IM ba.<ic ""'-~
~ -·· \20•~'" I , c,.ml~pt or ~m~lc ptL~ osscml>lcr "Ith 0
n I" pns.~ l and po.\., 2 ur u h10 Pa.\.\ .,_.._...,mbltr. (20J9(03JJ
functions and its pha."C,..
Ans:: A.~ b l u ~ >1n•rk N>)'-''t p11..~nl t,,m1.lt C-Ont:lins throe p---
~ If
t'\l~~\r ,.,11n1pk
,.,ii Or
!2017 [OS))
. rh•· l\lndions or two posses of u simple hio
An~: A!s'iemblcr Data Struclun-,,
The dn~J ~lructurc, used by .-in J.'-'<:mblcr arc as folio",
A.<>'Clnblcr " ~'<ICE:1 -.o..'n,= -..-!udt l> ~ "' (\"11\ffl UI rt("Ord.<:
. . _ ~ ) ~-..,l"C'l~IOll,-~\ ~,-..,.,.,..~,'\.'\X. Th:
lllpUI to the;,.~.,_ ::i. -..--a-.::= .:."\k-"~"'!I m =~
1' }lr,idrr Re."\lrtl: Th,.• H~,1.kr n.'\.--ord
J'R.~-rsm IW"- 0
.::,ro~ ~""-"- .1nd
n,:f.'lffl-1.I r~vxJJ-.--r ro.., "'1 t, ~ folio\\--.;
ICI\_:~ ' J\~":!J11blcr-
~" J'lp!'S ur ,\s,'tfflblcrs
!2020[03])
~.-.., l ~ m:,cm_-c:,.,::,.) :mJ the,-...~,,:.-.. &,,o:i 1JI>! ·.,of ;J...;emblcr.: :ire·
code. The~ of z :.:,..--=:,,.",lcr Jercni., ~-ci :he m.idr< .!!-- l'"'~f"ie-Pn.-.< Assembler: As iLs name implies, this
~ ..,:he ~tl..~>,.::tl,"IC:Cl,,.~~ ~..,.. Pl\~9f...'llM~
$!.Jt'!...S. ~ 1.'f 1.~j«t ~
11 ~ ng ,"ler reads the source file on~. Durin!? that
~n••
~" • p.1.s.<. rhc assembler handles both lnbcl
-
Saum,
Pro£nm ..._,
ObJc<,
Basic Funaians oC -~ ....,~-;-n>J\ 1
-•~ 'u·(ln< .illd n.= bl} · In this case the whole
I) T~ , ~ c::ic:,.,~,, ,~-.."'=,. ~ n:u:hmc ~.:::i.;_.~.
:?l Coo, cn,,?:l!\.--u.:~i.,tliarmx: IJm<~--<::,,.. CN :.i.t~ I L,:-r.s:" '~ '"-"...'-'-'1 pn,~r.tm in bvtr:::;;
11>:uh-ir.w\ •
J,:nnt
f'I'
. . , . .. .
...~,.., .,r ,c,mrung•. par.;mg. and obJCCl code
tNOn ;, tlone m smgle p:l.<s. The only problem
31 B wlJ ::mdi.:ne = . , , : : ur ~ f.:,r=r.
4 l Coe, at ~
5)
=
m:,, ~ r::pi=::.o,u
En-or ~bel:-b..~ ,, ;n,,ld<\l. ~
~"'":l,."'111 .....
;::r..:-.;~•"
~ ~-nm I
La\.l!<h<>Ftbi,cbi,q
- \0 I>),..
•,.,th
' '°' this method ·1s rc,;oI11ng
• ,orwa
'
one-r-iss assemblen; :ire ~d "hen: .
rd reference.
LOCCTR
6i Cl=:;,e,- c:m ~ qurl.l~ ;m.1 ~ ) m..--..:iqx-.r.1tohi:h:,. , nece$S:II) or dcstrable 10 n1•01d a second p:iss Figure 2.5: Data Struclun,s
~'>=bl, 11 111
1: ... 01 er the soun.-.: progr.un I) Operation Code Tobie (OPTAB): It 1s used to look
-, \ ";,ruble- -- ~ ti) ~mix-.& a=-- :,0:"" ~ C ' QP\ ,i1 The: c~tem:il storn_gc for ~c. inte,m<:<'fote file up mncmoruc opcrntion codes and translates lhcm 10
~ l.x:aticc,-. ~ l\1~ n two passes 1s slow or 1s toconvcruent to use !heir machine langu:ige cquivaleni,.. In more complc.,
r~ 1-:: H'3Cltr Rttanl Format
Pb.L't'inA.~ assemblers tl1e tnblc also contains mfonnation :ibotn
~ <lq,-
!Y'J...-.C,...
= =l
--..:md:, .
in "'~ 6:ff= ~= , . Text RK'()l1i: Te~t rec,.-.r.is cc-nl:lin the tran.<Jiued
:r...,:b;nc C\.--.X i::..,IIU,t:1011$ JDd d.m of tbc, ('~
, rwo l'n-<S ,\.ssemblcr: A tWO--J):1$S assembler resolves
1
• lb: fon.:trd references and then convcns into the
instruction format and length
ln pass 1. lhe OPTAB is used lo look up and ,-:ilidate
tr>f"'...:xr ..1:h :.:: t.nJi:::-..non (\f the addresses
~ ~J~t rode. For a two pass n.sscmblcr. fonvnrd
A.1..J~ " ' Phi.-<
s, -~'ic:,., , Pb..-.c :be,,<=,, x l." 3oi "'-rt ::C,rences in S)mbol definition :ire not allowed. the opcrntion code in the <ourcc progr:un.
symbol dcfiniuon must be completed in pass I. In pass 2. it is used 10 translate the operation codes to
The -,i • ·'mfwik :.1 t ❖ t.'>:;letclsft-cadi;:,b= oi TI.! I~:a-. ,~ tctt ~-ud ts .1S folio" s: mnchine language.
;:.r: : 1 s ~..lc:r
SUCh Jn .is~mbler perfomu. two p.-isses over lhe
Cu I T
TMit:..t:"""5c<.wl a~ S:x:,r,,: ..,__-= ,:,f ob)<d. code in rcconl. -oUJtC file. In the fir.:t p:i.ss 11 rends the entire source
fil<. looking onl) for 1:ibel definitions. All lnbcls rue
In simple SIC machine tl1is p = can be pc:rfom,ed in
either in p:iss I or in p:1..ss 2. But fur m:icbiDc lib:
.~ . . . . . , ~Plmr L::n~.r,. CC'"<"'- a>dc m b~tc,, ( ~
rollcct~. .1SSigoed ,alucs. and placed in tlie symbol SIC/XE tluu has UlStruclioos of dilttrcnt lengths. one
B~l:bc .S~~"l l ASe L.· .. J I < ! - ~ .,.,cecc»e=a:ioatn bc.<>d<amal. ubl< U1 1h1, p:i..ss. ,No instructions :ire assembled and. must =rch OPTAB in the fm'I p3ss to find tbe
-
T.be .,._ EC'lll><~
s~ ...er= ef ,: the enJ of the pass, lhe symbol table should conl:lln 1n,truction lenglh for incrementing LOCCIR Io pass 2
' ,',.~
. 1
a:,.:..
~ ,.
~ ID Cle ,1~.,,&,:::
c"""'1l
~=
ox
Ot-J<CI rode ~
m bcuJeamal
ill the !Jbds defined in the program. In lhc second one tlke.s the information from OPTAB to tell os "bich
P;;_._, ::><! ~ "'--"ci.. < b=lbe~...,,,_, d : I"-"'· t11e mw uctions are again read and are instruction foannl 10 use in nsrembling !he in.<IIUC:lion.
·~ =
I1~'
~ 00,S ~ ~ fidi,. ocmcr- opc:z>,:! I!>,
,.._-.emblcd. u.smg tlie symbol table. and :iny peculiarities of lhe object axk in.<IIUClion.
S ,--.,i T.ablc I 101 11 I OPTAB is ll,wtlly ~>noised :1.s a h:i.<h t:1blc. \lith
H= the process/functions of the l\,o--pass
Pafon:, mrn><X) :a!l:,.;=-a s,~ th: ~
• ~. l I: I
.c..tmbler can be as follows:
mnemonic operation code as lhc l--cy. The b.t>h cbic
organisation is particularly appropriate. since it pnwidcs
~
,r,:un,D: Ten Record Fonmt Pass J: (Defme Symbols)
Ch:d con-c..--., c! op:0d<> fust rctrie1-al witl1 a minimwn or s.::m:hing. MOS! of the
b~· ~ f c: r:bc -~ 3 End Rtaird: Th: End n>--ord m.,ru the end <i !Ir il A»icn addresses to all ,tntements in program. cases the OPTAB is a stnlic tnble - i c., cntncs :ire DOI
,tr ~ -., ta;l,lr
l'p.!.,:r .-oc:c:s al !..oc=::
at
obp:t ;r->;r= :::id ,1)CCllic,. the add= in the prop.
11:,c:-e c,c..~ is to bcpn. (This ,, llleD ma *
,il 5,_; lhe ,-:tlues assigned to all labels for use in
Jl-1» 2
nonruilly added 10 or deleted from 1L In such = it L'
possible 10 de.sign n specinl h:i.shi11g iunclioo or olhct-
COODCtt b:.,-,.d oe 6e ~ opcr-'X! d:lr ~ -, e - n ~tlfnoapaad ol Perform ,ome processing or assembler dirccti\•es dntn structure to gi1e optimum pertoml.llll.--c for tbe
d ca.::11 .,,,,,._....,.,.,.,_ ~chi: ~ of 6c firg cxecuuble - particular SCI of kC)S bc!mg stored. The fullo\\i~ tit-le
I• t.iCi Jbt fc.cD& for end n:coo1 t., la> {alJaol'-.: \ otr: Perform anal}sis of :issembly language
F~ 2.1 ilhl,ir.,ro t...._, ~ GJDDt ca:il p!u,c ci ~ws the c."11Dple of OPTAB
Col I E rroi:r.un o .....
l
-~-:-~
~lnMlontc Mndun•
~ ):
Cd c ~ o! f:ru eu:cuti.bk u,mwja Pa,s 2: (Assemble Instructions and Generate OP<'Odc Op,.'Udt
~-· oh,e-.:1 ~ lbc.ude.:1a:all -~ Objl'CI Codt) READ ()<j
A ~ ol f;nl u ccca."k 11 A,-emhlrr m,trucuon," ADD 01
. ~ m u i tt-,~ l'W"O£ff!' Grncr,tc d• IJ , J.luc, defined b) BYTE, WORD, LOAD - oi-
-~ 1) I 1ln'l'=,~ I
~ l ~- l ....~.../s,,.....!'...,_~
r I i
1 cl(
1J P,11om1 proccs,in~ of J>'embler tlircc111e, not
SUD
S!ART
111 - (it,;~ll\~)
ttt\A~,cmN<r
~•~T-7 fl:an- .l .l:Phecs.JaaA>s<mbkr
END
DS
l>C
-1--- - ~- .,0•~•~!
0
--
DTech. Fifth s,mc,tcr Tf Solrtd Series (Sy,1cm Sori.."t) lt11, guoge Prov,unming lllld As1emblcro <Module 2)
,IP',nbly 1,.211 C-23
<"·22
2) Symbol Ta.hie C~ITAB): 11u, tllble 1ntludc:s the
ct~ The >()Unx:,
.
1J
1,TORG
='S'
=' I'
211)
212)
+-000005
+-00 0 001
All or lhc lncral operands uscd in a program are galhctcd
together mto one or more literal pools Nonnally. loteral.s arc
name and value for each labcl m the source prog,am, To bold lh< addru, or the _
,n,1111.uon to be CXCCUlcd. ae.i placed onto a pool al tbe end or the program The assembly
lngcthu w11h flap lO ,nd,cau, lhe CITOf condmon•
Holra tl1c mnemonic llflll ~ 1: EXT sun AREG,=' I' 214) +021219 hstmg of a program containing literal\ usually include~ a
(e.g.. ,r a iymbol II defined ,n 1"'·0 d1ffcrcn1 plllCCS), Op<r.lUonCock Table 1S N DC LT, BACK 21S) listing of lhlS literal pool. The - . nbler directive LTORG
c,pood< (or each ln•truc:tio,,~ -l-07 I 202
In pa,u I , l:ihcl, an: cn1Cffil 1n10 lhe symbol 111ble ,.,lh length :and lypc. -, 16
1·
i.,1sT STOP
ORIGIN LOOP+2
216) +-00 0 000 tells lhc assembler gcner:ue a lileral pool hen:, LTORG
•loniv.11h thor .U\lgncd ...Sdreu vnJue as UlC) nre Hold lhc p\Cudo m•lruction 111d llie allows to place literals mto a pool at 'IOlllc: other localion in
-P-,udo <>pubic i\ MULT CREG,B 204) -+-033218
encountered 1\11 lhc •>mbnh addl'C$S ,,aJuc •bould g<I cormpondong ocuon to be~ 19 LAST+I the object program. When Ille :wembler encounters an
ORIGIN
rcMlh cd at lhc pa" I SIOID :ill symbol, •ncou~ 'ill I 217) LTORG Stalemcnt, it crca1cS a lilcral pool that contains all of
DS
In p,u,s 2. •ymbob wed as opcr.,nds an: looked up the
Symbol Table lhc program along ,.,lb~ ,1
;,
A
oACK EQU
LOOP the literal operands used since: the previous LTORG. This
o,dd!CSS"'----- OS I 218) literal pool is placed in lhe object program at the localion
,ymbol lable to obtain the address value 10 be 1nsencd
1n lhc .U'Cfflblcd m\UUc:tJora. uocnlTablc
s,on:s oll li1er.ils on the ~ ii B END where the LTORG directive was encountered.
aJoog wilh memory add~ . :J =' I' 219) +-00 0001
)l Literal Table (LITIAB)
snrr AB u usu.Uy organised as a lwh u,.blc for
f1gu
r<2.6: Assembly Program UluslrnUng tht
Dlrecllve
ORIGIN
Por each used literal, LIITAB contains:
efficCIIC) of rnr.eruon and rctriev:il. Since entnc:s arc P....s D I) The literal name,
Daill stn1cturc> u.lCd on pass IJ arc as follows:
r&nel} delelcd. cffioeocy of dclcuon u lhc ,mporu,.nt Tibl< 2.2 llluslr'Jlcs contents or these lllbles after processing 2) The operand value and length,
cntma ror optnni>.Won. Pu
Into s1rvc111r, Ill< END sw1cmcnt or tl1e program of figure 2.6: 3) The address assigned to lhe operand when it is placed
lnu:nncdlll< Cod< For further proc..sing 1111d llleiiiy T•blc 2.2-a: OPTAB in a liternl pool.
Boch pu, I .and pa.-. 2 require rt:1dmg the ""1l'CC
~ Apan from lhu an 1ntcrmed1au, file u mntn1onlc ol)(ode class mnemon.lc lnfo LITTAB 1s often organised as a hash table. using the
Loa!JDII Caunl<t
hold addrc>S or IICll i-~
code.
To MOVllR IS
=eel by Jlb' I that conwru each source S1atcmen1 (04. lJ literal name or value as the key.
OpcnUon Cod< Table Holds tloc mnemonic machineW DS DL R.#7
torelhcr "'llh ,u. assigned address, CITOf md1ca1ors. ror each in.,truclion along IOilb -.»i Cr eation or LI TIAB
dC. Thi• file u one of the inpuu. 10 lbe pass 2. A copy
START AD R#II
and IYl>C, In Pnss 1
of the loOUrCC program i, aho an mput 10 lbc pm 2. :
S)mbol Table Crca1e by pass I 10 store all 1Ylllbob I) The assembler searches Ll'ITAB for the specified
,-fucb •• wed 10 retain the opcr:,tioru lhat may be 10 lhc program and ill uaoc..,. Tnblc 2.2-b: SYMT
SYMTAB~
svmbol uddrw len2lh literal name (or value) because each literal operand is
performed dunng pus I Csucb as scanning lb< value. recognised during, Pass I.
opcntJon field for ,ymbols and addressing Oap), \0 LOOP 202 I
Ba,c Table To indo<alc which rc&iataa • 2) If lhe literal is already present in the table, no action is
that tbcsc need 1101 be performed dunng pass 2. ,pcc,ficd os ba5c rcgistell by die USE Nl!XT 214 I
LAST 216 I needed.
dirccuve and llleir conlenL
Similarly. pouncrs into OPTAB and SYMTAB u A 217 l 3) If lhe literal is not present, lhe literal is added to
numed for ead1 opcnllon code and symbol used Qoes29J[%plaln 1hc use or OPTAB, SYMT,\J . . BACK 202 I LITTAB (leaving the address unassigned).
LITTAB In lhe A.sscmbler Poss [ using lllllalllt D 218 I 4) When Pass l encounters an LTORG statemeot or lhe
11w a•mds need to rcpc.n many of lbc table,
aamplc. 'fable 2.2-c: LllTAD end of lhe program, Lhc assembler makes a scan of lbc
loClltCluog opcntion, 1lle c:umple of SYMTAB U
~nlabkbclo... vnlue oddn,ss literal lllblc, Each literal currently in lbe table is
Ans: Use of OPTAB
I
I
I
Symbol
'-
A
.r
Addna
100
La,~
I
Other
Inrormalloa
.
OPTAB ,s U5Cd 10 look up mnemonic operation codeund
tnllilatc lll<m to lll<1r machine language cquivalCDII.
I
2
3
='S'
=' ! '
=' I'
LTORG
l}-..J.,1crnl1
op
0101
n ix
b •
dbp/addrai
I I I 0000 0000 1000 S3A008
followmgst.atemen1 second and third words; others require memory ~ FIRST LDT #11 00 010
register numbers, or who knows whnt? - LOX #() STCH STR2.X 0101 I I I 0000 0001 0000 57A010
OJ\"E OC •1· 010
STRl,.'C 01
MOVECH LOCH
decl= O.NE to be the name a.socwcd "ith the JLT MOVECH 0011 I l 0 111 111110101 38 ~
,\sscmbly is n ro,e ~k Iba, we can assign ·1o lbc STCH STR2,X
= i I The pro,gnmmer c:.sn declare consUIIII> D11aocomputtr The n:11crocornpu1_er never lllakei llDy
10 0 10 l
TIXR T
tn decimal btnal). hexadccunal. cu: Man) mistakes when translaung codes; II always kno\!i hotr
assemblers pcnn11 the use of hterals. These arc H$TRCP2l)010001)00027 IU,TRCP~00100Q!)0002B
m«o) ,. 0 rds and "hat formal each instruction ~ T,l)0100011l5000B050000~3A008,:i7A0101!850}82FF5
cssc:nuall) co=t.s ducctJ l used ill an operand T,P0100Q.OF_.04102!i50900t54901~C1021!,l81003
Toe program that docs this job is an "asscmb~; 'l1it T,l)0101l01!544553542053545249
field. Smee the ·,aJue' of~ constant is known from T,00100F..0~445535420535453494E47
assembler program IJ'allslates a user program, or~
the ..,..,) 11 " 1Ar.tten. the littrals arc ah.o called self- 1;,001000 T.l)0 I0 2~0 6_000000.l)OOOOB
program wrinen with mnemonics, in,o a machine IID_iua,c
defining t.cnn,. t:se of a littr.J sa, es us from the Ep<ll0OO
program. or 'object program, which the microcomeifirCltl Elgure 2.8
difficult) of defining a constant through a DC
c1CCU1C. The assembler's inpu, is a source progr.mi)idis
SlalemCDL
output tS an object program.
3) ~ l c r Dincth c Stal.ements, Assembler
diR:ca"e 5U!emcDls nc:ither repre.<ent maclune Assembler:. bave Ihm own rules that you
IDW'IIClloru to be tncludcd tn the obJCCI program nor These include ule use of cenain markers (such u
i.nd.ica1e lhc: :lloc..uon of storage for constants or collllllllS, semicolons, or colons) in appropriate
vMUiblc, ln,tc.,d. these st.11emenl.\ dJrect the correct spelling, tile proper control of info~
assembler Ill pcrfonn ,omc spccdic acuons dunng the perhaps c,en the correct placemen, of names and · ·
assembLng proce.s of the progr..rn These rules an: usually simple and can be leamecl
Assembler direane ,u.ttmenu neither rcpre\ent Tr-..nslate /by hand) the following assembly p
machmc tn~1ruc:lJOn to be included m the ObJCCl obJCCI code. (The OUlptJI fonnat wiU
pmgnun nor wd1c:..u: the allocauon of storage for I i ~ 2.8, which con1atns H record, T record, and
com1Jsnu. or w,r,able. Instead, these st«tcmcnl.\
dJrca the ~Mcmbler to perform ~omc specific Lo< Soura: •talcm1•nl
scuon dunn,g the a.scmbhng procc•• of the STRCPY START 1000
program ARST LOX Zl!RO
For ci:amplc, oonMder the followmg •t«tcmcnt MOVf.CH LOCH sm1.x
STCH STR2,X
START:W2 TIX lli..CVLN
JLT MOVCCH
Erplanauon: n,e fu>t ,.,c,rd of Iii< <JbJcx;t prugram STRI llYTf: C'lF..ST STRING'
genctllltd by the iLJ,.>c:mblet hiu to be plMced STK2 Rf.SO IJ
10 !he
memory addrc,,, 202 71.RO W()RI) 0
IJJ;Vf:.N W()RI) II
C-~S B.Ttd1. fiilh Sc111e.<1cr TP So/l'td ~me, \:.)"•IemsOl\1v~) • _nn<l Dcsig11 Opt1u11, (MoUule J)
Ft:lllln;..~
~ ,,.,n1b\cr ..
current program counter value. The followlni:
scon be:
(lllruct1°11· • ns for the Instruction Involving exumplc shows how tl1e address is calculated :
Module3 1
\ rri1~1slt~'.;cgistcr Addressing Mode: During pnss 1
1 jtc~'st ~itcrs can be entered a.s _port o: the ~ymb~I tnblc
For PC relative P
Dlsplncemcnt
=I TA =
(PC) +
thCrtSTI ,•nluc for tl1csc registers 1s tl1c1r equivalent :::, Displacement = TA - PC
. •If IC 2 0000 FIRST STL RETADR 17202D
,ti< : .c co<k S-
ttUlll<rt 3 0003 LDB I/LENGTH 69202D
• ,, p:ISS 2. t11cse values arc ass~mblcd alongwitli
Assembler Features and Design O~ti!~ DUO11c ,
111011 ies obj~ct code. If required a separate
lh"' uJI\C n be create d w1' th tJ1c rcg1.ster names and their
ble ca . 18 0030 REfADR RESWI .
MACHINE-DEPENDENT
Gi>·e the difference bclWL:n PC Relath•e Add: :~
and Base Relatirc Addressing. · -~lit ,_ IJ . ,oJcnt
cqUI\
nslalion
numenc values.
,
involving Register-Mem~ry
!I 'fr~ructions: In SIC/XE machine there are four
TA= 0030 PC= 0003
i;:>isplacemi:nl = 0030 - 0003
ASSEMBlER FEATURES . Formats and Addressing M<>des
Ans: ln,"trtlcl!on ((15 uon ronnats and five addressing·modcs. i.e., 0000 0000 001 I 0000 (0030)
,ns1ruc 0000 0000 0000 001 I (0003)
Qucs I) What is llls chine ~pendent Assembler A.,-emblcr must: "nic onar.ition code to macl\ine 1,.. ng uic instr11ction formats, format-3 and fomiat-4 0000 0000 0000 0011
Fe:it:un,s? '\Vbat arc the ad,-antagcs or SIC/XE? ) C ,·ert mnem,, r . ~,21.u •. An10 ctions arc Reg1ster-
. Memory type or ·.
l on OPT, o) and change each registe~ Rltle ~ ~ . rnstrucuon. Displacement = 0 0 2 D
.(11.sm~~ ·c ·" "ui\'alent (done dunng
- pass. ?) -VUJc lo • of u1c operdlld 1s
1nstlll • always m . a register
. and the
JIS nl!l!leD eq . . - . .. _, one operand ··t1 ii) Base,Relative Addressing Mode: In this mode the
Ans, Machine ~pendent A.ssembler Features oiher ts m . 1e me!11ory. The ,add ressmg
. mode
There are ~ fe.-irures tiut are depend.en1 on the , Th• con\'ersion of register mnemonics to riu_m§crs ~
tells us the way m which the ._operand from the
base register is used to mention the displacement
architecture of the undcrhin" machine. A few of the -l bc 'done 1\1'th the scpar.ite table. To• do this, S~•ii\•'>-
''!VI,,," " value. Therefore the target addres5 is:
would be preloaded with the register name& .~A\ ~ memory is 10 be fetched.
machine-<iepoidcm f ~
.!re .as follo"'·:t:
fo;
SIC ,·er..ioo of assembler.
etc..) and their valut:S (0, l. etc.). . - .•
TA= (base)+ displacement value
This addressing mode can be represented by either
IJ lnstn:ct:ion fomuts and addressing modes. ::nd using ronnat-3 type or fonnat-4 type of instruction This addressing mode is used when the range of
2) Progr..m n:J0wuon. The instruction foanats depend on the ro,mat. 111 format-3, the instruction bas the opcode displacement value is not sufficienL Hence the
orgmiSltion and lhe size of the memory. followed by a 12-bit displacement value in the address operand is not relative to the ins1ruction as in PC-
Io SIC/XE 'f~on of assembler. field, whereas in fonnat-4 the instruction contains the relative addressing mode. Whenever this mode is
I) lmm:xiiau, operands denoted "ith pn,,fu #. lnstroction fonnal for SIC . mnemonic code followed by a 20-bit displacement used it is indicated by using a directive BASE. The
In SIC machine lhe memory ts byte addressatile. Won1 value in lhe address field. moment the assembler encounters this directive the
2) Indirect ~ddressing - inc!Jcated by adding prd'ix @.
size is 3 b)1es. so the size of_ lhe memory 212 ~ - next ins1ruction uses base-relative addressing mode
3) lllSlroctions thai refer mcmorv are assembled using
Accordingly it supports onlr one rnslrucllon .fonnat,, flltias Calculbtion of Displacement Value for Target to calculate the target-address of the operand.
Pro~-n coumer or base rclati\;Caddressing mode.
onll' rwo re!tislers - register A and Index ~~~
4) The assemol~ dmxti,-c BASE is used in conjunction
with ~ relati,·e addressing mode.
Th;refore th-e addressing modes supported 6f'iJ!h Address
Assembler must calculate displacement v"\ue to get
When NOBASE directive is used then it
indicates the base register is no more used to
architectun: are direc~ indirect and indexed. :,"-l 1arget address for both addressing modes. calculate the target address of the opernnd.
Ad,-antages of SIC/XE Displacement must be small enough to fit in the 12-bit
Instruction Fonnal for SIC/XE ·. Assembler first chooses PC-relative. when the
field in the instruction:
I J Regiru,r to register instruction used to improve
execution Speed of program. The memory of a SIC/XE machine is 220 bytes OMfilJ,' . i) lf the displacements loo large, 4 byte extended displacement field is not enoti!!h it uses Basc-
supports four different types of instruction types, the~ aie: instr11ction format (Fonnat 4) must be used. It relative. For exampl~, ~
2/ 11 does 001 requin: anotbcr memory reference and l) Format 1 (1 B)1e): Conlains only operation cod~
henee it 1s fasr.e-r. con1ains a 20-bit address fidd. No need to LDB #LENGTH (instruction)
2) Format 2 (2 BJ1es): Fim eight bits for oiieratioo calculate displacement. BASE LENGTH (directive)
31 No neec to fetch unmediaie operdild & it is pan of
rnstrucuo:i code. next four for register l and following four•.'f§i Format 4 (Extended Format Instruction)
register 2. - 6 bits l I l l l l 20 bits NOBASE
4 / Pro\Jde room to load and run several programs at
same Ume Tn" kmd of shzring of the machine The numbers for the regis1ers go accordi nfog',.,..
) I OP code I n I i I x I b I p I e I address I For Example
betwecu programs is called -multiprogramming". numbers indicated at the registers section (i.e., re' '-
ii) •+' specifies extended fomiat. 12 0003 LDB #LENGTH 692020
5) lf the d.is1Jlacemen15 reqJ irc:d for both PC & BASE T is replaced by hex 5. Fis replaced by hex 6), !
13 BASE LENGTH
relauve •ddrc,smg .re loo large to lit into a 3-byte 3J Format 3 (3 Byles): Fi,s1 6 bits contain opera•- Forexample,0006 CLOOP +JSUB RDREC 4BI01036
'"-''tnlcuon then the 4-byu: extended format (format
4)must be used. code, next 6 bill> contain flags, last 12 bits coo 100 0033 LENGTH RESW I
di.splacemem for the addres; of the ope There arc two ways for translation involving Register- !05 0036 BUFFER RESB 4096 .
Opera1ion code uses only 6 btts, llms the sccon Memory Instructions:
Ques 2J fa-plain the lru.truction Formats and tLg11 w,11 be affecied by the values of the f~ i) Program-Counter Relative: In this usually
Addressing Modes with •.>.Junple,.. 160 104E STCH BUFFER. X 57C003
0ags (n and i) format-3 instruction fomrnt is used. The 165 1051 TIXR T BS50
Or instruction contains 1he opcode followed by t1 12-
Discuss the Pr<>gram.Counl{:r Rcla1i1•e and Base. The nags in order ;,re - n, i, x, b. p, and c.
Relative Addressing in detail. bit displacement value. The range of In the nbow example the use of din.-ctin· BASE
The last nag t indicaies the instruction fonnat; displacement values are from 0-2048. This indicutcs thnt Base-relutivc addressing mode is to
Or c = 0 for Format 3 be used to cnlculnte the tnrget nddross. PC-relmive
\\'rile short notes on the foUowiug: <lisplucemcnt (should be smnll enough to lit in t1
l) Immediale Addressing .'1ode t = l for Format 4 12-bit field) value is nddcd to the current contcnls is no longer used. The vnlue of th~ LEi"IGTH is
ii) Indirect Address Tr.uisfalion of the progrnm c1~111ter to get the turgct nddress of stored in the busc register. If PC-relnti,·.: is us~I
4J Format 4 (4 llytt:.s): Same as format 3 with an c
Or the upcron<l required by the instrnction. This is then the tnrgct "ddress cnlculutcd is: ·
htx d1gm (8 bi1,J for addresse; that require mo
~
12 bit., to be represcnlcd . rcl111ivc wny of c11lc11l111ing 1hc nddress of the (0036)16-(1051),~
opcrnnd rclntive to the progrum counter. Hence = (-1015)1~< (--OS00) 10
• f /- the <llspluccmcnt of the opernnd Is relntlve to the .. (-2048)111
r-c,iurc.< anJ Dc.<ip1 Op1io11s (Module 3) C-J I
:) ~ \...c,,11,\cr
1 the ,·nluc of RDREC Is 1036. Nole: 1l1c ussemblcr must determine the portions of I.he
~-"'n,r 1118 .
11rf,\U IOp
- •-co_d_c'\,.....l_1
\ _n_c h
_in
_ e_ C
_ od_e_ l
code 1hn1 ch1111gc with lhc load address and make
)),, modifications accordingly. Other address remains lhc same.
\-fil;lO AC 1
J§UB 148 The assembler still docs not know where the program is
LDA 00 aclunlly loaded. Hence it cannot make any changes in lhe
addresses used by lhe program but only identifies the pan.s
i\'t Cit und marks lhem, for the loader lo take care of the rcsL
REGl¢1l [Ali]
[[JI] The problem o[ program relocation is solved as: consider
a JUMP instruction such as JSUB as an example. The
. rrogrum Rclocntion . assembler genern1es the code for lhc jump instruction
.\\IS• csir.1blc 10 load n program 1010 memory wherever relative to the s1arl address of the program and inserts a
1115 d_ ace for il. In such a case. the actual staning command for the loader instructing it to add lhc load
i),Cf( ': ••spnoi known unu·1 th c Ioad lllne.
.
1
address to the address field of the JUMP instruction. This
,JJl(S> IS
command for the loader is also mallc pan· of the final
, nbler cannot mnke changes over the addresses object cod_cs. This is done using n modification record.
l1tl a.~~.: program. But ii could identify.,~c parts o[ the
~ u<ed b) JOS!1llll 1hal requires modification. .
,{,jc-1p .• ' Format for Modification Record
&ti'? Col I Chnr"M'
~OJ}) b' cl prognun that contains necessary infonnation to
°
A0 J~ 1.his kind o[ modification is called relocntablc
1
Col
2-7
S1aning loc:,lion of addn:..<S field 10 be modified,
n:lalivc to lhc load address of lhc orogram .
il>lefor ,...-1 orn For cxnmpIe, cons,'der a program w11
. h a stnnmg
.
'Se- pnifr.l'11. Col Lenglh of lhe address field 10 be modified in 'Half
.iJdft.<S 0()()(). 0~'.'.'1e g.9 By1cs· . The lcnglh is in half bytes.
0006 JSUB RDREC 401~1036.J For example, a sample modification record
isp M00000603
-
~disp
n,eaddrcSS field for this instructio_n is 01036.
SurPo5~- user wanLS lo load this program beginning with
Explanntion: M represcnls the modification record
000006. ll indicn1es that it represents. the load address of
the program must be added lo an addrcss field beginning
ih: address 5000 then the address o[ the instruction
dispju at address 0.00006.03 represents the length in half bytes of
t-(,.'1l!DCS 6036.
ISi&iled the field which is to be added to the load address.
Sunilarly when lhe program s1aning address is 7420, the
Each nddress field 1ha1 requires change when the program
JSUB ins1ruction comes-with the new address 08456.
is loaded has a corresponding modification.record. '
\\nm:\'fr lhe program is loaded, JSUB instruction is
!)ll"J) S 1036 by1es past the sta.rting address of the
Ques 5) Is there a need lo use modification ~ords for
progr.un. 1l1c abon examples arc diagrammatically the ghen SIC/XE J,rogram segment? Explain your
" prc~nled as shown in figure 3.1: answer. lf yes, show the contents or modification
°'·f : record. (2019(031}
~
i(♦JSUO
D1~1036 RDREC) 0000 COPY START 0
: indei ' 84.10 RDREC
',u;\ \. 0006
OOOA
+JSUB
LDA
RDREC
LEi."iGTH
lidd is
:v.a)ac, Si D i(♦JSUB
S~\ j
T 036 RDREC)
··································································
0033 LENGTH RESW
...
603,6 D4 1~ RDREC • •••••• ••• ••• ••• •••• ••••••••••• ••••••••••••••••• .. •••••••• ••••-• ••u
1036 RDREC CLEAR X
IDplc. i i
1076 7420
l'{03J) Ans: Modl£icntlon Record
l
(♦J SUD
7416
I
,Otl-15 RDRl'.C) The commnml for th~ londcr must at~o be n part of the
object progmm. We cnn nccomplish this with n
84~i6 041(1 · RDllt: C'
modilic11tio11 record hnving the following fom1ut:
R4%
I Col, I M
Co\. S1onlng \oco1lon of 1hc uddrc.s.s field 10 be modified,
2-7 n:\n\i\'c 10 1hc bcginnin~ or 1hc oro~mm (hc.,a,kcmw)
1, 1 (h) (c)
Col, Leng1h or 1he nddn:ss field 10 be modified, in lllll(
flgurr 3.1 : lllwtnllon of l'roi:nm llrlonulon
8-9 b1·1cs(hc~ ndccimol)
C-3~ B.foth. fifth Sc:i~:cr
rr s,~..-d s,nrs (S)>"'11 SGII...
....~ )~ ,,,,111Jilfl
,... illlfl' ' mid (Jt'!<>iJln Opliom 1Mod11/c I)
,
I lJ
. . n,, .......mblcr dirttlh-o•llQu •IL ·~I way 1t1 1'\.' CO!,:nisl: d11pl ic111~ lircrnl ~ h hy vnluc,. '111c dircc11 v,· u~cd for rhn EO IJ rE,,u:ilrJ / he
One modif...::atio., 1'0..."\.Vd for each ~ hJ ~ tTh."l.liitc.'\i.
1
i1 l i::QU. _ w Jdinc ~ymbuls -and~-\._ nn· 1;-;!_~ ~;1 of rhr: chamc lr:r s1n_ng'i dc~11111g them. If one j,!C-nl'rul form of 1hc ~,.11cmcn1 I\
j fi ~
1be kn~ is st<\.-ro m h.tlf4'i~te:.-- t20 bit-- = 5 h.:d i-b~to\. pn.
1..::r.t1llnl•: •
- 11 1.1r 10 #i. c me or~ -' l"'r\,.: ~ (\,11 11i.:1n:'l ·h:ir:idr:r s1n11g Jcfi11111!! .i !lier.ii 10 n:rng,11.~c Syml10I liQV ,·afu c
T.ne stil:rOng lo..."aboo, is the loc,3[)00 of the b\1e ~·or.u.imng
, ":l.!Ul'. l!:l tn ''""-"-c:\u il 11~1-., Jhl./ hd:-hc must he r;m.:fu/ of /11crn/.~ who.~c v11/uc
;-., lcfnno,,, b1ts oithc, addrcs_, field to l,e ~ti<d. ]311$U.1£t\. ('
J11pht:: 1'.t:.0;1 ihcir loc;11ion in the pm!!rJlll. For e~mplr, '0 1i~ .~wrcmcnl defi ne, Ilic gJvcri ,ymbol ( 1.1:, cnft: rr_ng ,n rhc
_ ORG: 111<· ,_...,-, mbkr dln.-clh-o 01\G U!di,,...
i.f int:' fidd C'OnU!.r..s .1., odd :wmha of b.l.lf-~\'!t":S. ~
Jl·P"nJ\ lilt:rJls th :11 n:fcr 10 lhc cun-c.nl vnJuc or lh•: SYMT/\OJ :ind a.,~1gnmg fo ii lhc v;due lpt:4rfie<l '/ he \.Joe
111 \ a~is,n:- v:iJuc,:- W :-~n1bok -"'11; 1,\· :111°' ("(ll.lillcr (Jcnotcd by lhc symbol }.
~""tnf: locs:ion ~gin_.:; in the middle of the fin-l ti~u 31 c m he a com1.:.m1 or an cXpn:l,,on mvolvmg comL.lrlU .1/J{j
the st.Jrtitl.8 kx.-:u:ion. Thes:e c-on,·01tions ~ oi "'--~· ~~ ~Ii..\" ;1.,-. .::c-m:1_lc~ allow ~ l~;tiOII
13
OOOJ LOB ==• " c uuls 10 3) any other ~ymbol wJuch 1., ;1/rcady ckfin<:d One common
cioscly rcl!.tai 10 th~• .:m:hiteaun:- of SICf.\"E. For cdl.."T .~) D.pre__ :,., ,,h..~~,wsucha~mgle operand'is~ t( , 0 LOA ==* • • uals lo 20)
55 00~-~="--'--~~~~~~ us.1gc JS 10 define ,ymbolic name, !hat cln be u~ 10
types (\f machines.. ~ half-byte 3ppro....'>{"h might n..'t ~ ~xpr~~ C.'\pr~ioo m~1 be C\'alu.arod by !lie~ improve readability m place of numeric v.:i.Ju~ . For example.
:Ji...,'l:!ls.infle~.randaddn:s.s orValue, ~
. ~amc filer.ii name • ha.~ diffcn:nl ,·alurs.
J?pro~~::.. For- .be JSL'"B instru..-tion v.·e s:r: u.--:.D.f ~ an 1\ P soir: 11Ji,; . +LDT MW96
. ' ~ n~ti.:- c.\pr~--sions usually formed b) .
a:ampk the m:xii5..::!tion reca-d would h:..
Mcx.xxxr,05 :1\ i
,1p:-r.!1t,,r.- +. -. *. an.d /. • ~ oucs 91 ll<
r, c literal pool and LTORG.
UI Or This loads the rcg1slcr T with immediate va! uc .JO%. Um
This ro.."'O!'rl SJ)o:ifics tmI the t-ecinni.nc ~ of tb:- uil Th,tmostrommon~1altenn ~rbecllrrtat,, TORG dirc.:th·e and its advantages.
docs not clearly whal ex actly 1h1, value md rcJlt"~. If .:i
p.ropa:n is i:o be 3dded to 3 field~ that ~ ~ ill~ of th: J(',;.:!aon roun1er (often designated by '). pdinr L s1arcmcn1 is mcludcd a.1-:
CXXX){); l l'tlatn'C to ~ sun of the- pro!:n.m~l 300 i.~ 5 1-.:tlf- Tb:' ,"llue:- 0 r,enn:- 311d ~xprcssions are either~ ·i,r.il Pool and LTORG MAXLEN EQV W96.and then
!,ytes in lolfth. Thu.,; Ul the :?...~bled in_q""--:mn
.!.B !OJ 0 .:-6. t.l\e fin;;: 12 bits 1-!.B I) u ill ~~ ;mdunged.
or :!h.'°lu?c. f or exsmple,
i i A rolN!Dt is :!11.:ibsolucc term.
_.\OS: ~:ic literal opcr.mds used in a progrJm arc ga~hcn:d
1\11 of. into one or more !item! pools. NonnaJ ly. /nerals
+LDT o.\lAXLE:'>
T':tc Jr0Sn:n J~ address will be 3dde.d to L~ last ~ 1'1t.: 111.~~ihi.:r ·d 1•1110 3 pool at the end of the progrnm. The TI1en ii clearly indicales th.JC lhc: value of .\fA.XLE..\' u
10 l 036) ro proou.:;e tb!'cocrcct opcr.:nd add."'ess- nl l..3bels:onin.'1lllctionsaodda1a.areas.3Dd~
Jfl' pl.:JCi; r1• li O of a proor::un conlaining li1crals usually some maxi mum length \alue. When th~ ~ «m blc:
ro tk Jet,;::l[ion counter value are relative fdTns:~
J~<cmb~)'. 1i:ti~~ of this lir~ral pool. cccounrcrs EQU sratemeol ii enrcrs the sym~I '.\!AXLE\:
include~ ,1 . •
~--MACHINE INDEPENDENT iiil A sun!\.' ! whose \'3.l~e is _g.i\'en by EQ!J (Or~ alonl!with j15 \'aJue in the symbol ub/e. Ounng LDT the
simi.llr ,i<,..;;ernbler dire_ctl\'e) may 6c cilbcr ni,· :L..scmbler directi,•c LTORG tells the assembler a.ssc,~blcr searches lhc SY;\·ITAB for lb ~ntr;, acd Jl•
Jbso!ote tmn or a re/Jm·~ ~erm depending 0:. ~ 111
: ASSEMBLERFEATURES ,•(ller.11e :i. li1eral pool hen:. equivalent \'aJue as Ule ope.rand in the insuuctJon.
expre.~,oo u.~ 10 ddine its value.
a c=J} !""-"' c==i The obJCCl code generated is the ~e fo:- both th~ °fc~.ns~
Que. 6) Delin, th< mochin, independ,,,1 =bier
!atun:s. Qoes i i Whal is ~e difference between liftiid lad ~ LTORG I / literal pool If the maximum len_g 1h 1.'- ch.:i.n_ged rrom .J09610 IO_.J. Ji L>
Or b:nmeaiate operand. c=J} 1;"'-"-' c==i difficult lo change: if it is mentioned .is JO unmed.J:::irt"" \ J.l.u::
£x?f.,B:i,n lb~ foOo ~ m.3chine independent features of ~~LTORG I li1er.il pool where\'er n:qu ired in the instructions. 011.:- h.is 10 ~-:i.n 1.11::
=t:Jer.
ii Lilerak
Ans: Difl'"erenre between Literal and ~ r t
Operand c=J}~ ~ whole program and m::ike c~ges ~ben:- , ~r -W96 u.~
If one mentions th is ,·aJue m the lIL._tructJL•n throueb I.hr.:
L:
\\ -nh 3 1.t tcral.. the assembler genera1es ~e speciffed '1l11t END ~
ii, S_miboi Dclining Statements symbol defined by EQ U, be/sh.:- m.:i:, no1 tm t'" ro s.::-~
!S a consr~t 21 some other memory location.
ilil Exp!lSSio::is the whole program bu! change or.lJ the , i!ue or
Al ihc end of ,he object progrJm. a litcrn l poo l tvlAXLENGTH in ihe EQU Sl.'.llemenr ton lJ (ln~'t:'l.
.-u,s, Machine lnd,p,nd,,,1 __ F"3tllreS ~ add..ress of tht.s f enerated coostam is used as-lli"e '!rPt
Jddres.s fo, th~ michi.ne instructioi:i.
imm,•d iately fo llowi ng the END sra1cmcn1.
~ ....--e '-0:De co.:n;:,oo ~ la fearures tlut zre nm
Another common us.:ig.:- of EQ U !il.'.ltl•m~m is (1,,r . krimng
re.!Z!:'Q to m-.....=tnn~ Str".icrure. Tm: marltine-1nd..1::1e.n:i:-r.t OOU E.'1lFIL LDA =C'EOF . 0320lO TORG allows to place literals into a pool al some ot11er values for the genc:r:i.l-purpo:-: rrg~k·rs.. . The."" .l.'..-.t""mflkr
:~cs of 2S.Semhlcr 2.r-e listed as: 00'.D • ~ ·Jtion iu ihc o!JjL'Ct program. When ~c assembler can use the nmcmonics for n.-psra ll.;-J_gc hkc J-rrp.,rcr :\.
=C'EOF
•J U'...tt31:s:: l..Jlcr~ ;::.."'t' c:oos:zrus wriueti in the oper.:nd c( ~muunli.:r.- .:Jll LTORG SIJlcmcnt. it cn:ates_a liter.1I pool _lha~ X _ index n:gis tcr and s:o on.
~~ T'hn Zl 'Old5- h::vm.g l0 ddiDe m:: coo..,:,•.am - •<XI ro111:tin.~ :.ill of ihe literJ.! o,xrnmls used sm~e the previous
dsev.~ m th: ~ .:m 300 ~~ a labd for rt In n1 x bpe LTORG. Tius literal pool is pl;iccd in the obJcCt pmgr.1m :11 But Lherc arc some ins1ruc1ions '' hi.:h r..-quirr nwli~·n. in
SIC/XE ~ :: !J1enJ I) 1d..-oufied Wllh I.he prefix
=. fo!J.:ra ~ b)· a S?"'-.-""Ulc:mon o ( Uk literal \·alll('.
J srng th::- -.....mt n0'.a!Jon
WHb 1mmcd1:nr :iddrrssing. the
J J OO I 0
cfoo : 20-tD
tht· /oc,umn when: lhL' LTORG directive w1L~ cncountcn:~.
1J L~d>d : ThC" ,.J u~ of l.abcb on JUM.fut:lJUf~ Of dato l1Alu"m1; f)fVg.t<1ru on Jmc , 2/S ;,.ud 230, HA.'•:! · Ft..,,H' RI
areas U lhc .i.ddrc.)! ~ .lo.ltru,d LU ili.= :.at.err,eot on 215 IUt.'l WUJOY 'Jl) ;:; X' 05' INDI· \ I (,..) l l i..:, ,:
wtuch H Bppc..1.h 23,0 HJfJ H WD t= X '05' l 'l H INI I l..11 1 t{ l
~\tr fcntun:s nml Design Options (Module 3)
U Tech. f 1fih Sc1111:s1cr rr Sntrrd Sctil'$ lSy~lcm Sbl\w:irc) kl\J 1
, \ ~.,c11\ C-35
1
One limitation \\11·t11 th The :-anic lhm£. c:m :11~0 tx· done 11:-ing ORG Sln.teincn\ in , oennc vnrious types of expressions.
occurs in t..l • e Us.J£,C of EQU is wh:itevcr symbol , L"~ J-l Or With the '"Type" inform ution. the asse mbl er can easily
d fi :d 1- l C ng.lu hand side of lhc EQU ).hould be pn:· the followi nf ,,a) : RESH 1100
1 dctem1inc lhc type of cuch citprcssion to gc ner:ilC
e me · or exa mple. the follo\\inr:. st:1temcnt i~ not \":llid: thC 11 bsolutc nnd rclntivc expressions.
ST,\8 ORG ModHiculion records in 1hc object program fo r rela1ivc
BET A STAB t)PJ,in
EQU ALPHA values.
ALPHA RESW I ~ES B . cs of Expressions
SYMB OL
VALUE RESW I ~~:~~;v1ypc of value produced, expressions can be Qucs 13) Ex plain Progrnm block.
~sfi~:i symbo_l ALPHA 1s :is..'l;jgned to BETA he.fore it,~ 61 'ficd"''
RESO Or
· The \ ::tluc of ALPHA 1s nm known FL,\G
c1J.. .S 1 1
Jute Expressions: 1llc value of an absolute
ORG STAB+ l 100 Explain progrum block with on example. a machine
I 1) i\bSO~ ion is in~ependcnt of _the pro~ram location. The independent assembler feature.
~ues l l ) Bridl~· discuss the O RG statemenL Also li.,;;t at!o\utc cxpte5s1on ma~contams n:lanvc tenn~ provided:.
e restricti ons of ORG and EQU. · The fi rSI st-.1temcnl :i.lloc:ui::- 1100 bytes of n,crn0ry Or
:) Abso\.ute expressions may also conta.m relative Distinguish between Program Blocks and Control
:i..,,;;igncd lO J:it,c.l STA8 .
Ans: ORG Statement 1crms. Section. (2018[02])
TI1is directi\'c can be used 10 indirectl) ass.i~n v;i.\ues 10 lh~· In lhe c:ccond sta1cment lhc ORG :-1:11cmcnt initialises th a) Relntjve tenn_s. occur in pairs. Bolher of the Or
symbols. The d.uecn, e is usually e.J.llcd oRG tfor origin). loc!llio.n counter w the \'a\uc of STAB. Now lhc LOC~ terms arc pos1t1vc. Describe the concept of program blocks with a proper
lts ~cncral fom1 of Sl.3.tcmem is: point, to STA B. b) A rc\alive lcnn or expression represents example. (2019[04])
ORG ,'3.luc some value that may be written as (S + r), Or
The nc.d Lhn."C lines :i..~1;n appropriate memory storage lo where: Using the given information, generate the machine
\Vhcre. ,-a.Ju e is a const:1nt or :i.n expn:ssion in rnhing instruction for U1c instruction at location 0006 and
CJch of SYMBOL VALUE and FLAG symbols. • S is the starting address of the program,
consunL,;; and pre,iously defined symhols. 003F. Assume that program blocks arc used in the
nnd
Th:= la.st ORG staiemcnt rc-imti~li scs the LOCCfR to a r is the value of the term or expression · program, the machine code for LOA is 00 and STCli is
\Vhen this st:ncment 1s c.ncoumc.rcd during 3S$C mbly of a
new "aluc .iftcr :-.kipping the n:quircd number of memory relative to the starting address. 54 and the block table is as follows. (2020l04])
program. the :isscmblcr resets its loc:nion counter
(LOCCTR) to the specified \''3.l uc. Since the ,aloes of for the t::ible ST..\B (1.e .• STAB+l 100). . I Block No.me I Block Number 1 Address 1 Ltn!!th
c) A relative tcnn usually represents some I (dcro.ull)
symbols used :u 13.bcls are taken from LOCCTR. the ORG I O I 0000 I 0066 I
\oc.ation withiri the program. I CDATA
statement uill affect th~ , 3.lues of all 1:ibcls defined until While 1,bin!: ORG. the '-ymbol occurring in the statcmc,t I 1 I 0066 1 ooon 1
should oc -prede fined as is required m EQU s1atemcrn, V:ilucnssocio.ltd I CllLKS 12
the. n~t ORG LS encountered ORG is used to control I 0071 I 1000
1.1•ilhthcsymbo\
assignment storage in the object program. Somet.imc:s f or example. for I.hi! s::nuc ncc o f st.atcmc nts below: Loe Block Label Opcode Operand
altl!nng the values may re.suit in incorrect assembly I I ORG ALPHA Number
BYTE! RESB I 0006 0 LOA LENGTH
ORG can be useful in bbel defirutrnn. Suppose one needs I BYTE': I RESB I ii) Both BUFFEND and BUFFER arc relative tenns, 003F 0 STCH DUFFER.x
to defrne a s~mbol table! \\ith the folJo win g struc1un:. each representing an address within the program. 0003 1 LENGTH RESW I
I SYMBOL
BYTLl I RESO I
such that the expression represents an absolute 0000 2 BUFFER RESB 4096
6 Bvtes .
VALt;E 3 B\"tc:S I
I ORG value. The difference between the addresses is
ALPHA RESD I Ans: Program Blocks
FL.AG l Bvtcs j the length of the buffer area in bytes. Many asscmblCrs pro,·idc features that allow more ncxiblc
The table looks like the one gi,en below; Toe sequence could not be processed No relative tcnn can enter multiplication or divi sion
handling of the source and object progmm. Some allows I.be
the symbol used
:i.s
generated milchine ins1ructions and data to :i.ppear in different
SYMBOL VAL L"E FL\GS 10 asst!!D the neu locatJ on counter value is not de6ned. ln opcralion. For example,
STAB the rir:i pas~. as the assembler would not know what value OnJer from lhe corresponding source statements (Program
BUFEND+BUFEND. IOO-BUFFER. or 3•BUFFER Blocks.) and some results in the creation of se\'eral
(1 00 cntri c:s)r
' - - ~ - -- - - 10 ~ ,;;1en 10 ALPHA. the other symbol in Lhe next lines
aho c;uld not be defined in the symbol table. This u a arl! considered errors. independent parts of the object program (Control Sections).
kind of probkm of the forward rcf: rcnce. The program parts maintain their iden tity and arc handled
2) Relnth·e Expressions: The valul!: of a relative
expression is relative the beginning address of the object separately by the lo.1dcr.
Restri ct ions of EOC an d ORG 1) Program Blocks: Sci;mcnts of code lhosc are n.:·
The SYMBOL fi eld cont.airu a 6-b\lc u~r-ddincd I J All symbol~ u·\,cd on th!! nght-hand side of the EQU prog.mm. A rclillivc expression is one in which all of the
symbo l: VA L LE is a one-word repre!,c;O~lJon of the uluc n:lative tcm\s except one can be paired. 1lle remaining arranged within a single objce1 progr:un uni!.
statement must ha\ t'. been defined previously ID
assigned 10 the symbol: FLAG S 1,;; ~ 2-b)1c ilrld speci fi es unpaired term must have a positive sign . No relative 2) Control Sections: Segments thn1 tl.n! transhucd in10
progrcifn
sym bol type and other mfonn::suon The sp<!l.c for Ult: 1.able term can enter multiplication or division operation. independent objcel program units.
ALPHA RES\\'
can be rl!scrvt:d by tl1c Sl:.tkmcnt
~A l EOU h prcssions that arc neither relative nor absolute should be
ST AB RESD I JOO Figure 3.2 shows 1he cx111nplc of n progrJm with multi ph!
I BET A
nagged by the assembler as errors. progrnn1s blocks:
If one wlints to refer l:.QU I ALPHA
lOlhe cmm:'- of the table u,tng indc1.ed 5 COPY
~LPH/, Kl:.SW ..,. 1 - - ' ---'--- -.....,iii, START 0 COPY FILE FROM
.1dd ressmg. pl ace tlu~ offset \.tluc of the dt:~lfcd enll)' frum To determ ine lhc type of an expression, orle must keep INPUT TO OUTPUT
I.he beginni n2 of the table in the: index rc-z,istcr 1 o refer 10 Lrack of the types of all symbols defined in lhc progrnm. JO FIRST STL R61'AOR Si.W U RCTURN
the fields S YMBOL. VALLE. .Jt,d fl_A GS md1\Jdu.Jl y. For this, one need s n nag in the symbol tnblc to imlicntc
locauon UJUnte; r ,. :.ilui.: mtht have ADDRESS
he/she needs lo assign the value~ first ~, sbou- n belo '" 15 CLOOI' JSU!l RDREC
I SYM BOL
VALUE
' EOu
l:.Q L'
; \, AB
defined tnic of value (absolute or rclutive) in additiou to the vnluc
11.',t]f. M)mc of the symbol tnblc entri es might be:
20 I .Di\ UlNGTII
RllAD
RECOIH)
l NPU1'
120 •
SUBROu"T!NE TO READ RECORD L''TO
BUFFER
All cbl:l are3s that arc a few words orJcss i.niJcnglJi...
iii) Toe lhird (n:imcd _CBLKS) program block _
dlu ~ th::it cons1st of Ia,ger blocks of memQry~
.:s~ :~~~~ ·us·E
.1((1.~
~~~·· . ;
·- " CBl.!KS- · · ·· · ·
and 14 arc deleted- LDB and BASE instructions).
iii) Literal placement and references are simplified.
123 LSE ·10.i ; DUFFER RESB 4096 (include a LTORG in CDATA block to ensure Jj1erals
125 RDREC 105 O'.J{Xl ; BUFENO E U
Cl.EAR X Cl£AR LOOP 2) The ns...:cmblcr din:cr.ivc USE indicate,.~ ?'hich 20ttiolll are placed ahend or large d,ua areas.)
COUNTER of I.he source program belong to the Vanous b)oeKS; Jl)S i{l(XI - MAXLEN E U BUFEND-BUFFER
,,1 10<1000!!---'==~=-~=:=-=="----'
130
132
133
135 RLOOP
=~
Cl£~R
-LDT
m
A
s
.::~l,\..\1...EN
=ATOZERO
CL£~STOZERO
i) At the beginning of the program, statements, Ire
a.ssumcd 10 be p:ir1 of lhc unnamed (defaultblila},
ii) lf no USE s1a1cmcnts arc included, tfic Cllti.te
110
115
SUBROUTlNE TO READ RECORD
INTO BUFFER
The use or program blocks could satisfy both machine and
human factors:
i) Machine considerations suggest that lhc - parts of lhe
L\"PliT TEST INPt.r r
~ object program appear in memory in a particufar order.
DEVICE pro2 r.un belongs to lhis single block.
m··riJfr ··o··~·~~c ~~~R x ...
it~
l.!Q JEO al -Line 123. 20S - resume default block:. ii) Human factors suggest that the source program should
~ ~~t~:
RLOOP LOOP
:i~
L,;\' TIL
RE.WY b) Line 92, 183. 252 - CDATA bloc)(. be in a different order..
:fa A
Iii :~~ ~
l .!5 RD "-'PUT REA!) c) Line 103-CBLKS block.
CHARACTER U\'TO +LOT #~~AXLEN 75101000 The assembler can simply write tl1c object code as it is
REGISIB\A 3) Each program block may ac1ually contain scvc~ LiS 00.110 RLOOP TO INPUT E32038 generated during Pass 2 and insert Lhe pro~r Jood address in
150 COMPR A.S TEST FOR E!\lJ Of sep$1te sef!ments of the source progrJm. iJO OOJ-10 JEQ RLOOP 332FFA
)J:i 0037O RD ll\'.PUT D82032
each Text record. These load addresses will renect the starting
RECORD (X 00-i ➔) The assembler will logically re-arrange tliest
155 JEQ 003A 0 COMPR A, S AOQ.I address of the block a.~ well as the relar.ive location or the code
EXIT EXIT LOOP IF EOR segments to gather together the pieces of each 6loek, 150
160 STCH BLFFER. X 155 003C JE'Q EXIT 332008 within ~e block. This process is illuslralcd in figure 3.4.
STORE
5) These blocks are assi£,ned ilS .i~dre~ses in ·tlie ob}ea IW 003f STCH BUFFER,X 57A02F
CHARACTER IN H,.COPY ..OOOOOO,Jl0I071
BUFFER program. wilh the blocks appeanng m the same order 165 oon TIXR T B850
Lmc.s S-70 { T,.000000,.JE,.17206),.482021,.032060,.290000,.)32006,
165 li0 00+4 JLT RLOOP 3B2FEA ]
TIXR T in which they were firs! begun in the source PJOfr:DL
~~=--J~~~~;~;~;~~~;~~~~j
LOOP UKLESS 175 00-17 O EXIT STX LEi'lGTH 1320\F :
MAXLEKGTH ISO 00-lA O _____ _ttSlf'! ___ _ _____4El)~ __ : Lines 125·180 {
liO JLT RLOOP HAS BEEN
6) The resuh 1s the same as if the programmca;: liad Lmc iss-T,.000027,.ID,.8410,.8400.B4-I0,.75101000, E3203S.
191
USE CDATA
1~..~ ... !..!~r.1.:1:i: ....l}m_... -.~··rx.......fJ
SUBROUTlNE TO \VRJTE RECORD
:
Line$ :! 10.2,15-33:?FFA,.DB2032..,A004,.J3200S,.S7A02F,.BS50
Linc m-T..~ ,.09,.J82FEA,.1320l F.4FOOOO
T,.0000©01~Ft--~ CPAIA = 6§ t fr§= Kl
Jl.;Q R5L:B RETURN TO 1 T,.0000-l D,.19,.B410,.772017,.E320 I B,.J32fF,\..53AO 16,.
maintaining a separate location for eacfi p, FROM BUFFER
CALLER Df:'20 I~"'~850,.JB2FEF,.4FOOC,O
183 ,L'SE COATA I
block. Un Pass I):
i) Each label in the progr.m1 is assigned an a
;:-riio -o-·- ----usE--------------- ~:= 4.().'1..4S•m~os.__~~C-D-,\T_,\_=_66
_ +0-J-- -6D-1
185 L, ·r ur BYTE X 'fr CODE FOR INPUT :110 oom O WRREC CLEAR X 8410
DEVICE
is rehith·e 10 the start of the block thal contains Figure J.~: Ollj1.:cl Pn>llnnn ,:orn.-s1,011dln1:.10 ngure 3.J
1212 00.\F O LDT LENGTH 7720 17
J95 • iiJ When labels enter the symbol 1.ahJe, 1215 0052 0 WLOOP TD =X '05' E32018
200 • SUBROUTINE TO '>lPJTE RECORD FRO~ name or number i~ !.lored alongwith' thc 'WJ !XJSS O JEQ WLOOP 332FFA The first two text rcl"Ords arc gcncr-.Ucd from the source
205 •
BUFFER relati\'Caddrcsi.. : :;:J ~0CH =;~r;:m, Xt3~g~~ progr:un lines 5 through 70. Wlu:n thl! USE stutemcnl on
line 92 is recognised, 1he asscm.blcr writes out the current
208 LSE ms OOSE TIXR T URSO Text record. The nsscmbler then prepnres to begin n new
11.:tl fl()(i{) O JLT WLOOP 3Il2FEP 1
2 10 WR.REC CLEAR X CLEAR LOOP Block n.amc Hlock numlH•r Address :!JS O'lf,3 _ O ______ RSUD ________ 4R>OOO __ :
Text record for the new progmm block. The statements. on
COU~'TTol< (do:faul!) 0000 lines 95 through l05 rcsull in no gencm1cd code, so no
11 2 WT J...fJ\GTH
,m mm I USE CDATA I
new Tex1 records nn: created.
CDATA 0066 1
m LTORG
1 15 WLOOP TO =X ·os TI,!,'T OlffPUT CBLKS 0071 I !XX'7 J .. =C 'F.OP • 454FM1
DEVJC[ • IXXJ!. I • =X 'O.'i' O,'i Tho nest twn Test rcmrds come from lines 12$ thn.mgh
220 JEQ WLOO P LOOP UNTIL 8) For code generation dunng Pass 2, 1hc asse '.l~S- _ _____ ___ _ )lr'l!J ____Ftl(§'J2 ________ ! um. This · lime 1hc SllllCll\ClllS lhut belong to 1hc IW:\I
READY to rcviY.: U1e address for each symboJ relative CO 111:011· .IJ: faum11ll! ufM11lll11l1· l'ro11n1111 Hlock.-; wllh Ol~l'd Cotll! pmgrnm block do result in !he );lll\l'rmion of objt"C'l \'\'11.k•.
kr h.'lltnri:~ um! nc~l gu O ption.~ (Mmlull! J) (;.39
rr Sofrtd Series (Sys1cm Son""") b.. . ,,,,,1111
C-JS B.Tceh, firth Semester ""l,\J
TD INPUT T l!ST INl'UT 3) Two ussembler dircclivc s arc adopted !O •,olvc
1sections :H'C most oncn used
1~ 1tlJJOI' DUVI CI!
1 ex ternal reference problem:
TI,e firth Tc:\.1 record con111in." the ~ ng\c by1e of the d3t3 Different co~!: ~ubdivii.ions of I\ program, JI :Q Rl.001' LOOI' UNTIL
or other logic; ; cr.- to ~"-S~~11blc. load, nn~ Rl!;\DY i) EXTDEF (Ex lc rn • l J)efinillon)
from lmc 185. The sh1.h Text f'CC'Ord rcsumc..1; Lhc dcf:wlt 111 11
allow~ P~fr.lcnhancc f1cx 1b1hty. Control sccu I<D INPUT REAU Cl·IAIIACTER a) Name 1-,ymhols as cx1emal symbols lh t an;
prop-an, hloc.k and the rest of the objN't progr.tm
comi nucs, in .;:imilar \\ a) _ ~P."::!~~~! means for linl,..; 11 g them together.
COMPR /\ , S
INTO RCGIS'll:R A
TEST POR END or
defined in this control section and may be
pro\1v<,. •. • used by other sec lion s.
RECOltU (X'IIO'/ b) Conlrol section narncs (e.g .• COPY. RDREC.
ll doc..i. not m::mcr 1h :n the Text re...'"Ords of lhc obJt"Cl . mnl n:fcrcnre." that rcfercn~ m,struction or da, . EX IT
Some JEQ EX IT LOOP IP EOI(
e,\IC
' ._cctions need extra mfonno.tion du;'l and WRREC) tire automatically considered
progmm are no1 m sequence by 3ddrc..,;;s:
I I The loader \,; 11 simply lood I.he object cock from c:ich ~m~n~
linJd~.
~;~:sc
1
·control scctio~s nrc indepcndcnuy 1~
~ lhe :1,,;,.,; cmblcr 1s unable 10 Process u,.....
155
1(,0
+STCl-1 DUFl'ER , X STORE
CHARAC!'EI( IN Io be cxicmal symbols (Linc 7).
record J.t the indicJ.ted oddress. BUffER ii) EXTREF (External Reference)
:ind rdoc.1t~ . the usu:il w:iy. The nsscmblcr gc .. II.SC TIX R T ,LOOP UNLESS MAX
2) When this l~dmg ts romplctcd.: .
1 a) Name sy mbols that arc used in this control
rcfcren~ ~ ~ch C.\tcmal reference that will all~ LENGTH
1) The gcncnted code from the default block mll infonnauon..ror the required linking. wlhc JLT RLOOP HAS BEEN
scc1ion and arc defined elsewhere.
OCCUp) rd:iti,·e !('IClltiOn.'- 0000 through 0065. loader to pcuorm . 1iO REACBED b) For example, BUFFER, BUFEND, and
+STX LENGTH SAVE RECORD LENGTH are defi ned in the control scc1ion
ji} 11,c !!cner:tled code :ind n!SCJY(d ~or.l£C for Toe mljor bcnclit of using control sec tions is to illertasc pS EXIT
LENGTH named COPY and made available to the
CD.-\fA \ \ ill occup) locations (066 through 0070. ne.\ibilicy. RSUB RETURN
,so TO olhcr section (Lines 122, 193).
111 ) The stor.i.ce rcst.I"\cd for CBLKS "; 11 occupy CALLER
Control Section E'\-nmple , BYTE X'F l' CODE FOR INPUT
l~t.1on~ OC); I through 1070 . The figure J.6 ~l~ows example program of control ~on l~~ INPUT Ques 16) Draw t he block diagram or SEGDEF,
DEVICE
EXTDEF, LEDAT and FIXUP records or an object
Figure 3.5 tr.lCCS the blocks of the example progr.im .. ~5~~~..!i.~r;;k;:-·. -o COPY FJU···· 190 MAXLEN WORD B~~~D-
record. Explain the significance or each or them.
through this proccs-s. of a.,;..--e.mbly and loading .
()(XX) ,·•0-'-fiifr.·· ·eiiffiR'. ···-/J'!l!\ff.1'9.~~I] ~lgJ·~~r~~~( :: ~$~0 .... -······ ·. --... ____ ..... _.__ ········: Ans: Signllicancc and Block Diagram of SEGDEF
: 81.Jf'END.
·19s°• SEGDEF records describe the segments in the object
:
100 · SUBROUTINE TO WRITE RECORD FROM
· LENGTH ' BUFFER - module, including their name, length. and alignment The
:·•o-ii<Ef··,~~c, \ 10s • record fonnat is ivcn below:
.. EXTREF LENGTH, ' 98H length Attribu!~(l-0 Segment kngth N:11DC indc:c Chcck•sum
ID FIRST "si"i:"° .. .. RETADR ~i,~ ~ 207
... DU FFER __ . __;
210 CLEAR X CLEAR LOOP
+JSUB RDREC COUNTER Significance and Block Diagram EXTDEF
IS O.OOP
~RD 1NPUr 212 +LDT LENGTH EXTDEF record contains a list of the e:ctemal symbols
10 LOA LENGTH n; WI.OOP TD =X-05' TEST OUTPUT that are referred to in this Object module. These records :ire
~ GTII~ EOF DEVICE similar in fun ction to the SIC/XE Define and Refer
25 COMP #0 JEQ WLOOP LOOP · UNTIL
0071 ENDFJL
2.?0 ·records. Both PUBDEF and EXTDEF can contain
30 JE-0 EXITIFEO READY
+JSUB WRREC w +LOCH BUFFER, X GET CHARACTER information about the data type designated by an euernal
JS 1~5
RE FROMBUFFE~ nainc. These types are defined in lhc TYPDEF record. The
J CLOOP WO =X'0S' record format is given below:
"'~5 [!',.l)Fll. LOA =CEOF
VD WRITE
CHARACTER I SCH I length I fatcmal rdrn:ncc list I Chcd:•sum I
!070 2J5 TIXR T LOOP UNTIL ALL
50 STA BUFFER CHAR,\CI:ERS
f'ir;:tUT 3.5: M: ultiplt Proi;nm Bkda aod Loading Proa:ss; 55 LOA #l Sign ificance and Block Diagram LEDATA
2~fl JLT WLOOP HAVE BEEN
60 STA LENGTH WRITillN LEDATA records contain translated instructions and dat:1
Ques 15) Describe the Control Sections and Program 65 +JSUB WRREC I'S RSU13 RETURN TO from the source program, similar to the SIC/XE Tc.~t
70 J @RETADR CALLER record. The record fom1at is gi,·en below:
Linking with Control Section tlample.
m END FI RST . AOH lcng1h Sq:mcntindc.\(1•2) D::u:1ofrsc1(2 ) d:i.ti Cln.·d:•sum
Or 95 RETADR RESW FIRu•c 3.6 Control Section Exum ple
Ho~ an amtrol sections dilfe:reot Crom program blocks? JOO l.£NG'Jli RE.SW
& -plain. with proper =mpltS. Th• pll!J)OS< of D.'TREF Explanation Significance and Block Diugrum FlXUPP
= d EXTDEF assembler directi••es. (2017 IOl]/ !OJ LTORG !J In Lhis e:wmplc, there nrc lhrec control sec tions: FIXUPP rccortls ,m: used to resolve c:ucrn:il refcren~s..
Or 105 BUFFER RESB 4-096 i) One for the main progrnm - The. START and 10 carry•out nddrc.ss 1i,odifications that are associn1ed
What art- Control Sections? \\"h2t is the ad,•antage of statement identifies the beginning of the wi1h relocntion and grouping of segments within the
106 BUFEND EQU
us;ng th em? (2018103]/ a-;sembl y and gives ;,1 name (CO PY) to the first prograri,. This is si milur to the func tion perfom,ed by the
107 MAXLEN EQU BUFEND-
Or control section. SK~.':Vl-1 Modificmion records. However, FD(UPP tt-1.."0n.is
.. .~llFFF,R
Whal a rt· the Use5 of ru.scmblcr dirtct.il t EXTDEF and "j09 iio"ii.ii .. qtj_ 1i) One for the RDREC subroutine - The CSECT urc substmuiully more complc..x. tx--cnuse of the more
EXTRE F"! (2018103]1 I IO • statement on li ne 109 bcgim; the control scc1ion complicntcd ohjcc;t prosrn m stmcturc. A FIXUPP T'eC't}r\l
Or ll 5 • IUlltE C. must immclli:udy fo llow the LEDATAor UDATA ft'<.'O.f\l
Wb::i.1 are conl.rol S<.-ctions? lliust..ralt '"ith an example, 111J One for 1hc WDREC subroutine - The CSECT lO which it npp lics.
120 •
ho w control ~ectiom arc U.!,e;d .and linked in an 9CII length LOl;':11 Fi, \bl frnnw..• 1'1\1}..... I Tv\-ct
~sembly language prc,gr.im.
122 ·i.irREi-... iiufiiER:·· !ilatcmcnt 011 liu c 193 begi ns the cnn1rol section
(I) (I) W\tum ( I) d:itum(l ) offsd (:!l
Cb,...,_~
~um
LENGTH, WllltEC
BUFEND Co111rol M.:l:\ IUll t> urc lmnd lcd scpnru1qly hy 11\~
Aru: Conl.rul ~L-ctions .a nd Progr..un LiID.-Jng 125 CLEAR .... x···- ---·· 21
Ques 17) Ho w l'X ll!rmtl rcfl'l'\'lll't'S tH't' ~ed ?
A comrol .sc:c110111~ .i p.ttl of the progroirn th.tt m.i.int..ltlns ju. ''"c r11bl cr. Sy111hob 111111 nrc defined In 0110 control
1dcnltl) aih:r .i,-.cmbly E.tcb control iectJOn c..in be Jo.,.ded 130 CJ£AR A
M' L11c111 111u y 1101 he used dlrcc lly hy nnolhcl' cont rol Ans: Using ~ hmml nrr,•rcm~,s
.uld reloc111,ed mCkJKndcmJy of the othen 132 O.EAR s ,cuum They 11111 s1 he i1Jo n11ficd ns cxturnul 1110 opemnd (RDREC) is nl)mcd tn lhe B..'O"RE.F sttU\"tueut
Ill UYJ' MAXLEN rl'lt·1·1•11cl' fo r the louder m lmnillc .
B T"·h. Fi11h Scnic•I" Tl' S11li rd Series IS) ,1,111 Sofu,'lrc) . ,111d Oc>1~11 Op1iun, (Module))
C--lU ~ .,11tilcrFi::1u1n:-' • c...1 1
,.. rlie)' arc rcfcrcnccJ . TI,is rcstric~ion is not roo
,ef·"" ~ro,c
2) The other type produces the usual kind of obJCCt
Refer R«'<ird • l\lgr.inuncr merely places
A Rcf<r n,•,ml 1,,1, >! n,twb 1l1al .,n: us~d as nil stomgc rcservntion
l"•"'""I hy EXl ~
'\'-"-'-X ;:: -l..'\ C2nr>..'< a.,,"'"mN~ r-.:-" Ju: program for later execution.
..i'' ,i,,, ,ttp I111,;• •,1·,rt
1"·.,c of the progmm mthcr 011111 ut the end.
~!~
n:fcn:nr<> h) ih,· ,,,1111,,I "-..·11,rn
,,,11•·0 ·1 ell'. forw:m.l references lo labels on mstrucuons
' • •
L!S Col. I R - ---,--- Onc•pass a.<scmblcr.. that gcncrntc their object code in
OC\)_S
0.0Qp •JSL'S RO'-EC J61C\'\'\\l1 Col ; .1 ;\..i~ ~ ,,,.,1,,1 "·1,-m:J 10111
~
tl,,,._:;;-- . ·.,f,<11111'11 ·- 1111a1cd as ca.sily. The lope of the program memory for immediate execution. No object progrnm i,
[:oa l" )ICC1'" I
e.~amp c. .m .escaping .
,
l\.lr
-sn...i s_t,_1'FE!l x = ·, x\1. ~ - ~ h .rC ~ ..•,.~ . a forwanl JUmp - ,or wri1tcn•ou1. and no loader is needed. This kind of load•
,,· 1u1n:s d. . R ..
\,1\·11 11.")(} nfh.:r tl•sting some con all~n. equmng th.it the
f Th\.· l,lhl·r ,n(\mn.1t1\'" \,f P""grJm hnldng is add and.go ussembler is useful in a system that is oriented
(1f',.'\..J:- = .l..' ii'"' l It ~ diminatc all such forward Jumps would be much toward progr-Jm development and resting. In , uch a
The: ~mb!cr
a.s..... ~ no idc-.:i where the control
m.,;l111,·:111on 1:1~ 1< Cd lo Ilic .,.:n•01111' .. :ind ,ncon\'cnienL Therefore. the assembler system. a large fraction of the total workload consist> of
:O:C\:'UOn r • 111cU'" . . . , h d1i ,
,., re> ,:tkc sortlC special. prov1s1on ,or OJl ng ,orward
ronUinini; RDREC ,nu be: loaded. ,:o i1 cOJ1no1 a.;:;;emM<
lhc :id dn,,,s for this instruction:
~lodific,ition
The.' nt" item:-
R,,...,ro moJ1tic:1u~n record 1,.,1
11 To n:ducc the size of. !lie problem, man~ one-pass
progmm lr.inslalion. Because programs arc rc•asscmbkd
nearly every lime they arc run. efficiency of 1hc assembly
111 thl' .
I) Rds tfrc, 3ddrcs:sing ,s no1 po..<Sihk durinf m,, !Jti_.Jti,,n t<' tx· 1x-rfon11,-J: :,Jdmg or subspctjfy Ilic r.f1J\'.ncCS: do however. proh1b11 (or atlcast discourage) process is an importanl consideralion.
niblcr> d
,._..:-,rd n:fcrenccs 10 ata .ucms.
.
J...<&,mblmf . , -:ilu,· ,,( ,,,m< ,.",·m., 1 >! mbol. TI,c ~0 cling Ilic
2l Ao extended format instruction mu.-1 I'< u.-..-d t,, m<X11ri csti0n n'-''nJ ,s .is 1ollo« s: rm11 ~ ic''' r one·Pass Assembler A load-0.lld-go assembler avoids the ovcrhcld of writing
the objcc1 program out and reading ii back in. This c:in be
pro, ,d-, n'lOm for u,., ocnul address 10 bc: 111---=ncJ. c=;;j I '~I -
c,,J ;... ,s,..rnnf ,J~>-' oi 1hr field 10 be modi _
Of °.
f)P'5 11vo main types of one-pass assembler: accomplished with either a one• or a two-pass assembler.
E.\'.tc:m3.I n:f~n.x n,,n: :in: p< produces object code directly in memory for However. a one-pass assembler also avoids lhe overhead
- - - - -10'lh:J,,:<•""'"~
-- ,,f 1hc control secuon (b r,Cd. n,l.ll'
JI one iyd'rale cxccuuon
~
. (Load·and
c~t ,.o ·go asscmbler): of an additional pass over the source program.
1-=-., ro:..., \ I 4....\ lE
.I u n, <h ,,i 1h< ridd ro be modi!ic'd
,~, ~ ~1m.l1l. . in hilc~~
n,ntC
1 ·
1
\\'O!U) Sl "FD-1>-BlTI'ER ('(\"\.\ '\1 7 illusu-atcs Ilic program of both types of one-pass assembler:
.t_O"' I ClX' \ 1.. \.\l2' ,C(•l lCl ~kdlli.:Jufln fl:i!: (+ tie - ). r,gurr 3. SIC 0 1000 COPY START 1000
E.Q_t· Bl "FD-1 >-SlTFER
Cl.,, I J- !o E, tl."mJI :-ymhol \,hos: ,·alut: i:,. to be ad-- I 1000 EOF BYTE
~
C'EO!' • 54F-t6
,ut-lr-"IN irum th< indic,1cd field . <l<d to I003 THREE WORD J 00000)
1006 ZERO WORD U 000000
L.~ n : t ~ ,, ~ t."li;- ' ~ -~ en ~ o.kul.u.:d d.....-u:~
For e.,::unple. ObJ,-.:1 code "ilh relocation by modifj • , 1009 RETADR Rf.SW I
.;..,-.e~!....,.::
5 tOOC LE1'GTil RES\\' I Fo"'ml
mil be
n,-.'-Jrd CltiOQ 6 IOOF BIJFFER RESB >096 rcfc=cc
Th, - =mble:r m.1..<1 ;,1so allo\\ the s:irnc 5'1-mbol to be ~I' CO-)()()... 05 + cop)
used u, diffc:rait root:ul sc-cooos. For ~pie. the r.~ ...~~~ ... ~~ ......fil.... .. ....~ .~tl!!, ..... ...... !~!~ . ...... /
,,b~rr. : ..15 20J2 CLOOe JSUB RDREC . . •~~92!'.. _.. .. :
ronfurong defi.ruu oos kg_ :\U..'Q.£\ on hnc.s 107 . ..20 .. 2015 . . LOA
{ t::Ji:::J!fi:::::::::::::::;~~~::::::::::riij::::::::::::m~t:::::::
~! = )loJific:,non Rcrord LENGTlt OOIOOC
..nd I 0(1, .:O."-"' oo Problem: ()."\),,()'" = Sur.inf ,ddm-> of lh< field whose vnluc is !5 20lS CO,.1P ZERO ~~J~--- -·· ·
, ' A n,:erwce .~ :\[AXI~ in the control s.."Ction mc.xlificd n:!Jti,< 10 bcfinning of lhc progmm "I be
COPY would see the definition on line 107.
05
= L:ofth o: th, ,ddress field to be modified in lalfli)tts
u _.; :-,;=nc,, ro :\L.;,\'.1.E.'\ in the control serooa = \ lo.1Jficcuon fl,g ·, 05 20!4 ENDAL LOA EOF 001000
rop) = E,\1<mll symbol copy 111dica1es lhc suuting ~ 50 ! 0!7 STA BUFFER
RDREC -..ouJd see the definition on line 190. OC!OOF
th, progrun « h1ch IS to be ,dded wilh lhe ~ : 55 ! 02A LOA THREE 001003
3 , \\'c ::ieec r-.. o '"" rccc:-:l types in the obJect progr:,m the obJCCI code --_..,- 60 2020 STA LENGTH OCIOOC
-'Dd - c'W., f< in J pre:, 10usl) defined record type to
Sinte the modific,.tion record dep~nd u~-:-ihc ;. ~ --·i~~~· ············· ~:1:.8 ........ ~iR ···········:;~··-·····
mciude L,Io:n::!l.!oo for the !ruder to i= th,, proper 75 2036
, .J ~o
crdutecrure of machine. ll d i be cffic1en1 to ~ RSUB KOOOO
\I. nai reqwre.d.. I 15 SUllROlJTINE TO READ RECORD L''TO BUFFER
rdo-=on b) using lll)' oth<r method. - 110
121 2039 INPlTT 8\76 X 'Fl' Fl
Ques J6 I Explain the folJo,.ing records with respect lo 122 .!03A ~t;\Xl.EN WORD J096
SIC/XE: ASSEMBL~~ DESl~N OPT 12J
001000
I I Define R t:eard 2 J Reier Record 1:?5 ! 03D RDREC LOX ZERO On006
130 ! O.t0 LDA ZERO 001006·
3 I -' lodificalion Rt:eard Ques 19/ upilin single pass ass.emblers and its 135 ! 0-13 RLOOP TD INPUT E:0!039
Or Or l>U !O.t6 JEQ RLOOP 3020.tl
u-plain the fol'Tll2t and purpose of Define a.ad Refer Define one p JSS assembler. 145 20l9 RD INPUT DS...'OJ9
records in the object program. 150 20.tC COMP ZERO 2S lll06
(101i [03)) Or :. _155 .. 20.tF . . •.. . • • • ••••• JEQ• . • •• • • • • _.EXIT •• •• •• • •••.•• . 30205B • ••••• :
Or u plain the >1orking or an) one type or one pass 160 2052 STCH BUFFER. X S-1900F
\\.rite d o"n lbc format of -'lodillcalion record. Describe Or 165 2055 nx MAXLEN !C1C\3A
each field ><il11 lbe help ofan a.ample. 170 2058 JLT RLOOP .'S~ .'
(2018 [03]l Explain tht II or ki ng of a single pass assembler 175 20,n EXIT STX LENGTH rorooc
Or =m~ ~ l SO l05E RSUB J CllOOO
Explain lh, format of Defin , and Refer Rerords. \\'hat 195
are tht:ir uses·! Ans: Sing.le P...s ,\>semhltrs/On c l'ass Assembl 1<XI SUBROUTINE TO \\'RITE RECORD FRO~! BUFH, R
(2019[03]J
ll perform, .JI oper"uos, ,n on,· go Onc-pa.,;s 205
206 1061 OUTPUT BYTE X 11.\' ll<
.-\.ns: Odin~ l<tCOn:: {&1...,tcr .,!.' tt ~v:, LJ'_ruJfh J11 ..i.,"<mbly l.!.flguage 207
A Def= rec,x, _;;,, es mf=oo .sboot ~>.t.em..J ') mbo!• ont.< lh di,ad,antagt " that 11 d0<, 001 provide !tu 1062 WRREC LDX ZERO l).1 (().10
th:ll &c defined .n tru, control ><:CUO!l ll!WlCd b) EXTDEfi f<21urc-- "' " l\l o-p.,,,, ..,,c,nblcr :\1am problem in 215 206~ WLOOP TD OUWUT rn:,,.1
1
Co! J D 210 .?tk'1~ lt Q \\'LOOP JO~~'
..i..,-..c:mblc J prO'_µ-.!fn m one PJ..''> 1m ol, e~ forward 1()(111 llll!H ;K, :>:
;?1Ci l.llCII 51NOO~
C ol ~-- , 4Icuf c\.ldl.i..J ,\mbo! dc1'"..r,c:c! Ul ctu .. 1.AJOuul ~.JO Jn,~'1J-~un upcr.!lld, oltcn JJC ' ) 111bol, that have 1)01 1UI 20,,1: WO Olll l'l ll' oc:001
Col b·IJ Jd.Jrr- uf ~~mb,,J -....1L~w U,,- c..onu,,I -.c.1.:t.100
Rc;_[J c: dcfiscJ Ill ~"' ,ourcc pco;µ-JJ11 ·n,u, lhc ~ mblu 2H 1071 TI X I t Nt.TII X l lX\('
th.:• -J::-... n1-:, 2111 )014 II r \\'l 001 1 .lS.!t\(\.'i
~Ji() , 1 ,\ h.:.t .ddrt", t11 Hl"'l(..n 111 the tr..,n~lated 1
Col i~-7 : Rc-pc-.11 l-li 21177 RS! ltl ◄n\\X.'
i•: ~ , ..:,l-·,,1 .., ,,, Cu, ~- JJ f,,r ,.,~her c.Llari.;..!
t .1.): , ,, t-limjn.:.itt for.,ard n-fl'rt:n(.~ to daw 1 1,Cj liNll MKSJ'
...
.. \;J)l)( •
,,,,pJ; rcqJ11, lh.•1 d i ..u,h Jrc.i, he defined m t'luun- .\.71Our l'u.'"' A» ,•mhkr l\X'llmnlt
t .I
, .. •, nnJ Oesl~n Option, (Module 3)
C~- 1lcr fcn11111:.
8 Tedi Fifth S,mc-l <f rr st>J,wl :-rrir< (S)s1em ~-...
~
B ec;i1b.... : " " ·.. \ ~(Ill I
1 """"""tl ' f Slni:lc l'n.~s Assembler
foru ;!J',: -... ...."! !'.'•',;r= ,, v • :"_-"<'J ·~ """"'"' r.uha tlun t,:,,nc " ri1tcn-<,u1 on ,,,-ond:m ,10.,.•c L 11 11 than :1 two-pa" ,1\-cmhlcr. It " .c-, tr.r
progr.,.c -
.., '<"C\,:,-,-.. _: r-o.:!d:_'
.... ... '"' ·111::-ul . " . ...., ' ,,ch 11•11rk1 1! •\ "c,nblcr scons the input tile only once. ·n,ls, ii is i;cncmlly fa., 1cr
. llld1th. scmbler. Howe ver, 11 need, ,omc cxtrn d.11a ,1ructurn :onri P""''' ''"l ·,,
~
1 ~ .' 1 The :1.--,.cml>la ,,mpl) ~-c-ner.irc> (,!,Jl'\'.I c,>de ,n,truct1on, .1., it <c
~ s~
. 1t,
d< ·, · struct11rcs ns the two-pnss
~
. Illfs. II11 .
IIL<t?ucr _ , ' 1. .., ,,., ,,.,,_,- ,I .,in~lc·l'" .
p.c:sc., · -.. ·" ' _,... -• --~ ,~-""-' " ' ,, m'-·I ·•- hJ.., fl\){ yet 1\,-cn defined. 1hc ,,rcr.uid .1di' n.·ss I< 0 111111
.., Ix - ·. • '" u..1 ~., ,. 0f
.llll, ,.._
,.1111c ~c ·~ n:nccs 10 symbols dcfi11cd in lhc lulcr pnrt of the program (that 1.,. rcfcrc11cc, to ,ymhol<occumng before
1
" l~........ hJnJlc th e re c·) For cxnmplc, con,ider the following piece of code: .
;,.· ,;; .'"" « .,,.... '" """" '"''' .~ ,, '""'' "'" "'"''" '"'" '"of thlty .
~
.,,. " '" .: ._.,., " "' ., ·· - <\ ,..~ , .. Jc tlui lM '°)mNI 1' undcfinN The JdJn·-.,. ,,[ 1ht· l'JX"r.111J licld
Jcr,11111ons • .
---
the dcii- u.nJd:n~ il1''r
pron.-,- " •", . - ,~rn~J . •1,..., I> .>dJru to J 11,-t ,,1• fol'1:1N rel<n-n..'<'>
• :1.<>s •:•,, ' 1<11h 1hc ' "nbol t" bl C
~ ~
"' " ' "-:-cd , _> ,n..'\"1n.etN. the fo1'1:ml rcfcr.r..-c h<t ,~,r thJI ,, ,,t--,J 1• ,,.,nn,,f
~
t:,b)e . 111 one C.Cl!Ir)' X : db 10
~~
r-•
ts).~
. . .'.JJ 1t\C .l:·1,:.. ,:Oon,, pn:1100., l) ~= I N Th< fl):IIN' ., S(:ll ,h,.1'1' the llhJCCI C\)(!e
= ~ .
I.ta< JO of the pro.;r:1m ia figurt .l. i 3lld S)
-'--f--.>l '<W,~
\ \ \ · ' \\ \
LD°Gill
~R[C . --
n,.-,JJ...-.....,, ( t.t,.,,~--,'\l :·.-',11:<ll' o•>"n.«n('(j
,.,s_:::: \ • lo<t MOVAL,X
MOVAL,X
~ ~
Y: rcsb
::OI C L:~:~./ ~ i,\~
~:, ;,"
\\1-.,EC . - 2i11 F OJ . • when the assembler r~c~es the line "X: db 10", it makes entry into the symbol table and ~,multancously generate,
'-'"~ ' u.u.uu '-''"'"""'
.,_f
'"'""~ / EOF ll\Xl
..,,1c oj 11,n:. ,~serve one byte m11iahzcd to 10. Thus, when the assembler reaches the lmc "MOY AL. X", !he addre" of X "
'~'- --..,Xl:crc :St('(k).~ __ l .,_.......
cod::° avai lable in 1he symbol table which can be u5<:d to generate code._ However. a_c the very next line. · MOY Y . AL" r,
- -,<: '/ ✓- .v
7 Y
31 sir~plc process ~- the IYP,: _and addres_s of 1s n_o1 k~ow_n at this point of time. These lnf~~a1ion
10
only be "''!I
will
~ 6.-,::: (.,..,._4--:j ft'C'Cli.'X o.:,.-=.-,-:j 00 ~ ,e I~ S l "FfE-' ll\lf no . ble when the hnc Y: rcsb 1s seen. This type of s11uauon 1s known as fonvard reference. S1mdar cond111on,
31 1
<y.:;_-..:, :!:::-~_'.),j RDREC :--' ,,..kSx· aOO? : .11: ."' ~or branch targets, which arc not yet seen by the assembler.
~· :\)1f
:111se I'
• J- :--::._~ ::,c ..,ir..',o; :..!-.:
t=r, 3.S., l: Objcct ·Cod, and S,mbol Tahl< Quts 20) Explain lhe load-and-go assembler. Tite load and go assembler program can also called the /ibrar)
;>;c ~ ~• ·, - -- •, • r.¢IL"" -'-"
, " • .Jkr =.,m, i f I 60. Some o f t hc ',orwan:1 rtfi
me subroutines if required. This type of as.sembler program ha\ th:,
:o si[U.llloa
~
b,. ,.t,,;:.~ : o ~ d ; th:,
h.. ability 10 design code and test cliffemu proa..ram romponau; in
1e c ·.·.. __ '-: .r-, .. ,,::i: ,.-:cl, "-'i:r !J.::s be<'tl ~ \\"o<n :he ,,mt>ol D,l)ffi. ":i:, defined the assembler Pbci, · 1 15: Load-and-Go
Assembler
,-a1..,, · '- , · '1- "' c-...:1: ,1 thr::i 10...,:r-.a:! lhL, 1-,Ju: l.lllO u,,, u:_c-u_-~.:,n· op:r..1>d field (J. I addrcs< 20JCJ as di,,.~~
' ........, lb
~ ad-and-go asse~blcr gcne':'tes !heir object_code in parallel. Most of the assemblers are further di, idcd as:
.
= _---: : ~': '
lorv..c-.: ·, - -• - • . ,-_ ~~- p.:,:m on. ;.:ii ref== 10 E\DFIL uoold not .__
~ .
r _ _, r -- .....,
'"' ,01'1.uu rc,crcncc and wouJd ...,
• • •-'- ~.r.~.:.::i ~i, Jef.cno:i vf RDREC resulted m :h: 5.llinr Ill of L~< oper:ind address. at l<>cati
by,l.
IIOt be
memory for immediate cxccull?n. No p_rogram 1s wnl~n
001. and no
loader 1s needed. It 1s useful m a system that 1s
I) One-Pass Module Assembler. In this .:.s=bler. LJ,;:
cranslation of machine op-code for mnemoruc. m:rln.-:::
h:,e bo::, Jdd:,:d _ 1o \\"RR.EC :!.'.lrl Ar th< end of the program. any ~ EXIT oriented 10ward program development and testing. For address for symbolic and machine encoding of ch.1=<.d'
' 1':'"' ._ ' " " N :oru :::i: r::··=
e:it .. -c~~ • , :.-, • :nc.::ur ~'ine.:! symbols. Th= should be tbged b) !he :i.,scmbk r as error.,. , - ""''1:8 rxample, University compuung system for student's u~e. is performed in on a sequential p:iss over th esource ie.,L
These one pass assemblers are useful "hen ~
....... ~.... - J-.._ ill ~ =.=n
= :. ,
~:::;73
7Mi'..i:=
'ft:
lJJ Because progr:i.nts are re-assembled nearly every Lime they storage is either slowor missing entire I~. Toes<, one pc.,.,
assembler are suitable for small machine,.
S o :·~ r· ----- --· - - -~ arc run, ef(icicncy of the assembly process is an impollmlt
I ~ If ••.-7;3: .......~ ,::q;J 11/:
consideration. 2) Two-Pass Assembler: These are de,eloped for 1wo-
E".l"" Jf - - - - -- -- --·-·'
LUU,.U =<f £'>"1!. :o:: pass translation. During the first p:iss. the a.;scmbkr
,_ : :iYJ J.:J: :- ,.,,. ~~
P.£i ,i,J>;;, JJ" The handling of forward references becomes less difficult examines the assembler language program :ind
. -- --x,·ri, II C ~ c Ei..~ -. 1..E due IO me in-memory process. An inslnlction operand is a collects the symbolic names into a 1Jble. During the
1"&1
.....:=::::;;: ., ......... , IJ,).. J,_f~ C:.OOP
symbol that has not yet been defined, the operand address
,~ !
., .,,,c;. -•~ . .: ~ ~ ::,,r:x, ~ ~ :Jk second pass. the assembler gencrares code wluch 1.>
....:._. ,_, v~l:!t}J ,1,./ is omiued when ii is assembled. not quite in machine language. /1 1s rather 10 a
i'r'1.. J l :~
I) The address of the operand field of the inslnlction that similar forrn sometimes cal led "reloorable code-
~
J--:J:k.i'-' :..,..:-;,,,--,,,~
refers 10 the undefined symbol is added to a forward and also called as object code (or obJ<el module)
reference !isl associated wich the symbol table entry.
f ;:,:n, 3.8 1b ,: -\f!H Scannint Un, 60
2) When the definition for a symbol is encountered, the Qucs 21) Discuss the problems encou.nteml during
Oc.c _, q. • • h,· M r '1"=· It pmciu<c- object prO<',..rams "' OJ•pu· :ind 1s usually adop(ql oa the single pass assembly. Also write its solution.
JS assigned by [ht forward reference list for that symbol is scanned, and
... .J"'. .._;; _,. -,gc d~\JCe\ uc no: C:\ai.Jablc CJ:- ~io·.. If the o:tu.J cddres.!, . Or
'#• "''"' me proper address is inserted into any instructions
cou.ctrr - o:..,c oc 1rul.UJ1sed to the actual progr. m SW-ur g "ddrcss •I as~mbling time. WlJai
"=L lhe
;J.'51:-
previously generated. Define lhe forn'IITd refercn= problem of single pas,
dcJ.: .,...,, c-.c••--·= ,n, !!lJctJons th:it made fOf"ard rcfetrO<.c' 10 ui,1 >)moo! me) no longer be available assembler. Whnl nre the solution.s for this problem?
lllffiC!'"' "' '.t~. v· 1• t encr.J. !he~ h,, e !lre:.d) been \< ntlcn Ou!;., pi:.11 of c T t lCI record in the object progqm. Al !he end of assembling, the assembler searches Or
, ,, 1h "'"- ~.e· ...,_ r ~=r..ie iiUlO!h<:t TeXJ record -.,th :he co-rw operand •ddre". When the prOJIIIII i, SYMTAB for the value of the symbol named in the END Whnl ls mennl by Fon•'IITd Reference? How ii ls
Ju.,,J, '---= ,:.:,oc-.cc .n,~ I.he 10<!."\,:t.Juo b):oe •• 1,1,n of !he lo•dcr figu re 3.~ illu,tr:tle 1/m proce.sa. resolved by T110 l'ass Assembler:' (2018(031)
(:;, :_;;-::,. ~'(JI ' r"
swremenl (in this case - FIRST).
• '~J Y( I ( f .J' '"" . Or
't f ,, I I , .._ .;. • . .I '/.J'/ .1 f/ J l l.1 t ' Whnl do you mean by fonrnrd rtfcrenC"e? How ls
' - I#• , . H / '/ ✓/" ':.! J'.1/ >.IJ H 3 f.l.lJ ..I - - • TI1is is 1hc simplest assembler program. 11accepts as input
fonvnrd reference humlled by n Onr--Pnss ,Ls,,,mbltr
, ~
_;'-·:',,J,,'~.t-:::~;:~2-I,-H/f '11, , ' l l f f l.'I/
a program whose ins1ruc1ions arc essentially one to one
corrc,pondence with those of the machi11c 1:rngungc, but 111111 gcnm1t(-s objcct code'.' (20!0(lJS) I
- II '• II ,·1111 !,-. 1/ , : ( _-l, / ,:,•,.:
,yix,Jic names u1<:d for op-code and opcrn11ds. The output
of ihe load and go assembler Is the muchinc l,mgungc, Ans: Prohlrms Enrountcn-d duriug Sini:le l\t-.; ~~mbl.)
,. 1, ;-,,. • L A single Jlll~:,, n:,,\icmhlcr :-.hn~., :,.nmc pn,t"lk11b ,1$ foll,\\\,.
'f ,,c:,;, - ,, 'ff' J "/II wl11d1 i., loaded dircccly in 1he memory nml executed.
I) Forwnrd lkfrrencrs: A for11,ml n:fcn,n,·c h ddi~ ~-
,,1
. :: , -
•,..:.J! J
I .., ..,. _,__- --- ·n,c ,c, ulranr, machine l11hg1111ge occupic; s1omgc n type of in,tmCll<'n 111 1he L-W<' \t'gmmt lh.lr "
1n_, .....,, ',:, , ' \ ·11'/lt- '. / I _, ,'If .,. .J' :./ 'I/Ii rcferenc1og 1hc lnhd of 1111 i11,1m,·11,~1. but the- ,1..;,,c-mN«
I ,, loc, 111111, wluch urc fixed nt the 1i111c of 1runsl111lon nnd
f IK)JT< J. ~: uLJtt.1 <..odt Crom Or»P,u Ao,.,ml,l,r hn.s not yet c11co11111cn.-d tlw ddi11111011 ,,1 th.It in.,tru.11\lll
<aru1111 he clrnnged , ub,cquen1ly.
. . ........... , ..1111 Desiµ.. Opilu.., (~l11,lulc ~) C-45
1
U Tr,:h. F,Oh Scni<>« r Tl' Sot,·rd Series (S)•, 1c111 Sol',,wlll'o) ,,,,•ll\\1J1I
C- 1-1 1 rcrcndlng 11 deck of curds or punched paper lllpc. W11h
,, » l t:, ,111in 11111lll•(llls,; m,,rmblcr ltl d
. •• Or CIQII,
~'l\J ,,,,, I ,\ sscnthly l1111gu11gc p1ug111111 11s lnpul 111111 modern compnlcr, this hns ccnscd to be an ,-,uc. The
I -1'•1.,. , ,~i,;~ .1
... nnl·r .._-a_no,.'t .1~mbk ~('1.H\.'t.· 1."\1UC' 1 1 M•·cpl - ndvnntngc of the mulli-pass nssemblcr is thnl the ah,encc
A '-lriCl
wl . . Qu'
II n:rls 11110
1111 h11cn11cdi111c Code (IC).
u, h L'Olllatn, fo"' JJ\I rcicn·rxx•,._ I of th< P:t.,, 1::.,pl:1in, \\ith '"unpk>, 1hc W(lrklnJ: or ,i•n1\tJ •·•111 ., the symhol. Mnc111onlc Opcndc 11110 uf crrnln mnkcs 1hc linking process (or 1hc progrurn load if
s ·p,11,111.: .
;L~~mbk·, , ·.m:- the :-:OU.n."\;, ,lc-tem~1011~ thr :-11~ .ulll :1s,;c01hlrr. . ?r (20' ti !lo...
~11tor JI ' ' •nlllll licld.
lhc ns,cmhlcr directly produce, excculablc code) foster.
,tddn:,, 01 .,11 lltl:t. J.nd ms1ru\"1.Wns. lhc-n IXL'-":: -.i:.ms thl' •'I" id ihc , yn1lml wblc.. .
C,i\'C :1n ' """pie or , ,111: . 111110 , or
whcr,• lhc Itse I) 11 1111 ' 1111pcrn1ive Qucs 23) How docs slni:lc p:•,~ 11., scmblcr d iffer from
soun.'C ~~--:1.,n. ot.•tputhnf the \'Im.ti' ,,hJL"CI " "'-"'-' · A ·r, 1·•
ll'< • 11' II\
• ,,rm:.1 the 1111crn1cd1111c code lor every mulllpass usscm hlcr'/
syn,bc.\h"· n:n nc mJ) be f-.,t"\, at\J · n:-len:-ncl'.J in :t · ,.,._-.,11,bl<r c:111 b< JUSttOr
puss 0111
(2020l~lt JI ;i:11c111c111 o r /\LP.
\ a nc-:~ "'' \\a~~ \\ "her, u~ .l$ J. dJ[j 0rx·r.md 111 ·1
I) /\ns: DIITcrcnce hclwccn Single Pn.,, and T wo Pn.•s
::,,,tatc-m•:nL 1b a,'-C'mhl) ,:-. :-.tr.tli::htfon,::irJ. r\n t·ntr~ Whnt is u mulli·P.•SS :,ss,·mbkr·! 1-..'splnln WIUI
of un ,~ mplc. 11 ,;1u11tion "her<' wr would lhe btj ' 1•,1SS JI .,,zc the 1argct co<lc (Object Code) by processing /\sscmblcr.,
~ sui
(~o19lQ3
can he m,uc m the Table or ln~mpk te Jnstructioru. 11 5yu11ic. . . Sln~le PJt'ili A..-.semhlcn. I Two l'u.~1 A~~mblen
(TJJ). This cnlr) " oulJ iJcnufv the b, n;., Ill c.xk an iL<.<cniblrr. ii . tcrmcdiatc co<lc gencrnled d11n11g p:L<s I.
"l ,he 111 Perform, trnnslalion in one P"-" Perform< 1ransl,111on in ~
"here the oddr-,•,._, of the relcrcn~ S\lnbol should be output of pnss l nnmct.l l111ermi=dinlc code is i;ivcn n.~ itsclr ant.I hence knqwn ;,.., load• pa~sc.., by u\ing diffcrcnl
puL \\ hen t~ ,~ m~r ~ acfinit10n is ~ncountcn:d. thi !- .-\n.<: Multi-r-.1.<S ,\,-,-.,mbkrs ll ~01r: 111~ . 11 wlu:rc ii is convcrtct.l into object code. nnd- 10 1t-.scmhlcr. or ani:rin rinc,nlc:,. ~
. jn('lll 10 p,lS5
cn~ "culd he an.tl} ..-:r-d to rumpk:c the- lll:!rr.tru~uon Muhi I''~ :t...stmhlcr nu::m~ more than o ne p. Speed of cxlcmuVscconcfory The procc'I-~ can be !!low if the
Ho" c, er. u~ 0i .1 ~, mbolic n:m~ j$ lhc dC"sun.11100 m :,.<.<emNcr. ~lulu p.1;.< .,sscmblcr is used ass II 'I.led b b of p11sscs Compnristin s1or11ge never affects Lhc workinr;. external ,1oragc uJCd for lR is
a br~ch i n qru.,,·t1C\~ f.1\"C..."' n5:e 10 .:i pc<"Uli.lf problem fo", , rJ n:i.-n:ncc ,n , ymbol definition. It crc•a:o elilll1n, Y NU111 er, two of. :,.sscmblcr.; based on how mnny pas.<es workm )!_owly.
A more ~riou, pf'\X\lcm an~!- ,,hcn the typ.: of J oi p:c-se, ,h, 1 ,s n,,...,.""'ry 10 process the des a_nura~c 11•·n:~han: .
the source are needed (how many umes tl1c assembler.; Forwnrd Rcrcrcncins can 'be ForwarJ referencing is cal'i ily
foru:ml rt:IC"rcno.."d ,,mtx,l 1$. uSt..-J in .m ins1rucuon. S) mt-ols. ~lulu P""-' assembler does the work ~fin1U1>n r "'.~:-ihc source) 10 produce tl1c executable program. troublesome though a procc~s as ,yn1hc._,izmg 1s on pil..u 2
Th~ l~ pc nu~ be us~ m :i. m:inner ,, tuch intluc:nccs th< rc.<ohnc- 1hc fo"rard n:fen:nces · T ranint two ~ or ~- · c•pass assemblers go through the source code once. Icalled bock•patching can be used. and every entry in symbol
0
the ~1z.c/kngth of J dccb .r:ition.. S uc h us.a~c ,, 111 h~H' :i.<.<embl) 1,ngu,~c . program _into object cod s allon 0 II A::y symbol used before ii is dclincd will require 1oblc will be complete before
lO be di~iO\\t."d lO fac ihta.lt' ~mglc p..1-'-!! :i.:~mhly ......1r
m:lfl\· Jl.lS.<"-> ,; tcm1cd J S muh1-pass a.<scmbler.C n:qu!.:. "'err:it:1•· al tl1e end of the obJect code (or, least. no a.ssin • it to pasli. 2.
•arlicr 1han the point where tJ,e symbol is delined) Back-pntching - The address ofl No need for back•p>lching.
For c..u mp1c. c0n.,i;;1der Lhc ,i;;tatemc:nt.s ;'\oJr; The i ,,;c.n1t'lkr ron\'crts the given a..~cmb 111 ~dling the linker or the loader to "go back"' and undefined operand is ominct.l and
XYZ 06 LE'sGTH ABC DIJPWJ pn.,,r:im ,nlo m1cm1cd1J1< code and then. convetts .mtoly. lan ,.
Object-.• is entered 10 symbol table and is
ovcC'vri1e a placeholder which had been left where the
ABC DD ' The schem,tic dll~ram of a multi•pass assemb . _
ler 1~
~ as yet undefined symbol was ~scd.
noted on TII (Table or Incomplete
lnstruclions) and when "the
defin ition is encountered TU is
in figurd.10. , Muhi:pass assemblers create with all symbols and
Herc the fo:w:,n:I refcn:ncc 10 ..\BC m:ikc.s 11 impossible checked and values are added_._
• 1 ,heir values in die first passes, then use the table in
loa.s,,embl< til<: DB = e n l in a smgl< P1>'- l11c default addrc., s of :ui undefined No ~uch scenario wiU arise
laicr passes to generate code. hence no such
2) Seglllenl Register..--: An ASSL,~ suncmenl ind11:,11c.s symbol will be 1.cro aud is Inter nnd
u atcd with the correct address. conventions.
that j ~frnc~l n:gi"'ter contam.s the ~~ .:sd~ of :.i Example: In the following code_ snippet a o ne-pass
"'!'JTl<nL The •~-.emblc. represents this information b) ssemblcr would be able lo detennme the address of the
No need for :m intennediatc code An in1crmcdiate code is;
fi;:urr J.10: ~tuhi-Pass Assembler 3 10 be generated. · gcnerJled after pass t lo be,
:. pJJr of th.: form 1~cnu-at rr£1S1er. ~£JTient DlJTlf'). b ckward n!ference BKWD when assembling statement o~ses to P3SS 2_
1
Thi~ infonnatio, co.., ~ stored in a registers segn;:,ot Constra1n1S in two-pass assemblers: sz.3 but would not be able to detennine th~ address of the AII the tables should be available Optob (Table conuining1
table !SRTA!!). SRTA3 " updated on processing ;in I) An) symbol used in the right-hand side (he,, forward reference FWD when assembling the branch in memory during the t.rnnslation mni:monics :ind op-«xks) b
ASSCME si..tcment Fo: processing the rderence 10 a expression gi,-ing llie value of the new SYJn , mcnl SI; indeed FWD may be undclined. A two-pass process :ind hence more memory ne-:dcd only during I~ pa..-.sl
5131
symbol S) mb ,n "" :is,cmbl) siatcment the assembler
accesses the >) mbol table erlll') of symb and finds
assemblv directives (e.g.. EQU and ORG) be assembler would detennine both addresses in ·pass I. so Iintensive. :inc.I hcne'\! can be c:liminatedj
in second p:iss. _
pre,, ou;ly in !he source program. For they would be known generating code in pass2,
l:,cg ,~'"'°"" offscL~J "nae seg ....-:e- is the name of th~ ALPHA EQU BETA IGenernlly all areas me defined Though foC'l'o.rd referencing)
symbol con12.irun2 the defirution of svmb. It uses the SIB FWD before lhey are used and back is much widely u.1<-d forwanJ 1
BETA EQU
mfonnation in SRTAB ID find 11,," register wluch patching is lcfl only for fonvnrd n:f(~nL-cs in symbol
DELTA RESW
com.ams :,eg>~rr~• Let Jt be: register r. lt now synthesLZ.es FWD EQU* jumping. definition are not allowed.
BETA cannot be assigned a value in the BKWD EQU* 11 is possible for data items. For c.,umplc,jack EQU jill is
Ll1c p:ur Ir. oflscL-,.,..1. Th, p:ur " put m the address
because DELTA has not ye! be&n defined. thou h incom•cnicnt. not allowed.
field of the target rn,u-ucuon.
2) Fo"1•ard reference prohibition is not S; B BKWD Th~ objecl code is generated inlllu;: objl-Cl code i::- wriucn-out
Solution,, for Single Pass Assembler mcm?ry but is not, writ1en out mul .t loader is needed.
inconvenience for Llte programmer. In both cases, the assembler must be able to determine the
Two methods can be u~cd. implicitly and hence no louder is
size of each instruction on the initial passes in order to lneeded.
I J Eliminating Forward References: We c-an n:sol,e Multi•pa,s a.s,emblers can solve the definitions ot calculale the addresses of subsequent symbols. This means
I J Fof"ard references in symbol definition Emphn.,;;i1.c. mol'! on J)r<X.'\'S..,;;in1,:1Us1.."tl in an:-u.~ where 1hen: i~ a
the probk m ,n two "3) s. 1ha1 if tl1e size of an operation referring to nn operand pow-:r nml n.-quin:s anon! memo{)'. limitation of avail:',bk
i) Approach I: The a»emblcr tm) read Ilic source dunng Pass 1. defined later depends on the type or distnnce of 1hc S011scdwhcre memory ronsumpcion 111t· mory.
prog.rd!TI tv.Jc.:c - t\l. O pa.~se---. On p.:e-~ ont'. the 2J Add,oonal passes through these stored deli operand, the assembler will make a pessimistic estimnte 1is of no ~rj_mL'\ \.'Onccnt. _ _
defirnuon:, of') mbols. including ~~tc:mcnl l.ibch. m•dt ,1 the assembly progresses. wh,n first encountering the operation, and if ncccssnry pnd
~n.- collected and stored rn i1 lJ.ble When pl:1.~~ tv.o Qlll'S 24) Writ,• the oli:orithm for single (lll'-S 11sscmbler.
it wilh one or more "no•opcration" ins1ruc1ion in n h11cr
~t..lfl.s. the defiruuons o f !,ymbob arc }.no\.\n forn ard Reference P"" or the crrala . 111 an nsscmbler with peephole Atl<: Algmithm for Single Ptl~ 1\.-.«•mblH (for Inter Stl.'!8)
11J Approach 2: On the flISI resdmi of the a,,,embl) In an meinbl) laniuage program. the symbols ( op111111w1ion, addresses may be rccnlculntcd between I) codc_11n::1...11ddruss:=11ddre$S of cod~_ llt'.":t:
progr.1m com en II to :m 1me.nnediate fonn ')torcd "'' defined cl,ewhcrc in the pr; gram. If tJ,e sy I'·"'"' 10 allow replac111g pessimistic code wilh code
memory The <.a:ond p3.), 1~ m"'dc m er th1..,
in usctl before they arc defined it is considered 115 srrnb_no: = I;
1ailorcd 10 the cxnct dis1ao/ee fro m the 111rge1. LC:= ll:
Jll lt·11111:d1:i1e form Thi, ~.n e~ on UO umc rdcrcncc , ufli.blc.
The original reason for 1hc use 10 oncppnss ns~cmhlcrs wus Slllll_no: = I\
1) Gcnernlln)! the Objec t Code in Memory: .'-o obJCCI Nutt: 011I) wheu lr,rward reference variable arc SYMT/\B_s,•gmcnLCllll) ': = 0;
,peed of asscmhly-ofle n 11 sccnnd pnss would rc,1uirc
progrJ.m 1::, wnllcn uul and nu lu:sdcr j:) needed. T he p, ogr'1 m, 11 11c.c.ch two-pa~"'e"' to generate tJ1c obj rcY11111Ji11g nmJ rcrcmJing the progrnm 1mu1c1J on 111pc or
Clcnr ORRTAB. SRTAB_/\RRAY.
.. . . . . , ....hl,. ,.f , ., ,.,.., , ,,,..., ..
,,\i\\f f~,,U U\' :< lJl\l l u i.::-1~11 " l """'
C-46 e.TC'.\7h, Fifth.S cnicsiu rrsnlrcd Series (Systc1ll Sonwnrc) ~"ll, 1 while Oi'CODC _,. 'E!ND' du
1,-• ,l•:in:h O l' l'All for O PCO DE
hcJ!ln
M:ikc :in ~nt? for symb in SY1ITAn With ic ftl~llt~ \1;~:\n1ct lo11 lcnglh) Ill LOCCTR IC this i_, not u comme nt lmc lhc n
2) ~~'hilc the Ol!J.t st:ucmcnt b nOl an El'lO <;t,:llemcnl
;i)Oc.u m::ac hine_code_buffcr. ·
defined := no ·
Make the cnrry (srtab no_LC. usngc C'n;t.
r1~: ir OrcooE c 'WORD' tlum
· u<ldJtoLOCCflt _
b cJ!ln
M:atch OPTA U for Ol 1CODE
lf_a symbol is pres:cnt in lhe 13bcl field 1hcn stmLno) in FRT of s~•mb. . -~ JS\' ff OPCODE= 'RESW' then If found lhrn
th..i s_labcl: = symbol in the label field ; c) ,\:-....-cmblc mstruct1on r . nJ<l 3 ~ //(OPERAND] lo LOCCTll htiln
i iii If an EQll St.llcment m:tchinc_,._"Odc_bu~Tcr. . io d sr ir orcoDE. = 'RESD' chen IC 1hcrc j.., a ,y mbol in oNmANr> fldtl Ihen
.i.) thi.s_addrc.-...--..:= , '31ue of <:lddrcss spccifi<:::ition>: size := size oflhc msbUcllon: dd NJOPERANDJ 10 LOC"Ct R hc~n
d) cls;: l( OPCODE = 'OYl'E.' Chen K:irch SYMTAU for OPf:.RI\ NO
b l MakC' :m COO) f<Y this_l.:ibd in SYMTAB \\ith
Off.!.CI : = this_addr.
ix) If :,.;ze ,:;0lhcn . 1r ro11nd lh, n
:i) If l:ibcl is prc...cnl then u~•gh~n<l lcnglh o r cons1an1 in I.Jytcs More ,ymbol value a, opcr:1.ml
Defi ned : = "\•~ · M:tkc an entry for this_Tabcl in s~~
#
d '-<.' 1\Wr
r.nd (Jf ~)'mbolJ 111 111~111 l tu ,1 l c~1,,·n 111I tlirec tiv" is 011cou11ll'n;d, th\· Elli.I IW , \C\I , , , "'",
:i: iiun·• und l)c,ii; 11 Optw11, (i\fod11Jc 3) ( JI}
1·r Tl' 5r,/1·rd Srrics (S)'SICII\ Sorlu. i11t•h'r f . . .
C--lR B.TJh. F10h Sc111c., i.: '"'lri)~ 1,,t , l'f sS: Th is 1s sc i 10 :mllca tc lhc lust stack Qucs 32) Exp lnin the i1LSlruclions or MASM as.~cmblcr.
IS 06.1 }h'~'~l . •~scd by the loader.
Q ucs 27) Des ·b DL R#7 : 1 ,l'~111~III p10 CC, .•
l!C ncrutcd b,· en c. the forma t or object ~roj:"101 An.'i: MAS/\1 Assc111hlcr - lnslruclio n
. Uic h ,o-p:iss SIC ~cmblcr olgonthm. IS 10.1 ·· •l!t' lcr:- can be ~pcc1flcd by lhc progr:unmcr or
,\ 0 . ~ t•lll rt·d ·t,y the nsse mblcr. Oy defau lt , the assembler The re arc mnny other instrucuons m which rhi.: lcngrh of
(2017 (Ol ]) 111 an assembled insrrucuon depends on lhc operant! ,; 1ha1 arc
~ n~: Fo rm at of O bject Program Gcncralcd by the
-~rn-Pass Ste .Assembler AJ~orithm
IS
SYMTAII
,\drin'S."
03.l
L<'n lh
j~:
'\.~t• lccl~
11111l' '
1111
111 ~!ibli.:
ti~ 111~ 1~·16IO :l~.;ociate
references IO 1h1ln scgmc~1ts 11.~c n.:gi s1cr
colli.:cl scvi.:r.tl si.:gm~nts
10 a group ;ind
a segment register wuh lhc group.
111~0
used.
I) The operands of :m ADD in:,1ruc1ion may be n:g1\lcr:,.
Figu rc 3.12 shows the objc-t:1pror-r-J..1u memory loc;.itions. or immcdia1c opcramls .
ljort ;t1~ty11 m, i::-
It~ I ~ l,ssLJi Tell tl1c ass:m~li.:r lo :1ssumi.: lhnt
113 I i) Immediate operands may occ upy from l ro 4
1} ~"~ ,1 I..,• !::~- •.a )V~ll :;,rn ).)• I< !,U :t t ~}Cl tJ\m~:4,m t l l• J!~l>
regis1cr ES 111d1ca1cs the segment
ULT 11 -l DATASEGl. bytes in the instruction.
t,( : IOl \1 \l {IM 11 !l ( ! , JI l~l )l ; .~,t~IH,,t :H~r \t C, c;~
0 osE i is 1\ny references lo labels that arc ii ) An operand that .~pcci fies a memory locat ion m:iy
ip;: , 1~a,. 1 1t.,.. u i:.1t:c!: 1::c1~m!c':m,rn: ci 1!1Hll: ::,'~j11CH TER:\I 116 defined in DAT ASEG2 wi ll be
;t>::,) ;J C.I H11l ~, ~ ........, I ((' J c. ~. I ! . lC(~: r'a M ~1 !\:C:;JI) ( J; h
•.~,1t assi.:mbled usi ng rcg1s1cr ES.
take varying amounts of space m the instruc11on.
LITTAB ,nd POO LTAB :ire empty a., depending on 1he location of 1he operand.
~Clthi \:l,h llit',l ' ~ •\•l
(,t -: 1t,1~
Li1crali- defi ned in the progr.:un. S f.5. FS. 1111d GS must be loaded by the 2) Pass 1 of an x86 as.'lemblcr must be considerahl y ore
~,d,1cr.; ~r • • ihey can bi.: used to address data scgmenls.
Gi A•M/#:ihiM: ■ #:HM
Figure- 3.13: Objrcl prop-::im complex Lhan Pass I of an SIC assembler.
" ., ni bc1orc
P"'irJ i) The fi rs! pass of x86 as:,cmblcr musl analysi.: the
Qucs 28) Write the assembly progr:im to rnmpu lc n! ·•1111rlc_•, ---=::-:- opcr.i nds of an ins1mction, in ndditi on lo lool-.iri~
:.ind also ""rite its machine language progr.im '1ith the Qucs 29) Write short no tes on l\1ASM asscrnti) for l' -' ~ AX. o ,\'J'ASEG2
1 Set ES 10 imlica1c 1hc data at lhc opcr:tl ion code.
data struclure used. (2 ~:~v [:.S . AX segment DATASEG2.
Ans: j\[ASf\I Assemblrr ii) The opcr:uion code !able must also be 111or1.:
Ans: Assembl~· Program lo compute N! and ·U~IE din.:c ti vc is similar lo the BASE diri.:ctivc in
The i\licrosoO M:icro (l\lASI\I) Assembler is an)( complica1cd, since ii must conta in infom1a11 on on
Equinilcnt ~lachine Language Program ;5S '
.mhiiecrure a.swnblcr for MS- DOS ~nd Mi 86 which addressin g modes arc valid for each
Oprod, ,Rc:,is1e, Memo!)·
Wi ndows While the n:m1e MAS M has e~rher usage~ 51cr,<f;, BASE tlirectivc 1clls :m SIC/XE assembler tJ1c ope rand.
ISTART 101
I (2di¢t) opcr.ind opu:ind
Odifit) Odi.!.!itl Uni:-,:; OS J 100 ·.ie la-Assembler. II is COntfiiOQJ
unde~tood in more recent years 10 refer to the Mi9'oso~
II 11:~icnlS of rcgist~r B: tJ1e p~~r.imm~r must p~ vide
~~ccuiablc ins1ruct1ons to load tJ11s value m (O tJ1e reg1s1cr. Qucs 33) Gh·c a note on r eferences with rcspcc l 10
!READ N 1011 09 0 113 M:icro Assembler. 11 is Jn ~tandard MACRO _as~cmblcr rl:t, survlE tell s MASM the COnll!nlS of a segmenl MASM assembler.
:\tOVER BREG. 101) O.S the xS6 PC market thal IS owned ~nd mrunta.incd lliy l
O:-.'E
~IO\E\I BREG. 103) 05
' l1 5
11 6
major operaling system ve ndor and smce t~e inlrodu~ ·
?l A•~istcr: the programmer mu s1 prov_ide ins1ruct1ons 10
~~;d th is registi.:r whe n the program 1s cxcculed. Ans: l\!IASM Assembler - References
5 AGAI' Mll.T
TcR.\I
IBREG. 10.: ) 03
' 11 6
of M,.\SM ,·ersion 6.0 in 1991 has had a powerful 01
processor th:n suppons psi:ud~ hig~ !eve~ .e mulatio~ Q1.1cs JJ) Describe 1he JMP instruct_ion of l\-IA SM.
Segme nts m an MASM source program can be wriucn m
more Lhan one pan. lfa SEGM°ENT directi ve specifies the
BC
CREG. :,. J08J 06 J ll 3
6.lld aJI later \'ersions were 32 bll Ponable ExecuJal,~
console mode application that produced both 0MB aod
~tp cinstnic11on. 1!1c assembler can 1ell whc1her this is a References betwee n segmen1s 1hat are asse mbl ed together
LE. 109 ) 07 ritlr jump or a far JUrnp.
:.10VE.\1 BREG. 11 0) 05
' '°' COFF objec1 modules for 32 bi1 code. Programmer, of aii
x86 sys1em views memo')' as a collec!ion segments, If thisis a forwa rd reference to TARGET, Lhe assembler does
arc au1oma1ically handled by the assembler.
I ) Externa l references between separ.ilcly assembly
PRl'T
RESL'LT
RES L'l T 11 1, 10
'
0
'"
11.: An MASf\1 asse mbler language program is writteJJ as 1
no1 1J1o1V how rnany bytes to reserve for the instruction.
2)
modules must be hand led by thi.: linker.
The MASM direc1ive PUBLI C h:is approximarel y thi.:
coUection of segments. Each segment is dcfi nc11 At B·<l~fauli. Mr\SM assumes that a fo rwa rd jump rs a near
STOP jJ 12 , 00 same fun ction as 1hc SIC/XE directive EXTREF.
0 000 be longing 10 a pan1cu lar class (co1Tcsponding 10 rs ju~ip. I( 1he 1.1rgc1of 1he jump is in another code se~~cnl,
18 N 05 I l 13 1
contentsJ. Common ly used classes are CODE. DA/JI~ Ille progrnnuncr must warn 1he 11ssembler by wn11ng - 3) The MASM directive EXTERN has approximatd y
19 RES t;LT OS
20 OSE DC
I
,. I 15 1 00 0 001
CONST and STACK Durin g program• exccub~ (Similar IO ex tended forrm1t in SIC/XE) the same fu ncti on as the SIC/XE directive EXTREF.
21 TER.\1 OS segments are addresM:d via Lhe x86 segment register5. JMP FAR PTR TARGET
,, END
I 116,
I) Code Segments: These arc addressed using rcgistci:~~ Tiu; object program from MASM nmy b.: in SC\'cr:11
Jf ih~ jump :1ddrCS)> is wi1h l 28 bytes of the current diffe rent fo rmats to allow i.:asy and dfici~· nt execution of
2) Stack Scgmtnts: The!>t arc addressed using registtrW,
Oat.a Struclure of Pass-I of an assembler int1ruc1ion. the programmi.:r can spec ify the shoncr (2- the program in a \'aric1y of the.! ope ration en\'iron mcnL
OPTAB 3) Data Segments (including Con~tan t Segp]enf,}; bite) n~ar Jump by writi ng:
Mnemonic OPCODE Ch~s !\lnemonkUlfo Thesi.: arc norma lly addressed DS, ES, FS, or GS; . JMP SHORT TA RGET MASM cun nlso produce nn ins trnct ion limin g listi ng
START AD RKII
READ
1ha1 shows the number of cl oc:' k cydes n..·qui f\'d to 1.•,i.:cufl•
IS fCJ9.11 Qucs 30) Dcfint tlu: .scwncnl\ n.-gistcrs of Jfd1e Ji\'IP 10 TARGET is ;1 rar j um p 1111d lhe prog r:1111111cr
MOVER l'uc h 111nchi nc it1)>1111Ction. (This nllows the prognunmi.:r to
lS /~ J , OOl's nn1 .,pct:if'y FA Ii PTR, a problc111 occurs. The lmcr
MOVEM 15 rCJSl1
:\"~?'/.'/li:sM Assembler - Segments 1e,,1on~ of MASM :1"scmbler can repeut Pass t 10
cxi.:rcisi.: n gri.:ut <lcn l of co111rol iu 0p1imi)>ing 1imin!,!·
ADD JS ((Ill / Stgmi.:111 rc~ •~ter~ .ire au tomm,ca/ly sci by the syM#I cri1icnl sec tions nf code.)
f(nc1<1ICcorrer1 local ion co111 1lc r va lues.
BC 15 1() 7 11 loader when a program i~ loaded fo r execulion.
DC DL R•5 l J Rt gj.'i lcr CS: Thb i~ .'IC I to indicate 1he segment lh.a1
SUR 15 1112 1, conlaJ/l\ the ~tart ing label \pccificd in the END
STOP JS ,00.1, 1,lalcmcnt of the progrmn.