Assembler Design Options

Slides:



Advertisements
Similar presentations
Intermediate Code Generation
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Data Dependencies Describes the normal situation that the data that instructions use depend upon the data created by other instructions, or data is stored.
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.
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
Machine Independent Assembler Features
Assembler Design Options
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:
Tutorial 6 & 7 Symbol Table
CS2422 Assembly Language & System Programming December 22, 2005.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
Programming Logic and Design Fourth Edition, Comprehensive
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.
A Simple Two-Pass Assembler
Assemblers.
Chapter 4 System Programming and Operating Systems -DM Dhamdhere
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
Assemblers.
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:
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
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.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
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
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
G.Umamaheswari Lect/IT R.M.D.EC system software
Loader and Linker.
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.
Assembler Design Options One-Pass and Multi-Pass Assemblers.
Macro Processors Basic Functions Machine-Independent Features Design Options Implementation Examples.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 11–Macro-Processors.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 4 - Assembler 1.
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.
CC410: System Programming
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
Machine Independent Features
Assembler Design Options
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Mastering Memory Modes
Machine Independent Assembler Features
Machine Independent Assembler Features
point when a program element is bound to a characteristic or property
Presentation transcript:

Assembler Design Options

One and Multi-Pass Assembler So far, we have presented the design and implementation of a two-pass assembler. Here, we will present the design and implementation of One-pass assembler If avoiding a second pass over the source program is necessary or desirable. Multi-pass assembler Allow forward references during symbol definition.

One-Pass Assembler The main problem is about forward reference. Eliminating forward reference to data items can be easily done. Simply ask the programmer to define variables before using them. However, eliminating forward reference to instruction cannot be easily done. Sometimes your program needs a forward jump. Asking your program to use only backward jumps is too restrictive.

Program Example

All variables are defined before they are used.

Two Types There are two types of one-pass assembler: Produce object code directly in memory for immediate execution No loader is needed Load-and-go for program development and testing Good for computing center where most students reassemble their programs each time. Can save time for scanning the source code again Produce the usual kind of object program for later execution

Internal Implementation The assembler generate object code instructions as it scans the source program. If an instruction operand is a symbol that has not yet been defined,the operand address is omitted when the instruction is assembled. The symbol used as an operand is entered into the symbol table. This entry is flagged to indicate that the symbol is undefined yet.

Internal Implementation (cont’d) The address of the operand field of the instruction that refers to the undefined symbol is added to a list of forward references associated with the symbol table entry. When the definition of the symbol is encountered, the forward reference list for that symbol is scanned, and the proper address is inserted into any instruction previously generated.

Processing Example After scanning line 40

Processing Example (cont’d) After scanning line 160

Processing Example (cont’d) Between scanning line 40 and 160: On line 45, when the symbol ENDFIL is defined, the assembler places its value in the SYMTAB entry. The assembler then inserts this value into the instruction operand field (at address 201C). From this point on, any references to ENDFIL would not be forward references and would not be entered into a list. At the end of the processing of the program, any SYMTAB entries that are still marked with * indicate undefined symbols. These should be flagged by the assembler as errors.

Multi-Pass Assembler If we use a two-pass assembler, the following symbol definition cannot be allowed. ALPHA EQU BETA BETA EQU DELTA DELTA RESW 1 This is because ALPHA and BETA cannot be defined in pass 1. Actually, if we allow multi-pass processing, DELTA is defined in pass 1, BETA is defined in pass 2, and ALPHA is defined in pass 3, and the above definitions can be allowed. This is the motivation for using a multi-pass assembler.

Multi-Pass Assembler(cont’d) It is unnecessary for a multi-pass assembler to make more than two passes over the entire program. Instead, only the parts of the program involving forward references need to be processed in multiple passes. The method presented here can be used to process any kind of forward references.

Multi-Pass Assembler Implementation Use a symbol table to store symbols that are not totally defined yet. For a undefined symbol, in its entry, We store the names and the number of undefined symbols which contribute to the calculation of its value. We also keep a list of symbols whose values depend on the defined value of this symbol. When a symbol becomes defined, we use its value to reevaluate the values of all of the symbols that are kept in this list. The above step is performed recursively.

Forward Reference Example

Forward Reference Processing But one symbol is unknown yet Defined Not defined yet After first line

After second line But two symbols are unknown yet Now defined

After third line

After 4’th line Start knowing values

Start knowing values After 5’th line All symbols are defined and their values are known now.