Assembler Design Options One-Pass and Multi-Pass Assemblers.

Slides:



Advertisements
Similar presentations
Chapter 10 Linking and Loading. Separate assembly creates “.mob” files.
Advertisements

The Assembly Language Level
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Chapter 3 Loaders and Linkers
Macro Processor.
Machine Independent Assembler Features
The assembler is the system program that translate source code written in assembly language to object code( Machine Language) and other information for.
Assembler Design Options
System Software Chih-Shun Hsu
Assembler design.
Chapter 6: Machine dependent Assembler Features
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler I.
CS2422 Assembly Language and System Programming Linking Loader Department of Computer Science National Tsing Hua University.
Chih-Hung Wang Chapter 2: Assembler (Full) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley,
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
Assembler – Assembler Design Options. One-Pass Assemblers (1/2) Main problem  Forward references Data items Labels on instructions Solution  Data items:
Chapter 2 Assemblers Assembler Linker Source Program Object Code
CS2422 Assembly Language & System Programming December 22, 2005.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
1 Chapter 2 Assemblers Source Program Assembler Object Code Loader.
Machine-Independent Assembler Features
Assembler (Basic Functions)
Assembler – Machine Independent Features. Literals Design idea  Let programmers to be able to write the value of a constant operand as a part of the.
CS2422 Assembly Language & System Programming December 14, 2006.
UNIT II ASSEMBLERS.
A Simple Two-Pass Assembler
Assemblers.
Chapter 4 System Programming and Operating Systems -DM Dhamdhere
Assembler Design Options
Assemblers.
Chapter 1 Computer architecture Languages: machine, assembly, high
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler II.
One Pass with Fixup One-pass structure definition must occur before any uses (that is, uses can have only backward references to definitions) examples:
1 Assemblers System Software by Leland L. Beck Chapter 2.
CS2422 Assembly Language and System Programming Assembler Design Options Department of Computer Science National Tsing Hua University.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
Machine-Independent Assembler Features Literals, Symbol-Defining Statements, Expressions, Program Blocks, Control Sections and Program Linking.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Machine Independent Assembler Features
G.Umamaheswari Lect/IT R.M.D.EC system software
Loader and Linker.
Assemblers Two functions: – Mnemonic opcode  Machine Code – Symbolic labels  machine addresses (in memory) Some features: – Depend on assembly language.
LINKERS Execution of a program written in a language L involves the following steps: 1.Translation of the program: Performed by the translator for language.
Assemblers System Software.
Macro Processors Basic Functions Machine-Independent Features Design Options Implementation Examples.
COMPILERS CLASS IV Er. Vikram Dhiman M.tech NIT jalandhar.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
One-pass structure definition must occur before any uses (that is, uses can have only backward references to definitions) examples: macro definition before.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 9 - Assembler 4.
Machine dependent Assembler Features
CC410: System Programming
Machine Independent Assembler Features
System Programming and administration
System Software by Leland L. Beck Chapter 2
Machine Independent Assembler Features
Chapter 9 : Assembler Design Options
Assembler Design Options
Assembler Design Options
Optional Assembler Features
Loaders and Linkers CSCI/CMPE 3334 David Egle.
Machine Independent Features
Assembler Design Options
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Assemblers CSCI/CMPE 3334 David Egle.
Machine Independent Assembler Features
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
Location Counter (LC) = 0 while line of code <> END if ORG
Presentation transcript:

Assembler Design Options One-Pass and Multi-Pass Assemblers

One-Pass Assemblers One-pass assemblers are used when –it is necessary or desirable to avoid a second pass over the source program –the external storage for the intermediate file between two passes is slow or is inconvenient to use Main problem: forward references to both data and instructions One simple way to eliminate this problem: require that all areas be defined before they are referenced. –It is possible, although inconvenient, to do so for data items. –Forward jump to instruction items cannot be easily eliminated.

Sample Program for a One-Pass Assembler

Load-and-Go Assembler Load-and-go assembler generates their object code in memory for immediate execution. No object program is written out, no loader is needed. It is useful in a system oriented toward program development and testing such that the efficiency of the assembly process is an important consideration.

How to Handle Forward References Load-and-go 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 –Adds the address of this operand address to a list of forward references associated with the SYMTAB entry –Scans the reference list and inserts the address when the definition for the symbol is encountered. –Reports the error if there are still SYMTAB entries indicated undefined symbols at the end of the program –Search SYMTAB for the symbol named in the END statement and jumps to this location to begin execution if there is no error

After scanning line 40 Object Code in Memory and SYMTAB

After scanning line 160

One-Pass Assembler that Produce Object Programs If the operand contains an undefined symbol, use 0 as the address and write the Text record to the object program. Forward references are entered into lists as in the load-and-go assembler. When the definition of a symbol is encountered, the assembler generates another Text record with the correct operand address of each entry in the reference list. When loaded, the incorrect address 0 will be updated by the latter Text record containing the symbol definition.

Object Program from One-Pass Assembler

Multi-Pass Assemblers Prohibiting forward references in symbol definition: –This restriction is not a serious inconvenience. –Forward references tend to create difficulty for a person reading the program. Allowing forward references –To provide more flexibility –Solution: A multi-pass assembler that can make as many passes as are needed to process the definitions of symbols. Only the portions of the program that involve forward references in symbol definition are saved for multi-pass reading.

Multi-Pass Assemblers For a two pass assembler, forward references in symbol definition are not allowed: ALPHA EQU BETA BETA EQU DELTA DELTA RESW 1 Reason: symbol definition must be completed in pass 1. Motivation for using a multi-pass assembler –DELTA can be defined in pass 1 –BETA can be defined in pass 2 –ALPHA can be defined in pass 3

A symbol table is used –to store symbol definitions that involve forward references –to indicate which symbols are dependant on the values of others –to facilitate symbol evaluation For a forward reference in symbol definition, we store in the SYMTAB: –the symbol name –the defining expression –the number of undefined symbols in the defining expression –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. Implementation

Forward Reference Example

1 HALFSZ EQU MAXLEN/2 one undefined symbol in the defining expression defining expression undefined symbol depending list

2 MAXLEN EQU BUFEND-BUFFER two undefined symbol in the defining expression defining expression undefined symbol depending list

3 PREVBT EQU BUFFER-1 appended to the list

4 BUFFER RESB 4096

5 BUFEND EQU *