<style> font { color: red; font-weight: bold; } </style> ## Intro - A **loader** is a system program that performs the <font>loading</font> function - Many loaders also supports <font>relocation</font> and <font>linking</font> - Some systems have a <font>linker</font> to perform the linking operations and a separate loader to handle reloacation and loading - In most cases all the **program translators** (assemblers & compilers): - produce **object program** in <font>the same format</font> on a particular system - Thus one system loader or linker can be used **regardless of the original source programming language** ## Absolute Loader - An absolute loader does <font>not</font> need to perform **linking** and program **relocation** - All functions are accomplished in a single pass - When the **End record** encountered - the loader <font>jumps</font> to the **specified address** to **begin execution** of the loaded program :::info **Packing Operations** - SIC **Object Program** is represented in **character format** (ASCII Code) - Easy to read, print or display - When the program is **loaded into memory**, it is represented in **binary format** For example: - The object code of `LDA #512` is `010200` - In the object program, it is represent in character format `"010200"`, the bit string in **disk** is ``` 0011 0000 // '0' (ascii 48) 0011 0001 // '1' (ascii 49) 0011 0000 0011 0010 // '2' (ascii 50) 0011 0000 0011 0000 ``` - In **memory**, it represented in binary format ``` 0000 0001 0000 0010 0000 0000 ``` - **Packing Operations** - **Convert** object program **from character** format **to binary** format ``` 0011 0000 => 0000 0011 0001 => 0001 0011 0000 => 0000 0011 0010 => 0010 0011 0000 => 0000 0011 0000 => 0000 ``` ::: - For **efficiency** in terms of both **space** and execution **time** - most machines store object programs in a **binary form** - We must be sure that our **file and device conventions** . . . - do <font>not</font> cause some of the object program bytes to be **interpreted** as **control characters**. - Obviously object programs stored in binary form do not lend themselves well to printing or to reading by human beings. ### A Simple Bootstrap Loader - When a computer is first **turned on** or **restarted** - a special type of *absolute loader*, called a <font>Bootstrap Loader</font>, is executed - The bootstrap loader, **loads the first program to be run** by the comuter - usually an **Operating System** - Because this loader is used in a **unique situation** (the **initial program** load for thesystem) - The **program** to be loaded can be represented in a very **simple format** - There is <font>no</font> **Header record**, **End record**, or **control information** (such as addresses or lengths). - It <font>skip</font> all other input characters that have ASCII code **less than hexadecimal 30**. (十進位 48,即 `'0'` 的 ASCII code) - This causes the bootstrap to <font>ignore</font> any **control bytes** (such as end-of-file) that are read. ## Machine-Dependent Loader Features - The absolute loader is certainly simple and efficient - however, this scheme has several potential <font>disadvantage</font> 1. Writing **absolute programs** makes it <font>difficult</font> to **use subroutine libraries** efficiently. 2. To make **efficient use of memory** - It is important to be able to **load** object programs **into any appropriate memory space** - This could <font>not</font> be done effectively if all of the **subroutines** had preassigned **absolute addresses**. ### Relocation ### Program Linking