MULTI MULTI PASS PASS ASSEMBLER ASSE MBLER
INTRODUCTION
Multi pass assembler means more than one pass is used by assembler. Multi pass assembler is used to eliminate forward references in symbol definition. It creates a number of passes that is necessary to process the definition of symbols. Multi pass assembler does the work in two pass by resolving the forward references. First pass •
Scans the code
•
Validates the tokens
•
Creates a symbol table
Second Pass •
Solves forward references
•
Converts the code to the machine
IMPLEMENTATION
prog program rammi ming ng lang langua uage ge that that is one one step step away away from from machi machine ne langu languag age. e. !ach !ach assembly language statement is translated into one machine instruction by the assembler. Program Programmer merss must must be well well versed versed in the comput computer"s er"s archit architectu ecture# re# and# and# undocu undocumen mented ted assembly language programs are difficult to maintain. It is hardware dependent$ there is a different assembly language for each CP% series. Pass 1
•
ssign addresses to all statements in the program
•
Save the values assigned to all labels for use in Pass &
1
•
Perform some processing of assembler directives
•
ssemble instructions
•
'enerate data values defined by ()*!# +,-
•
Perform processing of assembler directives not done in Pass /
Pass 2
MULTI PASS ASSEMBLER OVER SOURCE CODE
two0pass assembler performs two se1uential scans over the source code2 •
Pass /2 symbols and literals are defined
•
Pass &2 ob3ect program is generated
Parsing2 moving in program lines to pull out op0codes and operands DATA STRUCTURES
•
4ocation counter 54C62 points to the ne7t location where the code will be placed
•
,p0code translation table2 contains symbolic instructions# their lengths and their op0codes 5or subroutine to use for translation6
•
Symbol table 5S*62 contains labels and their values
•
String storage buffer 5SS(62 contains SCII characters for the strings
•
Forward references table 5F-*62 contains pointer to the string in SS( and offset where its value will be inserted in the ob3ect code
2
simple two pass assembler NUMBER OF PASSES COMPARISON
*here are two types of assemblers based on how many passes through the source are needed 5how many times the assembler reads the source6 to produce the e7ecutable program. •
,ne0pass assemblers go through the source code once. ny symbol used before it is defined will re1uire 8errata8 at the end of the ob3ect code 5or# at least# no earlier than the point where the symbol is defined6 telling the linker or the loader to 8go back8 and overwrite a placeholder which had been left where the as yet undefined symbol was used.
•
Multi0pass assemblers create a table with all symbols and their values in the first passes# then use the table in later passes to generate code.
EXAMPLE
In the following code snippet a one0pass assembler would be able to determine the address of the backward reference (9+ when assembling statement S but would not be able to determine the address of the forward reference F+ when assembling the branch statement S/$ indeed F+ may be undefined. two0pass assembler would determine both addresses in pass /# so they would be known when generating code in pass S/ (
F+
... F+ !:% ; ...
3
(9+ !:% ; ... S&
( (9+
In both cases# the assembler must be able to determine the si
•
ssembly language is typically used in a system"s boot code# the low0level code that initialiM is an e7ample.6
•
Some compilers translate high0level languages into assembly first before fully compiling# allowing the assembly code to be viewed for debugging and optimi
•
-elatively low0level languages# such as C# allow the programmer to embed assembly language directly in the source code. Programs using such facilities# such as the 4inu7 kernel# can then construct abstractions using different assembly
4
language on each hardware platform. *he system"s portable code can then use these processor0specific components through a uniform interface. •
ssembly language is used to enhance speed of e7ecution# especially in early Personal Computers with limited processing power and -M.
CONCLUSION
Sometimes# the first pass of an e7treme two0pass assembler produces an output file which is then read in by the second pass. *he advantage of this is that the first pass can record# with each line of input# the positions of some or all of the le7emes on that line and some of the results of parsing. For e7ample# in the e7ample assembly language# each line might be sent from one pass to the ne7t with a record indicating whether the line was a definition# or a statement# and# for statements# whether the line contained a label and what the value of the location counter was prior to processing that line. *he use of such an intermediate file can almost completely eliminate redundant computations in the two passes# but it adds to the input>output burden of the system. *he advantage of writing assemblers with a separate procedure for each pass is that this leads to assemblers which run very fast# since no flag must be tested to determine what to evaluate. ,n the other hand# this approach results in two very similar procedures which must be maintained in parallel# and which occupy almost twice the memory space occupied. REFERENCES
• • • • •
http2>>www.answers.com>:>+hat?is?multi?pass?assembler http2>>albertstu/@.blogspot.in>&A/B>A>what0is0multi0pass0assembler.html https2>>sites.google.com>site>assignmentssolved>mca>semesterB>mcAADB>BA https2>>www.1uora.com>+hat0are0advantages0of0assembler0with0multiple0passes https2>>books.google.co.in>booksEidI%Vmy0 G-ecCHpgP/ABHlpgP/ABHd1multipassassemblerHsourceblHotsD( ryJtS,l@HsigD%k/cnI+D0 o*Gr?dK?o/(hfcHhlenHsaGHvedAah%9!w3KnI9J1I<-h%MuIJ9Lbc
• • •
LLCho:guM%vonepageH1multiN&ApassN&AassemblerHffalse [email protected]>Course>SP.K/>sp&0.pdf http2>>homepage.cs.uiowa.edu>O3ones>syssoft>fallAA>notes>Afwd.html https2>>www.classle.net>>classle>book>system0software0and0assemblers0&0marks 5