1)Convert mnemonic operations codes to their machine language equivalents.
2)Convert symbolic operands to their equivalent machine addresses
3)Build the machine instructions in the proper format
4)Convert the data constants specified in the source program into their internal machine representations.
5)Write the object program and the assembly listing.
All of these functions except number 2 can easily be accomplished by sequential processing of the source program, one line at a time.The translation of addresses ,however, presents a problem . Consider the statement
10 1000 FIRST STL RETADR 141033
This instruction contains a forward reference – that is , a reference to a label(RETADR) that is defined later in the program. If we attempt to translate the program line by line , we will be unable to process this statement because we do not know the address that will be assigned to RETADR. Because of this , most assemblers make two passes over the source program. The first pass does little more than scan the source program for lebel definitions and assign addresses. The second pass performs most of the actual translation previously described.
In addition to translating the instructions of the source program , the assembler must process statement called assemble directives . These statements are not translated into machine instructions (although they may have an effect on the object program). Instead , they provide instructions to the assembler itself. Examples of assembler directives are statements like BYTE and WORD , which direct the assembler to generate constants as part of the object program , and RESB and RESW , which instruct the assembler to reserve memory locations without generating date values. The other assembler directives in our sample program are START , which specifies the starting memory address for the object program , and END , which marks the end of the program.
Finally , the assembler must write the generated object code onto some output device. This object program will later be loaded into memory for execution. The simple object program format we use contains three types of records : Header , Text and End. The header record contains the program name , starting address, and length. Text records contain the translatd (i.e.machine code ) instructions and data of the program , together with an indication of the addresses where these are to be loaded. The End record marks the end of the object program and specifies the address in the program where execution is to begin.(This is taken from the operand of the program’s ENDstatement. If no operand is specified , the address of the first executable instruction is used)
The formats we use for these records are as follows .The details of the formats(column numbers etc ,..) are arbitrary , however the information contained in these records must be present(in some form) in the object program.
Header Record :
Col.1 H
Col.2-7 Pogram Name
Col.8-13 Starting address of object program (hexadecimal)
Col.14-19 Length of object program in bytes (hexadecimal)
Text Record :
Col.1 T
Col.2-7 Starting address for object code in this record
Col.8-9 Length of object code in this record in bytes
Col.10-69 Object cde , represented in hexadecimal
End Record :
Col.1 E
Col.2-7 Address of first executable indtruction in object program
To avoid confusion , we have used the term column rather than byte to refer to positions within object program records.This is not meant to imply the use of any particular medium for the object program. We can now give a general description of the functions of the two passes od our simpler assembler.
PASS 1 ( Define Symbols ) :
1)Assign addresses to all statement in the program
2)Save the values (addresses) assigned to all labels for use un Pass 2
3)Perform some processing of assembler directives.
PASS 2(assembler instructions and generate object program) :
1)Assemble instructions ( translating operations codes and looking up addresses) 2)Generate data values defined by BYTE ,WORD etc ,.
3)Perform processing of assembler directives not done during Pass 1.
4)Write the object program and the assembly listing.
Subscribe to:
Post Comments (Atom)
1 comment:
Three Dimensional Display Methods
Storage allocation strategies
Different Loading Schemes
Relocation: Linking Concept
Regular Expression and Regular Definition
IEEE 802.11 Architecture
Phases: Language processor (Toy compiler)
8086 Pin Diagram
80386 Architecture
Post a Comment