Assembler Design Options

Slides:



Advertisements
Similar presentations
The Assembly Language Level
Advertisements

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
System Software Chih-Shun Hsu
1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.
Chapter 6: Machine dependent Assembler Features
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler I.
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:
CS2422 Assembly Language & System Programming December 22, 2005.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
An introduction to systems programming
Software Development Process Compiler Linker C File Asm. File Binary File Exec. File Assemble r Library Implementation Phase Debugger Profiler Verification.
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.
CSC 3210 Computer Organization and Programming Chapter 9 EXTERNAL DATA AND TEXT D.M. Rasanjalee Himali.
A Simple Two-Pass Assembler
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
The Assembly Language Level Part B – The Assembly Process.
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
Assembler Design Options
Assemblers.
Chapter 1 Computer architecture Languages: machine, assembly, high
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.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
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.
Assembler Design Options One-Pass and Multi-Pass Assemblers.
Assemblers System Software.
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.
Chapter Linkers and Loaders
Machine dependent Assembler Features
Segment Definition The CPU has several segment registers:
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
Loaders and Linkers.
Assembler Design Options
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Machine Independent Assembler Features
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
An introduction to systems programming
Presentation transcript:

Assembler Design Options One-pass assemblers Multi-pass assemblers Two-pass assembler with overlay structure

Two-Pass Assembler with Overlay Structure For small memory pass 1 and pass 2 are never required at the same time three segments root: driver program and shared tables and subroutines pass 1 pass 2 tree structure overlay program

One-Pass Assemblers Main problem Solution forward references data items labels on instructions Solution data items: require all such areas be defined before they are referenced labels on instructions: no good solution

One-Pass Assemblers Main Problem Two types of one-pass assembler forward reference data items labels on instructions Two types of one-pass assembler load-and-go produces object code directly in memory for immediate execution the other produces usual kind of object code for later execution

Load-and-go Assembler Characteristics Useful for program development and testing Avoids the overhead of writing the object program out and reading it back Both one-pass and two-pass assemblers can be designed as load-and-go. However one-pass also avoids the over head of an additional pass over the source program For a load-and-go assembler, the actual address must be known at assembly time, we can use an absolute program

Forward Reference in One-pass Assembler For any symbol that has not yet been defined 1. omit the address translation 2. insert the symbol into SYMTAB, and mark this symbol undefined 3. the address that refers to the undefined symbol is added to a list of forward references associated with the symbol table entry 4. when the definition for a symbol is encountered, the proper address for the symbol is then inserted into any instructions previous generated according to the forward reference list

Load-and-go Assembler (Cont.) At the end of the program any SYMTAB entries that are still marked with * indicate undefined symbols search SYMTAB for the symbol named in the END statement and jump to this location to begin execution The actual starting address must be specified at assembly time Example Figure 2.18, 2.19

Producing Object Code When external working-storage devices are not available or too slow (for the intermediate file between the two passes Solution: When definition of a symbol is encountered, the assembler must generate another Tex record with the correct operand address The loader is used to complete forward references that could not be handled by the assembler The object program records must be kept in their original order when they are presented to the loader Example: Figure 2.20

Multi-Pass Assemblers Restriction on EQU and ORG no forward reference, since symbols’ value can’t be defined during the first pass Example Use link list to keep track of whose value depend on an undefined symbol Figure 2.21

Implementation Examples Microsoft MASM Assembler Sun Sparc Assembler IBM AIX Assembler

Microsoft MASM Assembler SEGMENT a collection segments, each segment is defined as belonging to a particular class, CODE, DATA, CONST, STACK registers: CS (code), SS (stack), DS (data), ES, FS, GS similar to program blocks in SIC ASSUME e.g. ASSUME ES:DATASEG2 e.g. MOVE AX, DATASEG2 MOVE ES,AX similar to BASE in SIC

Microsoft MASM Assembler JUMP with forward reference near jump: 2 or 3 bytes far jump: 5 bytes e.g. JMP TARGET Warning: JMP FAR PTR TARGET Warning: JMP SHORT TARGET Pass 1: reserves 3 bytes for jump instruction phase error PUBLIC, EXTRN similar to EXTDEF, EXTREF in SIC

Sun Sparc Assembler Sections Symbols Delayed branches .TEXT, .DATA, .RODATA, .BSS Symbols global vs. weak similar to the combination of EXTDEF and EXTREF in SIC Delayed branches delayed slots annulled branch instruction

Sun Sparc Assembler LOOP: . . ADD %L2, %L3, %L4 CMP %L0, 10 BLE LOOP NOP . CMP %L0, 10 BLE LOOP ADD %L2, %L3, %L4

Sun Sparc Assembler LOOP: ADD %L2, %L3, %L4 . CMP %L0, 10 BLE,A LOOP

AIX Assembler for PowerPC Similar to System/370 Base relative addressing save instruction space, no absolute address base register table: general purpose registers can be used as base register easy for program relocation only data whose values are to be actual address needs to be modified e.g. USING LENGTH, 1 USING BUFFER, 4 Similar to BASE in SIC DROP

AIX Assembler for PowerPC Alignment instruction (2) data: halfword operand (2), fullword operand (4) Slack bytes .CSECT control sections: RO(read-only data), RW(read-write data), PR(executable instructions), BS(uninitialized read/write data) dummy section