Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
More NextBlog
CreateBlog SignIn
ABOUT ASSEMBLERS
BLOG ARCHIVE
structuretheOperationCodetable(OPTAB)andtheSymbol
2008 (4)
Table(SYMTAB).OPTABisusedtolookupmnemonic
operationcodesandtranslatethemtotheirmachine
languageequivalents.SYMTABisusedtostore
values(addresses)assignedtolabels.
September (4)
ASSEMBLER ALGORITHM
AND DATA STRUCTURES
FUNCTIONS :
WealsoneedaLocationcounterLOCCTR.Thisisavariable
Directives:
thatisusedtohelpintheassignmentofaddresses.LOCCTR
Assemblers :Indroduction
isinitializedtothebeginningaddressspecifiedintheSTART
statement.Aftereachsourcestatementisprocessed,the
lengthoftheassembledinstructionsordateareatobe
generatedisaddedtoLOCCTR.Thuswheneverwereacha
labelinthesourceprogram,thecurrentvalueofLOCCTR
givestheaddresstobeassociatedwiththatlabel.
ABOUT ME
B RIS K I
VI EW M Y C OMP LET E P R OFI LE
TheOperationcodeTablemustcontainthemnemonic
operationcodeanditsmachinelanguageequivalent.Inmore
complexassembles,thistablealsocontainsinformation
aboutinstructionformatandlength.DuringPass1,OPTABis
usedtolookupandvalidateopearationcodedinthesource
program.Inpass2,itisusedtotranslatetheoperation
codestomachinelanguage.Actually,inoursimpleSIC
assembler,bothoftheseprocessescouldbedonetogetherin
ABOUT ASSEMBLERS
eitherPASS1orPASS2.However,foramachinethathas
instructionsofdifferentlengths,wemustsearchOPTABin
thefirstpasstofindtheinstructionslengthforincrementing
LOCCTR.Likewise,wemusthavetheinformationfrom
OPTABisPASS2totelluswhichinstructionformattousein
assemblingtheinstruction,andmypeculiaritiesoftheobject
codeinstruction.Wehavechosentoretainthisstructurein
http://briskiassemblers.blogspot.ca/2008/09/assembler-algorithm-and-data-structures.html
1/3
4/17/2016
thecurrentdiscussionbecauseitistypicalofmostreal
assembles.
OPTABisusuallyorganizedasahashtable,withmnemonic
operationcodeasthekey.Thehashtableorganizationis
particularlyappropriate,sinceitprovidesfastretrievalwith
aminimumofsearching.Inmostcases,OPTABisastatic
tablethatis,entriesarenotnormallyaddedtoordeleted
fromit.Insuchcasesitispossibletodesignaspecialhashing
functionorotherdatastructuretogiveoptimum
performancefortheparticularsetofkeysbeingstored.Most
ofthetime,however,ageneralpurposehashingmethodis
used.
TheSymboltable(SYMTAB)includesthenameandvalue
(address)foreachlabelinthesourceprogram,togetherwith
flagstoindicateerrorconditions(e.g,.asymboldefinedin
twodifferentplaces).Thistablemayalsocontainother
informationaboutthedataareaorinstructionlabeledfor
example,itstypeorlength.DuringPass1oftheassembler,
labelsareenteredintoSYMTABastheyareencounterdinthe
sourceprogram,alongwiththeirassignedaddresses(form
LOCCTR).DuringPass2,symbolsusedasoperandsare
lookedupinSYMTABtoobtaintheaddressestobeinserted
intheassembledintructions.
SYMTABisusuallyorganizedasahashtableforefficiencyor
insertionandretrieval.Sinceentriesarerarelydeletedfrom
thistable,efficiencyofdeletionisnotanimportant
consideration.BecauseSYMTABisusedhavilythroughout
theassemble,careshouldbetakenintheselectionofa
hashingfunction.Programmersoftenselectmanylabelsthat
havesimilarcharacteristicsforexample,labelsthatstart
orendwiththesamecharacters(likeLOOP1,LOOP2)orare
ofthesamelength.Itisimportantthatthehashingfuction
usedperformwellwithsuchnorandomkeys.Divisionofthe
entirekeybyaprimetablelengthoftengivesgoodresult.
Itispossibletobothpassesoftheassemblertoreadthe
originalsourceprogramasinput.However,thereiscertain
information(suchaslocationcountervaluesanderrorflags
forstatements)thatcanorshouldbecommunicatedbetween
thetwopasses.Forthisreason,Passusuallywritesan
INTERMEDIATEFILEthatcontainseachsourcestatement
togetherwithitsassignedaddress,errorindicators,etc,.
ThisfileisusedastheinputtoPass2.Thisworkingcopyof
http://briskiassemblers.blogspot.ca/2008/09/assembler-algorithm-and-data-structures.html
2/3
4/17/2016
thesourceprogramcanalsobeusedtoretaintheresultsof
certainoperationsthatmaybeperformedduringPass1,so
theseneednotbeperformedagainduringPass2.Similarly,
pointersintoOPTABandSYMTABmayretainedforeach
operationcodeandsymbolused.Thisavoidstheneedto
repeatmanyofthetablesearchingoperations.Weassume
forsimplicitythatthesourcelinesarewritteninafixed
formatwithfieldsLABEL,OPCODE,andOPERAND.Ifone
ofthesefieldscontainsacharactedstringthatrepresentsa
number,wedenoteitsnumericvaluewiththepreficx#(for
example,#[OPERAND]).
POST ED BY BR I SKI AT 9: 0 4 AM
1COMMENT:
Shanthakumar V said...
useful :)
JULY 20, 201 4 AT 5: 1 5 PM
Post a Comment
Home
Older Post
http://briskiassemblers.blogspot.ca/2008/09/assembler-algorithm-and-data-structures.html
3/3