Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
l l
l l
Basic assembler functions: Translating mnemonic operation codes to their machine language equivalents Assigning machine addresses to symbolic labels Generating machine language program equivalent to the input assembly language program
Assembler directive
l l
Assembler directives are pseudo instructions They provide instructions to the assembler itself. They are not translated into machine operation codes.
Basic functions
l l
l l
Functions of an assembler: Convert mnemonic operation codes to their machine language equivalents Convert symbolic operands to their equivalent machine addresses Decide the proper instruction format Convert the data constants to internal machine Representations Write the object program and the assembly listing
Types of assembler
Two pass Performs the functions mentioned in two distinct passes over the input program, intermediate file, etc. One pass Performs the functions mentioned in one pass over the input program. Difference between types of assemblers functionality in processing of labels (definition and usage)
Backward reference Label/item defined earlier in the program with respect to its reference (as operand) in the program
Problem lies with the forward reference
10
The undefined symbol (marked with a flag *) associated with a list of symbols depend on this undefined symbol. When a symbol is defined, we can recursively evaluate the symbol expressions depending on the newly defined symbol.
11
2-pass assembler..
Save the addresses assigned to all labels for use in Pass 2 (symbol table) Perform assembler directives, including those for address assignment, such as BYTE and RESW Pass 2 (assemble instructions and generate object program): Assemble instructions (generate machine code and look up addresses) Generate data values defined by BYTE, WORD Perform processing of assembler directives not done during Pass 1
13
2-pass assembler..
For instructions with forward reference, look up symbol table for substitution of label addresses Generate error message if necessary Write the object program and the assembly listing
14
15
1-pass assembler
Problem is Forward reference Solution: eliminate forward referencing !! Not possible, so..
16
1-pass assembler..
Omits the operand address if the symbol has not yet been defined Enters this undefined symbol into SYMTAB and indicates that it is undefined Remember where it is referred
17
1-pass assembler..
When the definition for the symbol is encountered, inserts the address. At the end of the program, reports error, if any.
18
1-pass assembler
NOT the Load-and-Go type: If the operand contains an undefined symbol, use 0 as the address and Text record is written to the object program. Forward references are handled like load-and-go assembler.
19
1-pass assembler
When the definition of a symbol is encountered, the assembler generates another Text record When loaded, the incorrect address 0 will be updated
20
Points to remember
Assemblers may allow the use of expressions as operand The assembler evaluates the expressions and produces a single operand address or value Expressions may consist of Operator +,-,*,/ (division is usually defined to produce an integer result) Individual terms: Constants, User-defined symbols Special terms, e.g., *, the current value of LOCCTR
21
Some notes
Immediate operands: The operand value is assembled as part of the machine instruction
22
Some notes
Program block: Allow the generated machine instructions and data to appear in the object program in a different/particular order
Separate blocks for storing code, data, stack, and larger data block
Segments of code that are rearranged within a single object program unit
23
Some notes
Control sections Segments of code that are translated into independent object program unit (subroutines/logical subdivisions) Can be loaded and relocated independently of the other control sections Programmer can assemble, load, and manipulate each of the control sections separately
24
Points to remember..
Instructions in one control section may need to refer to instructions or data located in another section External definition: Definition names symbols that are defined in this control section and may be used by other sections External reference: Reference names symbols that are used in this control section and defined elsewhere
25
Points to remember..
External symbol reference: Assembler may not have any idea about its occurrence Assembler must generate information for each external reference WHY??
26
Points to remember..
In an object program : There may be DEFINE and REFER records (for external symbols) There may be MODIFICATION record involving modification of operand (can be addresses)
27
Acknowledgement
course.ipv6.club.tw/SP.941/sp2-4.pdf
28