Optional Assembler Features 2

Slides:



Advertisements
Similar presentations
The Assembly Language Level
Advertisements

Chapter 3 Loaders and Linkers
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
3. Loaders & Linkers1 Chapter III: Loaders and Linkers Chapter goal: r To realize how a source program be loaded into memory m Loading m Relocation m Linking.
Chapter 3 Loaders and Linkers
COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida.
Chapter 3 Loaders and Linkers. Purpose and Function Places object program in memory Linking – Combines 2 or more obj programs Relocation – Allows loading.
Machine Independent Assembler Features
Assembler Design Options
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
Chapter 6: Machine dependent Assembler Features
Chih-Hung Wang Chapter 2: Assembler (Full) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley,
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.
An introduction to systems programming
1 Chapter 3 Loaders and Linkers Source Program Assembler Object Code Loader Executable Code Linker.
Loader- Machine Dependent Loader Features
Machine-Independent Assembler Features
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 1 Computer architecture Languages: machine, assembly, high
CS2422 Assembly Language and System Programming Machine Independent Assembler Features Department of Computer Science National Tsing Hua University.
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.
Assembler Design Options One-Pass and Multi-Pass Assemblers.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 –Linkers.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 9 - Assembler 4.
Lecture 3 Translation.
Machine dependent Assembler Features
Assembler Directives Code generation flow
CC410: System Programming
Machine Independent Assembler Features
System Programming and administration
System Software by Leland L. Beck Chapter 2
Assembler Directives Code generation flow
Machine Independent Assembler Features
Chapter 9 : Assembler Design Options
Assembler Design Options
Assembler Design Options
CSCI/CMPE 3334 Systems Programming
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Optional Assembler Features
Lecture 6 Assembler Directives.
Loaders and Linkers CSCI/CMPE 3334 David Egle.
Loaders and Linkers: Features
Machine Independent Features
Loaders and Linkers.
Assembler Design Options
68000 Architecture, Data Types and Addressing Modes
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
Machine Independent Assembler Features
Loaders and Linkers.
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
An introduction to systems programming
Chapter 3 Loaders and Linkers
Presentation transcript:

Optional Assembler Features 2 CSCI/CMPE 3334 David Egle

More features Allow for more flexible handling of the source and object programs the generated machine code appears in a different order in the object program than in the source the source code may be in independent sections, resulting in independent object programs these maintain their identity and are handled by the linker Program block segments of code that are rearranged in memory Control section segments of code that are translated into independent object programs

Program blocks Separate in source; contiguous in memory Primary objective allow the programmer to keep data sections close to the code where it is referenced have the data in one place in memory Need the programmer to specify which sections should be together in the object

The USE directive At beginning of program statements assumed to be part of the unnamed (default) block If no USE statement is included, entire program belongs to this single block The USE statement signals the beginning of a block with a specific name source statements are associated with this block until another USE statement is encountered USE statement may also indicate a continuation of a previously begun block

Handling program blocks During Pass 1 a separate location counter is maintained for each program block when new block is started, location counter is set to 0 current value is saved with switching to another block value is restored when a block is resumed labels are assigned addresses relative to start of current block; block name/number is included in symbol table at end, value of location counter is size of block assembler can assign to each block a starting address in object program

Handling program blocks 2 Pass 2 address of symbol relative to start of block is found and added to address of block this is then used in generating the object code See Figure 2.11 and 2.12 (p 79 and 81)

Blocks table The program blocks table is constructed during first pass When a new USE directive is encountered, the current location counter is saved in the Length If the new block is not in the table, it is added At the end of assembly, the address field is determined by adding the address and length of the previous block Block name Block number Address Length (default) 0000 0066 CDATA 1 000B CBLKS 2 0071 1000

Program blocks pros and cons Reduced use of extended format instructions No need to use base addressing Improves program readability Avoids Jump statements Can accomplish same thing by rearranging the source statements

Control sections A part of the program that maintains its identity after assembly separate assembly, loading, and manipulation think of separate functions in C++ Instructions in one control section may refer to instructions or data in another section external references Need to provide information for each external reference which will allow the loader to perform the required linking

Control section assembly CSECT directive signals the start of a new section Symbols that are defined in another section must be identified as external references EXTREF directive names symbols used in this control section and are defined in another Need to specify which symbols may be accessed from other control sections EXTDEF directive names symbols defined in this control section which may be used in other sections Control section names are automatically global

External reference handling The assembler cannot assemble the external reference addresses Need to use the extended instruction format (four bytes) to provide room for the actual address The assembler uses an address of 0 and passes information to the loader/linker If a symbol is defined in another section, but not identified in the EXTREF statement, an error will be generated if an attempt is made to reference it

Passing information to the linker Need some additional record types in the object code To indicate symbols defined here and globally available Dname1 addr1 name2 addr2 … e.g., DBUFFER00033BUFEND001033LENGTH00002D To indicate external references (not defined here) Rname1 name2 name3 e.g., RBUFFERLENGTHBUFEND

Passing information to the linker 2 To allow for expressions, update the modification record Maddress +/- {external symbol} e.g, M000018+BUFFER Note that this is a bit different than the text – but does illustrate the idea Also note that this still handles relocation, since the control section names may be used M00007+COPY

Handling expressions with external symbols Earlier expression restriction all of relative terms must be paired, or all except one that has to be of positive sign Extended restriction both paired terms must be relative within the same control section The assembler cannot in general determine whether or not the expression is legal it evaluates all the terms it can The loader finishes the evaluation, and checks for errors