UNIT 6
INTRODUCTION
TO SYSTEMS
SOFTWARE
What is System Software?
System software is software that provides a platform for other software. Some
examples can be operating systems, antivirus software, disk formatting
software, computer language translators, etc. These are commonly prepared
by computer manufacturers.
This software consists of programs written in low-level languages, used to
interact with the hardware at a very basic level. System software serves as the
interface between the hardware and the end users.
System software refers to the collection of programs and software components
that enable a computer or computing device to function properly.
It acts as an intermediary between the user and the computer hardware,
allowing the user to interact with the hardware and use various applications
and programs.
Some common types of system software include operating systems (such as
Windows, macOS, or Linux), device drivers, utility programs, programming
languages, and system libraries.
◦Operating systems are the most important type of system software, as
they provide the foundational framework for all other software and
applications to run on the computer.
◦They manage computer resources, such as memory and processing power,
and provide a user interface for users to interact with the system.
◦ Device drivers are another important type of system software, as they
allow the operating system to communicate with hardware devices such
as printers, scanners, and graphics cards.
◦Utility programs provide additional functionality to the operating system,
such as disk defragmentation, virus scanning, and file compression.
Examples of System Software
System software is a type of computer program that is designed to run a
computer’s hardware and application programs and examples of system
software include operating systems (OS) (like macOS, Linux, Android, and
Microsoft Windows), game engines, search engines(like google,Bing,Yahoo!),
industrial automation, computational science software, and (SaS)software as
a service applications.
• Operating systems (OS): Windows, Linux, macOS, etc.
• Device drivers: software that enables the communication between
hardware and OS.
• Firmware: pre-installed low-level software that controls a device’s basic
functions.
• Utility software: tools for system maintenance and optimization.
• Boot loaders: software that initializes the OS during startup.
Why use System Software?
Here are some reasons why system software is necessary:
[Link] Communication: System software serves as an interface between the hardware
and software components of a computer, enabling them to communicate and work together.
[Link] Management: System software manages computer resources such as memory,
CPU usage, and storage, optimizing their utilization and ensuring that the system operates
efficiently.
[Link]: System software provides security measures such as firewalls, antivirus software,
and encryption, protecting the system and its data from malware, viruses, and other security
threats.
[Link] Interface: System software provides a user interface that allows users to interact with
the computer or computing device and perform various tasks.
[Link] Support: System software supports the installation and running of applications
and software on the system.
[Link]: System software allows for customization of the system settings and
configuration, giving users greater control over their computing environment.
Features of System Software
The most important features of system software are as below.
[Link] Management: operating system perform memory management. The OS
keeps track of the primary memory and allocates the memory when a process requests
it.
[Link] Management: OS performs process management. Allocates the main
memory (RAM) to a process and de-allocates it when it is no longer required.
[Link] Management: Operating system perform file management. Allocates and de-
allocates the resources and decides who gets the resources.
[Link]: Prevents unauthorized access to programs and data using passwords.
[Link]-detecting Aids: Production of dumps, traces, error messages, and other
debugging and error-detecting methods.
[Link]: The OS schedules the process through its scheduling algorithms.
Types of System Software
1. Operating System
An operating system (OS) is a type of system software that manages a computer’s
hardware and software resources. It provides common services for computer
programs. An OS acts as a link between the software and the hardware. It controls
and keeps a record of the execution of all other programs that are present in the
computer, including application programs and other system software.
Important Tasks Performed by the Operating System
The main functions of operating systems are as follow:
• Resource Management: The operating system manages and allocates memory,
CPU time, and other hardware resources among the various programs and processes
running on the computer.
• Process Management: The operating system is responsible for starting, stopping,
and managing processes and programs. It also controls the scheduling of processes
and allocates resources to them.
• Memory Management: The operating system manages the computer’s primary
memory and provides mechanisms for optimizing memory usage.
• Security: The operating system provides a secure environment for the
user, applications, and data by implementing security policies and
mechanisms such as access controls and encryption.
• File Management: The operating system is responsible for organizing
and managing the file system, including the creation, deletion, and
manipulation of files and directories.
• Device Management: The operating system manages input/output
devices such as printers, keyboards, mice, and displays. It provides the
necessary drivers and interfaces to enable communication between the
devices and the computer.
2. Programming Language Translator
Programming language translators are programs that translate code written in one
programming language into another programming language. below are examples of
programming language translator.
• Compiler: A compiler is a software that translates the code written in one language to some
other language without changing the meaning of the program. The compiler is also said to
make the target code efficient and optimized in terms of time and space.
A compiler performs almost all of the following operations during compilation pre-processing,
lexical analysis, parsing, semantic analysis (syntax-directed translation), conversion of input
programs to an intermediate representation, code optimization, and code generation.
Examples of compilers may include gcc(C compiler), g++ (C++ Compiler ), javac (Java
Compiler), etc.
• Interpreter: An interpreter is a computer program that directly executes, i.e. it performs
instructions written in a programming or scripting language. Interpreters do not require the
program to be previously compiled into a machine language program. An interpreter
translates high-level instructions into an intermediate form, which is then executed.
Interpreters are fast as it does not need to go through the compilation stage during which
machine instructions are generated. The interpreter continuously translates the program until
the first error is met. If an error comes it stops executing. Hence debugging is easy. Examples
may include Ruby, Python, PHP, etc.
◦Assembler: An assembler is a program that converts the assembly
language into machine code. It takes the basic commands and operations
and converts them into binary code specific to a type of processor.
Assemblers produce executable code that is similar to compilers. However,
assemblers are more simplistic since they only convert low-level code
(assembly language) to machine code. Since 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.
On the other hand, compilers must convert generic high-level source code
into machine code for a specific processor.
3. Device Drivers
Device drivers are a class of system software that minimizes the need for system
troubleshooting. Internally, the operating system communicates with hardware
elements. Device drivers make it simple to manage and regulate this communication.
To operate the hardware components, the operating system comes with a variety of
device drivers. The majority of device drivers, including those for a mouse, keyboard,
etc., are pre-installed in the computer system by the businesses that make computers.
4. Firmware
These are the operational programs installed on computer motherboards that assist the
operating system in distinguishing between Flash, ROM, EPROM, and memory chips.
However, managing and controlling all of a device’s actions is the main purpose of
any firmware software. For initial installation, it makes use of non-volatile chips.
There are mainly two main types of firmware chips:
• BIOS (Basic Input/Output System) chip.
• UEFI (Unified Extended Firmware Interface) chips.
5. Utility Software
System Software and application software interact through utility software. A third-
party product called utility software is created to lessen maintenance problems
and find computer system defects. It is included with your computer’s operating
system.
Listed below are some particular attributes of utility software:
• Users benefit from protection from threats and infections.
• WinRAR and WinZip are programs that aid in reducing disk size.
• It assists with disk partitioning and functions as a windows disk management
service.
• It makes it easier for users to back up old data and improves system security.
• It operates as a disk defragmenter to organize the dispersed files on the drive.
• It aids in the recovery of lost data.
Uses of System Software
Here are some common uses of system software:
[Link] systems: An operating system is a type of system software that manages computer
hardware and software resources and provides common services for computer programs. Operating
systems are used in a wide variety of applications, from personal computers to servers,
supercomputers, and embedded systems.
[Link] drivers: Device drivers are a type of system software that allow operating systems to
communicate with hardware devices such as printers, scanners, and graphics cards. Without device
drivers, operating systems would not be able to interact with hardware devices, making them
useless.
[Link]: Firmware is a type of system software that provides low-level control over hardware
devices such as BIOS firmware, firmware for embedded systems, and firmware for network devices
such as routers and switches.
[Link] utilities: System utilities are a type of system software that performs routine maintenance
tasks such as disk cleanup, defragmentation, antivirus scanning, and system backups. These utilities
help ensure that the computer system is running efficiently and securely.
[Link] tools: Programming tools are a type of system software that is used by developers to
create, debug, and optimize software applications. These tools include compilers, debuggers,
integrated development environments (IDEs), and performance analysis tools.
Advantages of System Software
[Link] management: System software manages and allocates resources such as
memory, CPU, and input/output devices to different programs.
[Link] performance: System software optimizes the performance of the computer and
reduces the workload on the user.
[Link]: System software provides security features such as firewalls, anti-virus protection,
and access controls to protect the computer from malicious attacks.
[Link]: System software ensures compatibility between different hardware and
software components, making it easier for users to work with a wide range of devices and
software.
[Link] of use: System software provides a user-friendly interface and graphical environment,
making it easier for users to interact with and control the computer.
[Link]: System software helps ensure the stability and reliability of the computer,
reducing the risk of crashes and malfunctions.
[Link] functionality: System software provides a range of tools and utilities for
performing various tasks, increasing the functionality and versatility of the computer.
Disadvantages of System Software
[Link]: System software can be complex and difficult to understand, especially for
non-technical users.
[Link]: Some system software, such as operating systems and security software, can be
expensive.
[Link] Overhead: The use of system software can result in increased system overhead,
which can slow down the performance of the computer and reduce its efficiency.
[Link]: System software, especially the operating system, can be vulnerable to
security threats and viruses, which can compromise the security and stability of the
computer.
[Link]: Upgrading to a newer version of system software can be time-consuming and
may cause compatibility issues with existing software and hardware.
[Link] Customizability: Some system software may have limited options for
customization, making it difficult for users to personalize their computing experience.
[Link]: Other software programs and devices may depend on the system software,
◦Difference between System Software and Application
Software:
System Software Application Software
System Software maintains the system
Application software is built for specific
resources and gives the path for
tasks.
application software to run.
Low-level languages are used to write the While high-level languages are used to
system software. write the application software.
It is general-purpose software. While it’s a specific purpose software.
Without system software, the system While Without application software
stops and can’t run. system always runs.
System software runs when the system is
While application software runs as per the
turned on and stops when the system is
user’s request.
turned off.
Example: System software is an operating Example: Application software is
system, etc. Photoshop, VLC player, etc.
System software components:
◦System software components include the operating system, device drivers,
firmware, and utility software.
◦These components manage the hardware and provide a platform for
application software.
◦Operating System: The operating system (OS) is the core of system
software, responsible for managing hardware resources and providing a
platform for running applications. Examples include Windows, macOS, and
Linux.
◦Device Drivers: Device drivers are small programs that enable
communication between the operating system and specific hardware
devices, allowing them to function properly.
◦Firmware: Firmware is low-level software embedded in hardware, such as
the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware
Interface).
◦Firmware: Firmware is low-level software embedded in hardware, such as
the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware
Interface).
◦Utility Software: Utility software includes programs that help manage
the computer system, such as disk defragmenters, antivirus software, and
system maintenance tools.
◦NOTE: It is described in detail in previous slides
◦Assemblers:
◦An assembler is a program that translates low-level assembly language
code into machine code, which the computer's processor can directly
execute.
◦ It essentially bridges the gap between human-readable assembly
language and the machine's binary instructions.
◦Here's a more detailed explanation:
◦Assembly Language:
◦Assembly language uses mnemonics (short, symbolic codes) and
instructions that correspond to specific machine operations. For example,
ADD might be used to add two values, or MOV to move data.
◦Assembler's Role:
◦The assembler's job is to take these assembly language instructions and
convert them into the binary (0s and 1s) code that the CPU understands.
◦Machine Code:
◦Machine code, also known as object code, is the binary representation of
instructions that the processor can directly interpret and execute.
◦Function:
◦The assembler essentially acts as a translator, transforming human-
readable assembly language into a form that the computer can execute.
◦Relationship to Compilers:
◦Assemblers are similar to compilers, which translate higher-level
programming languages (like C++ or Python) into machine code.
However, assemblers work with assembly language, which is closer to the
machine's hardware level.
◦ The compilation process in a compiler involves translating high-level source code into
machine-readable instructions. This process typically includes pre-processing, compiling,
assembling, and linking. The compiler checks for errors, analyzes the code, and converts it
into an executable file.
◦ Detailed Breakdown:
◦ 1. Pre-processing:
◦ This initial phase involves tasks like removing comments, expanding macros, including
files, and handling conditional compilation.
◦ 2. Compiling:
◦ The compiler analyzes the pre-processed code for syntax and semantic errors. If no errors
are found, it converts the code into assembly language.
◦ 3. Assembling:
◦ The assembler translates the assembly code into machine code (object code).
◦ 4. Linking:
◦ This final stage merges the object code with necessary libraries and other files to create
the final executable program.
◦ In essence, the compilation process bridges the gap between human-readable code and
machine-executable instructions, ensuring that the program can be understood and
executed by the computer's processor.
◦Compilation process
◦In essence, the compilation process bridges the gap
between human-readable code and machine-
executable instructions, ensuring that the program
can be understood and executed by the computer's
processor.
◦Types of Assemblers:
◦The assembler generates instructions by evaluating the mnemonics
(symbols) in the operation field and finding the value of symbols and
literals to produce machine code. On the basis of this functionality,
assembler has two types:
◦Single-Pass Assembler: If an assembler does all this work in one
scan then it is called a single-pass assembler.
◦Multiple-Pass Assembler: If it does it in multiple scans then called a
multiple-pass assembler
◦One-Pass Assembler converts the whole conversion of assembly code
into machine code in one pass or one go. On the other hand, Multi-Pass-
Assembler takes multiple passes to convert assembly code into
machine language.
◦Working of Assembler
◦Assembler divides tasks into two passes:
◦Pass-1
◦Define symbols and literals and remember them in the symbol table and
literal table respectively.
◦Keep track of the location counter.
◦Process pseudo-operations.
◦Defines a program that assigns the memory addresses to the variables
and translates the source code into machine code.
◦Pass-2
◦Generate object code by converting symbolic op-code into respective
numeric op-code.
◦Generate data for literals and look for values of symbols.
◦Defines a program that reads the source code two times.
◦It reads the source code and translates the code into object code.
◦As a whole assembler works as:
◦Elements of Assembly language programming :
◦Assembly language programming involves several key elements including
syntax, labels, commands, operands, directives, macros, and mnemonics.
These elements work together to create instructions that the assembler
can translate into machine code.
◦1. Syntax: The syntax of assembly language defines the rules for
constructing valid statements and expressions. It dictates how labels,
commands, operands, and other elements are organized and used.
◦2. Labels: Labels are symbolic names that identify memory locations or
addresses within the assembly code. They allow programmers to refer to
specific locations without needing to know their exact memory addresses.
◦3. Commands/Instructions: Commands, also known as instructions, are
the building blocks of assembly language programs. They specify the
operations the processor should perform, such as loading data, performing
arithmetic calculations, or controlling program flow.
◦4. Operands: Operands provide the data or values that the instructions
operate on. They can be registers, memory addresses, literal values, or
other data sources.
◦5. Directives: Directives are instructions to the assembler, not the
processor. They control how the assembly code is processed, such as
allocating memory, defining data types, or including other files.
◦6. Macros: Macros are reusable blocks of code that can be defined and
called multiple times within a program. They help to reduce code
duplication and improve code readability.
◦7. Mnemonics: Mnemonics are short, easy-to-remember codes used to
represent machine instructions. They provide a human-readable
representation of the underlying machine code.
◦In essence, these elements work together to create a language that allows
programmers to directly interact with the hardware, enabling low-level
control and optimization.
◦Introduction To Compilers:
◦A compiler is a translating program that translates the instructions of high
level language to machine level language.
◦A program which is input to the compiler is called a Source program.
◦ This program is now converted to a machine level language by a compiler
is known as the Object code.
◦
◦How does a compiler work?
◦The process of compiling code involves several [Link], Code passes
through these steps sequentially and if there is any mistake in code then it will
be examined through these steps and thus compilation process stops in-
between and show compilation [Link] if everything is OK then compiler
does not show any error and compile the source code . There are the following
steps which are involved during compiling:
◦Lexical Analysis
◦The source code is first tested by the compiler’s lexer, which breaks the source
code into tokens, such as keywords, identifiers, operators, and punctuation.
◦Syntax Analysis
◦The next step is syntax analysis, where the compiler’parser checks the code for
syntax errors and ensures that it follows the rules of the programming language.
The compiler generates an Abstract Syntax Tree (AST) that represents the
structure of the code.
◦Semantic Analysis
◦Once the code is syntactically correct, the compiler performs semantic analysis
on parsed code to find the meaning. The compiler check for logical errors, such
as type mismatches, undeclared variables, and incorrect usage of operators.
◦Optimization
◦The compiler may perform various optimizations to improve the performance of
the resulting code. It is an optional phase of compiler. It removes dead code and
arranges the sequence of instructions in order to boost the program execution.
◦Code generations
◦The last step is code generation, where the compiler translates the AST into
machine-readable code. The code generator creates assembly language code,
which is then translated into binary code that can be executed by the computer.
◦Phases of a Compiler
◦ A compiler is a software tool that converts high-level programming code into machine code
that a computer can understand and execute. It acts as a bridge between human-readable
code and machine-level instructions, enabling efficient program execution. The process of
compilation is divided into six phases:
◦ Lexical Analysis: The first phase, where the source code is broken down into tokens such as
keywords, operators, and identifiers for easier processing.
◦ Syntax Analysis or Parsing: This phase checks if the source code follows the correct syntax
rules, building a parse tree or abstract syntax tree (AST).
◦ Semantic Analysis: It ensures the program’s logic makes sense, checking for errors like
type mismatches or undeclared variables.
◦ Intermediate Code Generation: In this phase, the compiler converts the source code into
an intermediate, machine-independent representation, simplifying optimization and
translation.
◦ Code Optimization: This phase improves the intermediate code to make it run more
efficiently, reducing resource usage or increasing speed.
◦ Target Code Generation: The final phase where the optimized code is translated into the
target machine code or assembly language that can be executed on the computer.
◦The whole compilation process is divided into two parts, front-end and
back-end.
◦ These six phases are divided into two main parts, front-end and back-end
with the intermediate code generation phase acting as a link between
them. The front end analyzes source code for syntax and semantics,
generating intermediate code, while ensuring correctness.
◦The back end optimizes this intermediate code and converts it into
efficient machine code for execution.
◦The front end is mostly machine-independent, while the back end is
machine-dependent.
◦The compilation process is an essential part of transforming high-level
source code into machine-readable code. A compiler performs this
transformation through several phases, each with a specific role in making
the code efficient and correct. Broadly, the compilation process can be
divided into two main parts:
◦Analysis Phase: The analysis phase breaks the source program into its
basic components and creates an intermediate representation of the
program. It is sometimes referred to as front end.
◦Synthesis Phase: The synthesis phase creates the final target program
from the intermediate representation. It is sometimes referred to as back
end.
◦1. Lexical Analysis
◦Lexical analysis is the first phase of a compiler, responsible for
converting the raw source code into a sequence of tokens. A token is
the smallest unit of meaningful data in a programming language.
Lexical analysis involves scanning the source code, recognizing
patterns, and categorizing groups of characters into distinct tokens.
◦The lexical analyzer scans the source code character by character,
grouping these characters into meaningful units (tokens) based on the
language’s syntax rules. These tokens can represent keywords,
identifiers, constants, operators, or punctuation marks. By converting
the source code into tokens, lexical analysis simplifies the process of
understanding and processing the code in later stages of compilation.
◦Example:
◦ int x = 10;
◦The lexical analyzer would break this line into the following tokens:
◦int – Keyword token (data type)
◦x – Identifier token (variable name)
◦= – Operator token (assignment operator)
◦10 – Numeric literal token (integer value)
◦; – Punctuation token (semicolon, used to terminate statements)
◦Each of these tokens is then passed on to the next phase of the compiler
for further processing, such as syntax analysis.
◦ 2. Syntax Analysis
◦ Syntax analysis, also known as parsing, is the second phase of a compiler where the
structure of the source code is checked. This phase ensures that the code follows the
correct grammatical rules of the programming language.
◦ The role of syntax analysis is to verify that the sequence of tokens produced by the lexical
analyzer is arranged in a valid way according to the language’s syntax. It checks whether
the code adheres to the language’s rules, such as correct use of operators, keywords, and
parentheses. If the source code is not structured correctly, the syntax analyzer will
generate errors.
◦ To represent the structure of the source code, syntax analysis uses parse trees
or syntax trees.
◦ Parse Tree: A parse tree is a tree-like structure that represents the syntactic structure of the
source code. It shows how the tokens relate to each other according to the grammar rules.
Each branch in the tree represents a production rule of the language, and the leaves
represent the tokens.
◦ Syntax Tree: A syntax tree is a more abstract version of the parse tree. It represents the
hierarchical structure of the source code but with less detail, focusing on the essential
syntactic structure. It helps in understanding how different parts of the code relate to each
other.
3. Semantic Analysis
Semantic analysis is the phase of the compiler that ensures the source
code makes sense logically. It goes beyond the syntax of the code and
checks whether the program has any semantic errors, such as type
mismatches or undeclared variables.
Semantic analysis checks the meaning of the program by validating
that the operations performed in the code are logically correct. This
phase ensures that the source code follows the rules of the
programming language in terms of its logic and data usage.
Some key checks performed during semantic analysis include:
Type Checking: The compiler ensures that operations are performed on
compatible data types. For example, trying to add a string and an
integer would be flagged as an error because they are incompatible
types.
◦Example:
◦int a = 5;
◦float b = 3.5;
◦a = a + b;
◦Type Checking:
◦a is int and b is float. Adding them (a + b) results in float, which cannot be
assigned to int a.
◦Error: Type mismatch: cannot assign float to int.
◦4. Intermediate Code Generation
◦ Intermediate code is a form of code that lies between the high-level source code and the
final machine code. It is not specific to any particular machine, making it portable and
easier to optimize. Intermediate code acts as a bridge, simplifying the process of
converting source code into executable code.
◦ The use of intermediate code plays a crucial role in optimizing the program before it is
turned into machine code.
◦ Platform Independence: Since the intermediate code is not tied to any specific
hardware, it can be easily optimized for different platforms without needing to recompile
the entire source code. This makes the process more efficient for cross-platform
development.
◦ Simplifying Optimization: Intermediate code simplifies the optimization process by
providing a clearer, more structured view of the program. This makes it easier to apply
optimization techniques such as:
◦ Dead Code Elimination: Removing parts of the code that don’t affect the program’s
output.
◦ Loop Optimization: Improving loops to make them run faster or consume less memory.
◦ Common Subexpression Elimination: Reusing previously calculated values to avoid
redundant calculations.
◦Easier Translation: Intermediate code is often closer to machine code, but
not specific to any one machine, making it easier to convert into the target
machine code. This step is typically handled in the back end of the
compiler, allowing for smoother and more efficient code generation.
◦Example: a = b + c * d;
◦t1 = c * d
◦t2 = b + t1
◦a = t2
◦5. Code Optimization
◦Code Optimization is the process of improving the intermediate or target code to
make the program run faster, use less memory, or be more efficient, without
altering its functionality. It involves techniques like removing unnecessary
computations, reducing redundancy, and reorganizing code to achieve better
performance. Optimization is classified broadly into two types:
◦Machine-Independent
◦Machine-Dependent
◦Common Techniques:
◦Constant Folding: Precomputing constant expressions.
◦Dead Code Elimination: Removing unreachable or unused code.
◦Loop Optimization: Improving loop performance through invariant code motion
or unrolling.
◦Strength Reduction: Replacing expensive operations with simpler ones.
◦Code Generation
◦Code Generation is the final phase of a compiler, where the intermediate
representation of the source program (e.g., three-address code or abstract
syntax tree) is translated into machine code or assembly code. This
machine code is specific to the target platform and can be executed
directly by the hardware.
◦The code generated by the compiler is an object code of some lower-level
programming language, for example, assembly language. The source code
written in a higher-level language is transformed into a lower-level
language that results in a lower-level object code, which should have the
following minimum properties:
◦It should carry the exact meaning of the source code.
◦It should be efficient in terms of CPU usage and memory management.
◦Macro Processor
◦ Macro instruction is a notational convenience for the programmer. For every occurrence of
macro, the whole macro body or macroblock of statements gets expanded in the main source
code. Thus Macro instructions make writing code more convenient.
◦ macro definition may be written using formal parameters . A macro call on such a macro
specifies actual parameters.
◦ Salient features of Macro Processor:
◦ Macro represents a group of commonly used statements in the source programming
language.
◦ Macro Processor replaces each macro instruction with the corresponding group of source
language statements. This is known as the expansion of macros.
◦ Using Macro instructions programmer can leave the mechanical details to be handled by the
macro processor.
◦ Macro Processor designs are not directly related to the computer architecture on which it
runs.
◦ Macro Processor involves definition, invocation, and expansion.
◦Macro Expansion can be performed by using two kinds of language
processors and when we use of macro name with a set of actual parameters
is replaced by same code generated from its body .This is called macro
expansion.
◦macro expansion can be performed two ways:
◦macro assembler
◦macro pre-processor
◦Macro Assembler : It performs expansion of each macro call in a program
into a sequence of assembly language statements and also assembles the
resultant assembly language program.
◦Macro pre-processor: It only processes the macro call . Other statements
are processes with the help of assembler a macro pre-processor merely
performs expansion of macro in program. It produces an assembly
program in which a macro call has been replaced by statements that
resulted from its expansion but statements that were not macro calls have
been retained in their original from . This program can be assembled by
◦Using Macro instructions, a programmer can leave the mechanical
details to be handled by the macro processor. This makes writing code
more convenient as it allows for defining new language constructs that
can be expressed in terms of existing language components.
◦The working of a Macro Processor involves several steps:
◦1. Macro Definition
◦A macro definition is a section of code that a programmer writes (defines)
once. The macro is defined by a #define directive. Each parameter in the
macro definition begins with the character &. The macro definition may be
written using formal parameters
◦2. Macro Invocation
◦Macro invocation is whilst the macro is known as or invoked. The macro
call gives the call of the macro education being invoked and specifies the
arguments for expanding the macro.
◦3. Macro Expansion
◦This is the process where the Macro Processor replaces each macro
instruction with the corresponding group of source language
statements. This operation is known as the expansion of macros. Using
Macro instructions, a programmer can leave the mechanical details to
be handled by the macro processor.
◦Macro expansion can be performed using two kinds of language
processors:
◦Macro Assembler: It expands each macro call in a program into a
sequence of assembly language statements and assembles the
resultant assembly language program.
◦Macro Pre-processor: It only processes the macro call. Other statements
are processed with the help of an assembler. A macro pre-processor
merely performs the expansion of a macro in a program.
◦Salient Features of Macro Processors
◦Macro Processors have several salient features:
◦Macro represents a group of commonly used statements in the source
programming language.
◦Macro Processor designs are not directly related to the computer
architecture on which it runs.
◦Macro Processor involves definition, invocation, and expansion .
◦Macro processors are essential in programming, presenting a scientific
approach to handling generally used statements inside the supply
programming language.
◦ They provide a handy way for programmers to define new language
constructs and depart the mechanical information to be governed with
the aid of the macro processor.
◦ Whether you're a pro programmer or a newbie, expertise and utilizing
macro processors can notably enhance your coding performance and
effectiveness.
◦Linker and Loader:
◦When we run a program, two major players work behind the scenes to
make it happen: two components; namely, the Linker and the Loader.
◦ This may best be described as a double act of computing.
◦The most important work is done by the linker; this is the output of all
the different locations with code and produces an executable file.
◦There is then the loader function which is the one that loads this file into
memory, ready to run.
◦ Function of Linker
◦Symbol Resolution: The linker resolves symbols in the program that are
defined in one module and referenced in another.
◦Code Optimization: The linker optimizes the code generated by the
compiler to reduce code size and improve program performance.
◦Memory Management: The linker assigns memory addresses to the code
and data sections of the program and resolves any conflicts that arise.
◦Library Management: The linker can link external libraries into the
executable file to provide additional functionality.
What is Linker?
◦A linker is a special program that combines the object files, generated
by the compiler/assembler and other pieces of code to originate an
executable file that has a .exe extension.
◦In the object file, the linker searches and appends all libraries needed
for the execution of the file.
◦It regulates the memory space that will hold the code from each module.
◦It also merges two or more separate object programs and establishes
links among them.
◦Generally, linkers are of two types:
◦1. Linkage Editor
◦2. Dynamic Linker
◦What is Loader?
◦It is special program that takes input of executable files from linker,
loads it to main memory, and prepares this code for execution by
computer. Loader allocates memory space to program. Even it settles
down symbolic reference between objects. It is in charge of loading
programs and libraries in operating system. The embedded computer
systems don’t have loaders. In them, code is executed through ROM.
There are following various loading schemes:
◦1. Absolute Loaders
◦2. Relocating Loaders
◦3. Direct Linking Loaders
◦4. Bootstrap Loaders
◦Function of Loader:
◦Loading: The loader loads the executable file into memory and allocates
memory for the program.
◦Relocation: The loader adjusts the program’s memory addresses to reflect
its location in memory.
◦Symbol Resolution: The loader resolves any unresolved external symbols
that are required by the program.
◦Dynamic Linking: The loader can dynamically link libraries into the
program at runtime to provide additional functionality.
◦Differences Between Linker and Loader
Linker Loader
The main function of Linker is to generate Whereas main objective of Loader is to load
executable files. executable files to main memory.
The linker takes input of object code And the loader takes input of executable
generated by compiler/assembler. files generated by linker.
Linking can be defined as process of Loading can be defined as process of loading
combining various pieces of codes and executable codes to main memory for
source code to obtain executable code. further execution.
Linkers are of 2 types: Linkage Editor and Loaders are of 4 types: Absolute, Relocating,
Dynamic Linker. Direct Linking, Bootstrap Loader.
Another use of linker is to combine all object It helps in allocating the address to
modules. executable codes/files.
Loader is also responsible for adjusting
Linker is also responsible for arranging
references which are used within the
objects in program’s address space.
ALL THE VERY BEST