CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Loaders Dr. Monther Aldwairi 10/21/2007 Dr. Monther Aldwairi.
1 Loaders and Linkers Chapter 3 System Software An introduction to systems programming Leland L. Beck.
1 Loaders and Linkers Chapter 3 System Software An introduction to systems programming Leland L. Beck.
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.
Loader. Role of Loader Source Program Translator Object Program Loader Object program ready for execution Memory Translator – Assembler/Compiler.
Machine Independent Assembler Features
Loaders and Linkers Object Program contains the information:
Chap 3 Loaders and Linkers. Object program contains translated instructions and data values from the source program. Loading, which brings the object.
1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.
1 System Programming System Software, pp Chia-Hui Chang, Assistant Professor Dept. of Computer Science & Information Engineering National Central.
Simplified Instructional Computer (SIC). SIC Architecture Two versions: SIC and SIC/XE (extra equipments). SIC program can be executed on SIC/XE. Memory.
System Software by Leland L. Beck chapter 1, pp.1-20.
1 Chapter 1 Background Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University 9/17/2009.
System Software by Leland L. Beck chapter 1, pp.1-20.
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 (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
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
Chih-Hung Wang Chapter 1: Background (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
CS2422 Assembly Language & System Programming December 26, 2006.
A Simple Two-Pass Assembler
MIPS coding. SPIM Some links can be found such as:
Assemblers.
Chapter 1 Computer architecture Languages: machine, assembly, high
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Loader and Linker.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
UNIT III LOADERS AND LINKERS. This Unit gives you… Basic Loader Functions Machine-Dependent Loader Features Machine-Independent Loader Feature Loader.
Loaders and Linkers T 李俊葦. 1. Loader Accepts the object programs , prepares these programs for execution by the computer , and indicates the execution.
CPS4200 System Programming Spring 1 Systems Programming Chapter 1 Background I.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 4 - Assembler 1.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 –Linkers.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 9 - Assembler 4.
김길용 교수 분산처리연구실 시스템 프로그래밍 김길용 교수 분산처리연구실
CC410: System Programming
Machine dependent Assembler Features
CC410: System Programming
System Programming and administration
System Programming and administration
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Chapter One: Introduction
Machine Independent Features
Simplified Instructional Computer (SIC)
Loaders and Linkers.
Memory Management Tasks
Chapter 1 Background Professor Gwan-Hwan Hwang
Simplified Instructional Computer (SIC)
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
Loaders and Linkers.
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
An introduction to systems programming
UNIT III LOADERS AND LINKERS
Chapter 3 Loaders and Linkers
Presentation transcript:

CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders

2 Learning Objectives Understand Loader Functions Differentiate between Machine Dependant and Independent Functions 2 Source Program Assembler Object Code Loader Executable Code Linker

3 Introduction »In Chapter 2, we discussed: –Loading: brings the OP into memory for execution –Relocating: modifies the OP so that it can be loaded at an address different form the location originally specified. –Linking: combines two or more separate OP and supplies the information needed to allow references between them (Section 2.2.2) –Loading and Allocation : which allocates memory location and brings the object program into memory for execution (Section 2.3.5)

Chapter 3 Overview »Type of loaders –assemble-and-go loader –absolute loader (bootstrap loader) –relocating loader (relative loader) –direct linking loader »Design options –linkage editors –dynamic linking –bootstrap loaders

Assemble-and-go Loader »Characteristic –the object code is stored in memory after assembly –single JUMP instruction »Advantage –simple, developing environment »Disadvantage –whenever the assembly program is to be executed, it has to be assembled again –programs have to be coded in the same language

Design of an Absolute Loader »Absolute Loader –Does not perform linking and program relocation. –Advantage Simple and efficient –Disadvantage the need for programmer to specify the actual address difficult to use subroutine libraries »Program Logic –Next slide

7 Fig. 3.2 Algorithm for an absolute loader Begin read Header record verify program name and length read first Text record while record type is not ‘E’ do begin {if object code is in character form, convert into internal representation} move object code to specified location in memory read next object program record end jump to address specified in End record end

8 3.1 Basic Loader Functions Design of an Absolute Loader »Absolute loader, in Figures 3.1 and 3.2. –The contents of memory locations are absolutely defined and there is no Text record include memory locations as xxxx. –Each byte of assembled code is given using its Hex representation in character form, easy to read by humans. –Most machine store object programs in a binary form.

9

Design of an Absolute Loader »Absolute loader, in Figure 3.1 and 3.2. –STL instruction, pair of characters 14, when these are read by loader, they will occupy two bytes of memory. –14 (Device ASCII 31 34) ----> Loader (one byte) –For execution, the operation code must be stored in a single byte with hexadecimal value 14. –Each pair of bytes must be packed together into one byte. –Each printed character represents one half-byte.

A Simple Bootstrap Loader »A bootstrap loader, Figure 3.3. –Loads the first program to be run by the computer--- usually an operating system. –The bootstrap itself begins at address 0 in the memory. –It loads the OS or some other program starting at address 80.

A Simple Bootstrap Loader »A bootstrap loader, Figure 3.3. –Each byte of object code to be loaded is represented on device F1 as two Hex digits (by GETC subroutines). –Text Records only, no header or end records. –The ASCII code for the character 0 (Hex 30) is converted to the numeric value 0. –The object code from device F1 is always loaded into consecutive bytes of memory, starting at address 80.

13 To read 14, GETC will read 31 and convert to , the SHIFTL -> Then Next GETC will read 34, convert to m then ADDR ->

14 Char A has ASCII 55 (Hex 37), since 30 is already subtracted, extra 7 need to be subtracted

Fig. 3.3 SIC Bootstrap Loader Logic Begin X=0x80 (the address of the next memory location to be loaded Loop A←GETC (and convert it from the ASCII character code to the value of the hexadecimal digit) save the value in the high-order 4 bits of S A←GETC combine the value to form one byte A← (A+S) store the value (in A) to the address in register X X←X+1 End 0~9 : 48 A~F : 65 GETC A←read one character if A=0x04 then jump to 0x80 if A<48 then GETC A ← A-48 (0x30) if A<10 then return A ← A-7 (48+7=55) return

Machine-Dependent Loader Features »Absolute loader has several potential disadvantages. –The actual address at which it will be loaded into memory. –Cannot run several independent programs together, sharing memory between them. –It is difficult to use subroutine libraries efficiently. »More complex loader. –Relocation –Linking –Linking loader

Relocation »Motivation –efficient sharing of the machine with larger memory and when several independent programs are to be run together –support the use of subroutine libraries efficiently »Relocating loaders, two methods: –Modification record (for SIC/XE) (Fig. 3.4, 3.5) –Relocation bit (for SIC) (Fig. 3.6, 3.7) each instruction is associated with one relocation bit these relocation bits in a Text record is gathered into bit masks

18

19

20

Relocation »Modification record, Figure 3.4 and 3.5. –Also called RLD specification Relocation and Linkage Directory –To described each part of the object code that must be changed when the program is relocated. –The extended format instructions on lines 15, 35, and 65 are affected by relocation. (absolute addressing) –In this example, all modifications add the value of the symbol COPY, which represents the starting address. –Not well suited for standard version of SIC, all the instructions except RSUB must be modified when the program is relocated. (absolute addressing)

22

Relocation »Figure 3.6 needs 31 Modification records. In a SIC machine (no relative addressing) »Relocation bit, Figure 3.6 and 3.7. –A relocation bit associated with each word of object code. –The relocation bits are gathered together into a 12 bit mask following the length indicator in each Text record. –If bit=1, the corresponding word of object code is relocated. Bit = 0 when no modification is required or unused words

24

25

26

Relocation »Relocation bit, Figure 3.6 and 3.7. –In Figure 3.7, T000000^1E^FFC^ ( ) specifics that all 10 words of object code are to be modified. –On line 210 begins a new Text record even though there is room for it in the preceding record. –Any value that is to be modified during relocation must coincide with one of these 3-byte segments so that it corresponding to a relocation bit. –Because of the 1-byte data value generated form line 185, this instruction must begin a new Text record in object program.

28 First T Rec: Words for Lines 10:55 Second T Rec: Words for Lines 60:90 Fifth T Rec: Words for Lines 210:245