Complete Notes System Software
Complete Notes System Software
Name : ……………………………………………………………………………………………
SYLLABUS
Module III: Loaders And Linkers: Basic loader functions - Design of an Absolute Loader Machine
dependent loader features - Relocation – Program Linking – Algorithm and Data Structures for
Linking Loader - Machine-independent loader features – Automatic Library Search – Loader
Options- Loader design options - Linkage Editors – Dynamic Linking – Bootstrap Loaders
Module IV: Compilers: Basic Compiler Functions: Grammars, Lexical Analysis, Syntactic Analysis,
Code Generation. Machine Dependent Compiler Features – Intermediate Form of the program,
Machine Dependent Code optimization. Machine Dependent Compiler features –Structured
variables, machine-independent code optimization, Storage allocation. Compiler design options
– Division into passes
Module I
Introduction & Assemblers
System software and machine architecture – The simplified Instructional Computer (SIC) -
Machine architecture - Data and instruction formats – addressing modes - instruction sets - I/O
and programming. Basic assembler functions - A simple SIC assembler– Assembler algorithm
and data structures
System Software
• System Software is the most important type of software required to administer the
resources of the computer system.
• System software runs and functions internally with application software and hardware.
Moreover, it works as a linking interface between a hardware device and the end-user.
• System software runs in the background and manages all functioning of the computer
itself. It is called Low-Level Software as it runs at the most basic level of computer and is
usually written in a low-level language. As soon as we install the operating system on
our device, it gets automatically installed on the same device.
• System software helps to generate the user interface and allows the operating system
to interact with the computer hardware.
1. Operating System
2. Programming Language Translators
3. Device Drivers
4. Firmware Software
5. Utility Software
1.Operating System
• An Operating System is the most basic type of System Software that helps to manage
computer hardware and software.
• It is the central part of any computer system which is responsible for the smooth
functioning of any computer device.
• An Operating system primarily operates your computer when you start it.
• If you haven't installed the operating system on your computer, then you will not be
able to start your computer.
• Some most common examples of OS are macOS, Linux, Android, and Microsoft
Windows.
• Programming translators are the software that converts high-level language into
machine language.
• A computer can only understand the machine language or binary bits pattern, either 0
or 1.
• A CPU understands this machine language that is not easy to understand by a normal
human. Hence, First, the end-user interacts with the computer in a high-level language
like Java, Python, C, PHP, and C++, etc., then the translator converts these languages
into machine code.
• A CPU or computer processor executes these machine codes into binary. It means any
program written in a high-level programming language must be converted into binary
codes first. This entire process to convert high-level language into machine code or
binary codes are known as compilation.
3.Device Drivers
4.Firmware Software
• These are the operational software installed on the computer motherboards that help
the operating system to identify the memories such as Flash, ROM, EPROM, EEPROM,
and memory chips.
• However, the primary function of any firmware software is to manage and control all
activities of individual devices.
• Initially, it uses non-volatile chips for installation purposes, but later it gets installed on
the flash chips.
• The BIOS (Basic Input/Output System) also works as a system program used for the
booting process of the system. First, it loads the OS into the main memory (RAM) of
your system and then hands it over to the OS. BIOS works as the substitute for the ROM
chip; hence, it is called firmware software.
• A Firmware exists inside the devices while a device driver is installed in the operating
system.
5.Utility Software
Simplified Instructional Computer (SIC) is a virtual computer that has hardware features which
are often found in real machines. There are two versions of this machine:
1.Memory of SIC
2.Registers of SIC
There are 5 registers in SIC. Every register has an address associated with it known as register
number. Size of each register is 4 bytes. On basis of register size, integer size is dependent.
III. L(Linkage Register-2): It stores the return address of instruction in case of subroutines.
•
• If x=0 it means direct addressing mode.
• If x=1 it means indexed addressing mode.
1. Load and Store Instructions: To move or store data from accumulator to memory or
vice-versa. For example LDA, STA, LDX, STX etc.
2. Comparison Instructions: Used to compare data in memory by contents in accumulator.
For example COMP data.
3. Arithmetic Instructions: Used to perform operations on accumulator and memory and
store result in accumulator. For example ADD, SUB, MUL, DIV etc.
4. Conditional Jump: compare the contents of accumulator and memory and performs
task based on conditions. For example JLT, JEQ, JGT
5. Subroutine Linkage: Instructions related to subroutines. For example JSUB, RSUB
Assembler converts the assembly language into machine language. The main function of an
assembler is assign addresses to labels. The output of the assembler program is the object
program, a machine language translation of the source program.
All fuctions except function 2 can be established by sequential processing of source program
one line at a time.
The assembler must write the generated object code onto some output device. This object
program will later be loaded into memory for execution.
1. Header record: Contains the program name, starting address and length.
2. Text record: Contains the machine code and data of the program.
3. End record: Marks the end of the object program and specifies the address in the
program where execution is to begin.
Assembler uses three major internal data structures: OPTAB,SYMTAB and LOCCTR
• Includes the name and value for each label in the source program and flags to indicate
error conditions.
• During Pass 1 of the assembler, labels are entered into SYMTAB as they are encountered
in the source program along with their assigned addresses.
• During Pass 2, symbols used as operands are looked up in SYMTAB to obtain the
addresses to be inserted in the assembled instructions.
Algorithm
Step4:SYMTAB find values of all operations and convert it into object code
Module II
Assemblers & Macro-processor
Machine dependent assembler features – Instruction formats and addressing modes – Program
relocation - Machine independent assembler features -Literals – Symbol-defining statements –
Expressions - One pass assemblers and Multi pass assemblers. Basic macro processor functions
- Macro Definition and Expansion – Macro Processor system software tools
Assembler
• An assembler is a program that converts assembly language into machine code.
• It takes the basic commands and operations from assembly code and converts them into
binary code that can be recognized by a processor.
• Assemblers are similar to compilers in that they produce executable code. However,
assemblers are more simplistic since they only convert low-level code (assembly
language) to machine code.
• Each assembly language is designed for a specific processor, assembling a program is
performed using a simple one-to-one mapping from assembly code to machine code.
1.Instruction formats
1. One-byte instructions –
In 1-byte instruction, the opcode and the operand of an instruction are represented in one
byte.
Example: Copy the contents of accumulator in register B.
MOV B, A
Opcode- MOV
Operand- B, A
2. Two-byte instructions –
Two-byte instruction is the type of instruction in which the first 8 bits indicates the opcode and
the next 8 bits indicates the operand.
Example: Load the hexadecimal data 32H in the accumulator.
MOV A, 32H
Opcode- MVI
Operand- A, 32H
3. Three-byte instructions –
Three-byte instruction is the type of instruction in which the first 8 bits indicates the opcode
and the next two bytes specify the 16-bit address.
Example-1: Load contents of memory 2050H in the accumulator.
LDA 2050H
Opcode- LDA
Operand- 2050H
Addressing Modes
The different ways in which location of an operand is specified in an instruction are referred to
as “Addressing Modes”.The three basic modes of addressing are −
1. Register addressing
2. Immediate addressing
3. Memory addressing
Program Relocation
Relocation means moving stuff from one place to another. Here, there is a program which
contains some absolute addresses, which make sense if the program is located at a certain
address named A. If the program is loaded to a different address named B, we need to update
all of these addresses, translating them by B−A. This is address relocation. A loader (a program
loading another program to memory) which does this is called a relocating loader.
Absolute Program
2.Symblol
• Symbol in almost all assemblers is a combination of letters and digits which begins with
a letter. It usually has a mnemonic name.
• Numeric symbol answers the question how many and address symbol answers the
question where.
• An assembler symbol is human-readable representation of a number, or a position in
the program.
• The first kind of symbol is called numeric symbol The second one is called address
symbol
• Example
ADD A,100
3.Symbol-Defining Statements
Symbol defining statements are EQU and Org
1.EQU : The EQU directive gives a symbolic name to a numeric constant, a register-relative
value or a PC-relative value.It is udes to assign a value or expression to variable or register
Syntax
name EQU expr{, type}
• name is the symbolic name to assign to the value.
• Expr is a value or expression
Example
• abc EQU 2
Assigns the value 2 to the symbol abc.
2.ORG: This directive is used at the time of assigning starting address for a module or segment.
Syntax
ORG memory_location
Example
ORG 1050H
By this instruction, the assembler gets to know that the statements following this instruction,
must be stored in the memory location beginning with address 1050H.
Expressions
Expressions consist of one or more integer literals or symbol references, combined using
operators.
There are two types of expressions-Simple and Complex
1.Simple Expression
2.Complex Expressions
A complex expression is any arithmetic expression involving more than two terms and one
operator.
A complex expression that is easy to convert to assembly language is one that involves three
terms and two operators, for example:
X := W * Y + Z;
Types of assembler:
1. Single Pass Assembler /One Pass Assembler
2. Two Pass Assembler
• In two pass assembler Processing of source program can be done in two passes.
• The internal tables and subroutines that are used only during Pass 1.
• The main problems to assemble a program in one pass involves forward references. It can
eliminate in two pass assembler by doing the conversion in two separate passes
PASS 1 Operations
• Assign addresses to all statements in the program.
• Addresses of symbolic labels are stored.
PASS 2 Operations
• Translate opcode and symbolic operands.
• Generate data values defined by BYTE,WORD etc.
• Assemble directives will be processed.
• Write the object program and assembly listing.
Macro Definition
A macro definition consists of name, set of formal parameters and body of code.
Two assembler directives (MACRO and MEND) are used in macro definitions.
The statements inside these directives called as macro body that defined with the macro name.
• MACRO: identify the beginning of a macro definition
• MEND: identify the end of a macro definition
• Each parameter begins with ‘&’
Macro Expansion.
A macro call leads to macro expansion. During macro expansion, the macro statement is
replaced by sequence of assembly statements.
The macro called the entire code when the program is called.
#define max(a,b) a>b?a:b
Main ()
{
int x , y;
x=4; y=6;
z = max(x, y);
}
The above program was written using C programming statements. Defines the macro max,
taking two arguments a and b. This macro may be called like any C function, using identical
syntax. Therefore, after preprocessing
Becomes z = x>y ? x: y;
1. Translator
• A Translator is a system program that converts a program in one language to a program
in another language.
• A Translator can be denoted by following symbol: STTBSTBT
Where S = Source Language
T = Target Language
B = Base Language in which the translator is written
2. Assembler
3. Compiler
• A Compiler is a language translator that takes as input a source program in some HLL
and converts it into a lower-level language (i.e. machine or assembly language).
• So, an HLL program is first compiled to generate an object file with machine-level
instructions (i.e. compile time) and then instructions in object file are executed (i.e. run
time).
4. Interpreters
• An Interpreter is similar to a compiler, but one big difference is that it executes each line
of source code as soon as its equivalent machine code is generated. (This approach is
different from a compiler, which compiles the entire source code into an object file that
is executed separately).
• If there are any errors during interpretation, they are notified immediately to the
programmer and remaining source code lines are not processed.
• The main advantage with Interpreters is that, since it immediately notifies an error to
the programmer, debugging becomes a lot easier.
5. Pre-processors
6. Linker
• A Linker (or a Linkage Editor) takes the object file, loads and compiles the external sub-
routines from the library and resolves their external references in the main-program.
• A Compiler generates an object file after compiling the source code. But this object file
cannot be executed immediately after it gets generated.
• This is because the main program may use separate subroutines in its code (locally
defined in the program or available globally as language subroutines). The external sub-
routines have not been compiled with the main program and therefore their addresses
are not known in the program.
7. Loaders
• A Loader does the job of coordinating with the OS to get the initial loading address for
the program, prepares the program for execution (i.e. generates an .exe file) and loads it
at that address.
• Also, during the course of its execution, a program may be relocated to a different area
of main memory by the OS (when memory is needed for other programs).
Module III
Loaders And Linkers
Basic loader functions - Design of an Absolute Loader Machine dependent loader features -
Relocation – Program Linking – Algorithm and Data Structures for Linking Loader - Machine-
independent loader features – Automatic Library Search – Loader Options- Loader design
options - Linkage Editors – Dynamic Linking – Bootstrap Loaders
1.Allocation:
• Allocates the space in the memory where the object program would be loaded for
Execution.
• It allocates the space for program in the memory, by calculating the size of the program.
This activity is called allocation.
• Allocation is done by the programmer and hence it is the duty of the programmer to
ensure that the programs do not get overlap.
2.Linking:
• It links two or more object codes and provides the information needed to allow
references between them.
• It resolves the symbolic references (code/data) between the object modules by
assigning all the user subroutine and library subroutine addresses. This activity is called
linking.
• In absolute loader linking is done by the programmer as the programmer is aware about
the runtime address of the symbols.
• Linking is done by the loader
3.Relocation:
• It modifies the object program by changing the certain instructions so that it can be
loaded at different address from location originally specified.
• There are some address-dependent locations in the program, such address constants
must be adjusted according to allocated space, such activity done by loader is called
relocation.
• Relocation is done by the assembler as the assembler is aware of the starting address of
the program.
4.Loading:
• It brings the object program into the memory for execution.
• It places all the machine instructions and data of corresponding programs into the
memory. Thus program now becomes ready for execution, this activity is called loading.
• Loading is done by the loader and hence the assembler must supply to the loader the
object program.
1.Relocation
• In general, the user does not know a priori where the program will reside in memory. A
relocating loader is capable of loading a program to begin anywhere in memory:
• The addresses produced by the compiler run from 0 to L–1. After the program has been
loaded, the addresses must run from N to N +L–1.
• Therefore, the relocating loader adjusts, or relocates, each address in the program.
• Fields that are relocated are called relative; those which are not relocated are
called absolute.
2.Program Linking
A whole program usually is not written in a single file. Apart from code and data definitions in
multiple files, a user code often makes references to code and data defined in some
"libraries".
Linking is the process in which references to "externally" defined objects (code and data).
Traditionally linking used to be performed as a task after basic translation of the user program
files.
Two important aspects in linking are - locating the individual object modules in the combined
executable program image, and adjusting the addresses used for external references in the
various places in the program.
Linking is performed at the last step in compiling a program.
Source code -> compiler -> Assembler -> Object code -> Linker -> Executable file -> Loader
Linking is of two types:
1. Static Linking – It is performed during the compilation of source program. It takes collection
of re locatable object file and command-line argument and generate fully linked object file that
can be loaded and run.
2. Dynamic linking – Dynamic linking is performed during the run time. This linking is
accomplished by placing the name of a shareable library in the executable image
2.Loader Options
Many loaders allow the user to specify options that modify the standard processing
Loader option 1: Allows the selection of alternative sources of input.
• Ex : INCLUDE program-name (library-name) might direct the loader to read the
designated object program from a library and treat it as input.
Loader option 2: Allows the user to delete external symbols or entire control sections.
• Ex : CHANGE name1, name2 might cause the external symbol name1 to be changed to
name2 wherever it appears in the object programs.
Loader option 3: Involves the automatic inclusion of library routines to satisfy external
references.
• Ex. : LIBRARY MYLIB
Such user-specified libraries are normally searched before the standard system libraries.
This allows the user to use special versions of the standard routines.
1.Linkage Editors
• The linkage editor performs relocation of all control sections relative to the start of the
linked program.
• Thus, all items that need to be modified at load time have values
• This means that the loading can be accomplished in one pass with no external symbol
table required.
• Linkage editors can perform many useful functions besides simply preparing an object
program for execution.
• Linkage editors can also be used to build packages of subroutines or other control
sections that are generally used together.
• This can be useful when dealing with subroutine libraries that support high-level
programming languages
Bootstrap loader
• A bootstrap loader is a program that resides in the computer's EPROM, ROM, or another
non-volatile memory.
• It is automatically executed by the processor when turning on the computer.
• The bootstrap loader reads the hard drives boot sector to continue to load the
computer's operating system.
• When the computer is turned on or restarted, the bootstrap loader first performs the
power-on self-test, also known as POST. If the POST is successful and no issues are
found, the bootstrap loader loads the operating system for the computer into memory.
The computer can then access, load, and run the operating system.
• The term bootstrap comes from the old phrase "Pull yourself up by your bootstraps."
• Alternatively referred to as bootstrapping, bootloader, or boot program,
Module IV
Compilers
Basic Compiler Functions: Grammars, Lexical Analysis, Syntactic Analysis, Code Generation.
Machine Dependent Compiler Features – Intermediate Form of the program, Machine
Dependent Code optimization. Machine Dependent Compiler features –Structured variables,
machine-independent code optimization, Storage allocation. Compiler designoptions – Division
into passes
Compiler
• A compiler is a translator that converts the high-level language into the machine
language.
• High-level language is written by a developer and machine language can be understood
by the processor.
• Compiler is used to show errors to the programmer.
• The main purpose of compiler is to change the code written in one language without
changing the meaning of the program.
• When you execute a program which is written in HLL programming language then it
executes into two parts.
• In the first part, the source program compiled and translated into the object program
(low level language).
• In the second part, object program translated into the target program through the
assembler.
1.Lexical Analysis:
2.Syntax Analysis
3.Semantic Analysis
• In the intermediate code generation, compiler generates the source code into the
intermediate code.
• Intermediate code is generated between the high-level language and the machine
language.
• The intermediate code should be generated in such a way that you can easily translate it
into the target machine code.
4.Code Optimization
5.Code Generation
1.Intermediate form
It is the form which is considered for the code optimization technique of the program which has
to be compiled. Here, the analysis of the semantics and the syntax of the source statements
have already taken place.
Operation op1, op2, result
Here, the function which has to be performed by the object code is the operation. The
operands for this operation are op1, op2. The resulting value is placed in the result.
Intermediate code-generation routines create the quadruples which we use in the machine-
dependent coding.
expressions different from the rest. It is because they do not change themselves going from one
iteration to the next of the loop.
1.Analysis Phase
• Known as the front-end of the compiler, the analysis phase of the compiler reads the
source program, divides it into core parts and then checks for lexical, grammar and
syntax errors.
• The analysis phase generates an intermediate representation of the source program
and symbol table, which should be fed to the Synthesis phase as input.
2.Synthesis Phase
Known as the back-end of the compiler, the synthesis phase generates the target program
with the help of intermediate source code representation and symbol table.
A compiler can have many phases and passes.
• Pass : A pass refers to the traversal of a compiler through the entire program.
• Phase : A phase of a compiler is a distinguishable stage, which takes input from the
previous stage, processes and yields output that can be used as input for the next
stage. A pass can have more than one phase.