SYSTEM
PROGRAMMING &
COMPILER
CONSTRUCTION Prof. S. R. Kulkarni
( VI SEM COMP REV
)
Overall Syllabus Discussion
https://drive.google.com/file/d/1ymP3Vs1kwNv
Kmii57f1iVmvzPWrDjPY-/view?usp=sharing
UNIT 1
Introduction to System Software
COMPUTER SYSTEMS
AND SYSTEM
SOFTWARE
Hardware and software combine to solve specific
problems
Software solves some problem: entertainment,
information management, scientific problem
solving, system control, etc.
Hardware provides the basic computing
resources (Processors, Memory, System Bus
and I/O modules).
TYPES OF SOFTWARE
• Software is divided into two categories:
– Application software – used directly by user (person or possibly another program or
system) to solve some problem.
– Ultimately a computer system exists to implement applications.
– System software – it simplifies application programming by creating a convenient
environment for programming
• Implements low level hardware management functions
• Provides a standardized interface and set of abstractions.
• Examples: Compilers, Operating Systems, System Drivers, Assemblers,
Macro Processors, Loaders , Linkers …. Etc
SYSTEM SOFTWARE
•The subject introduced the design and implementation
of system software
•System software consists of a variety of programs that
support the operation of a computer
• Operating system, compiler, assembler, macro processor,
loader or linker, debugger, text editor, database
management systems, software engineering tools, ….
What is Systems Software?
Systems Software consists of a set of programs that support the operation of a computer
system and help, the programmer, to simplify the programming process and run
application software efficiently.
Examples of systems software are:
Text editors
Compilers
Loaders
Linker
Debugger
Assembler
Operating system
Systems software can be classified in two groups:
1.- Software to create a program development environment
Text editor
Compiler
Assembler
Linker
Debugger(low-level)
2.- Software to create a run-time environment
Operating system
Loader
Dynamic Linker
Program libraries
Systems Software: Program Development Environment
Text editor: Software that permits the creation and editing of text (i.e., application
programs).
Compiler: Translates programs written in a high-level language to object code or machine
code.
Assembler: Translates programs written in assembly language to object code or machine
code.
Static Linker: Combines and resolves references between object programs and creates
the executable code.
Debugger It is used to debug executable programs and their (low-level)related object
code and source program.
Systems Software: Run-Time Environment
Loader: Loads an executable code and starts its execution
Libraries:
Precompiled programs the creates a set of functions for use by other programs.
Dynamic Linker:
Loads and links shared libraries at run-time
Operating system:
An event driven program that make an abstraction of the computer system. The operating system
handles all resources efficiently, creates an environment for application programs to run, and
creates a friendly interface between the user and the computer system.
NEED FOR SYSTEMS SOFTWARE
A computer understands only the language of binary 1s and 0s. To implement even a simple
function, several thousand lines of binary code may be required, which is not practical for a
computer programmer.
So, a semantic gap is said to exist between the application domain (suitable for a programmer) and
execution domain (used by the computer).
This semantic gap is made manageable by introduction of a new domain called the Programming
Language (PL) Domain.
The software developer bridges the specification gap by specifying application programs in terms
of programming language i.e., a software developer converts the specification of an application
into a computer program.
The system programmer bridges the execution gap by designing system software to interface
with the machine, in machine language itself.
So, basically an application program is needed for a user to ‘talk’ to his computer and system
software is needed for the computer to ‘talk’ to its underlying machine (in its machine language
or assembly language).
Compile time
Source Compiler/ Object
Progra assembler Module
m Other Object
Modules
Link Editor
(Linker)
Executable
Load File
System
time Library
Loader
Dynamically
Loaded
System
Library
Running
Execution Progra Computer hardware + OS
time m
WE WILL DISCUSS
ON…
• Machine Architecture ( HYPOTHETICAL machine )
• Assemblers
• Macro Processor
• Loaders and Linkers
• Compilers
MACHINE ARCHITECTURE
•System Software & Machine Architecture
•Traditional (CISC) Machines
Complex Instruction Set Computers:
VAX Architecture , Pentium Pro Architecture
•RISC Machines
Reduced Instruction Set Computers : UltraSPARC
Architecture , Cray T3E Architecture
MACHINE
ARCHITECTURE
•Memory and Registers
•Data Formats
•Instruction Formats
•Addressing Modes
•Instruction Set
•Input and Output
ASSEMBLERS
• Translating source code written in assembly
language to object code.
• Assigning machine address to symbolic labels.
ASSEMBLER : AN ASSEMBLER IS A TRANSLATOR DENOTED AS FOLLOWS:
A TAA
IMAGINE AN 8086 ALP PROGRAM (THE ACTUAL ASSEMBLER) THAT READS AN
INPUT SOME OTHER 8086 ALP PROGRAM AND GENERATES ITS MACHINE CODE
FOR 8086 MACHINE.
CROSS-ASSEMBLER: A CROSS-ASSEMBLER IS A
TRANSLATOR DENOTED AS FOLLOWS:
A
TAB
A CROSS-ASSEMBLER RUNS ON ONE MACHINE, BUT
ASSEMBLES ALP OF ANOTHER MACHINE AND GENERATES
MACHINE CODE FOR THAT MACHINE
DISASSEMBLER
• It converts machine code of a particular
machine back to its assembly language.
(Recall: reverse engineering).
• This idea of reverse engineering is used to
recover some lost source code file using its
object file.
Assembler Design
• Assembler Design can be done in:
– Single pass
– Two pass
• Single Pass Assembler:
– Does everything in single pass
– Can resolve the forward referencing
TYPES OF ASSEMBLERS
Single-pass assembler
Multi-pass assembler
MACRO PROCESSOR
- Basic Macro Processor Functions
(Single line abbreviation that replaces its call by
definition.)
- Algorithms
- Nested macros
- Comparison of different macro design
- Machine-Independent macro features
- Implementation of conditional macros
PRE-PROCESSORS
• A Pre-processor converts one HLL / ALP into
another HLL/ALP .
• A Macro Processor is an example of pre-
processor
MACRO PROCESSOR
• A Macro is defined as a single-line abbreviation
of a small sequence of statements.
• A Macro Processor expands the macro calls and
removes macro definitions from an as input
source code, which contains these macro
definitions and calls.
MACROS
• A macro instruction (Macro) is a notational convenience for
the programmer
• Allows the programmer to write shorthand programs
(modular programming).
• The macro processor replaces each macro instruction with
its equivalent block of instructions.
• The macro processor is not concerned with the meaning of
the involved statements during expansion.
• The design of the macro processor is generally machine
independent.
One-Pass Macro Processor
•A one-pass macro processor that alternate
between macro definition and macro expansion in a
recursive way is able to handle recursive macro
definition
LOADERS AND
LINKERS
- Basic Loader Functions
- Loader Design Schemes
- Implementation Examples
Linker
A LINKER (OR A LINKAGE EDITOR) TAKES THE OBJECT FILE,
LOADS AND COMPILES THE EXTERNAL SUBROUTINES FROM
THE LIBRARY AND RESOLVES THEIR EXTERNAL
REFERENCES IN THE MAIN-PROGRAM.
Loader
PROGRAMMERS USUALLY DEFINE THE PROGRAM TO BE
PLACED AT SOME PREDEFINED LOCATION IN THE MEMORY.
BUT THIS LOADING ADDRESS GIVEN BY THE PROGRAMMER
MAY NEVER BE USED, AS IT HAS NOT BEEN COORDINATED
WITH THE OS.
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 USING LINKER) AND LOADS IT AT THAT ADDRESS.
ROLE OF
LOADER
Source Object Object
Program Assembler Loader program
ready for
Program execution
Memory
ROLE OF LOADER AND
LINKER Memory
Source Object
Program Assembler Linker
Program Object
program
ready for
Executable execution
Code
Loader
Linking Loaders Object The source
Program(s) program is first
assembled or
compiled,
producing an
object program.
Library Linking
loader A linking loader
performs all
linking and
loading
operations, and
Memory loads the program
into memory for
execution
Processing of an Object
program using LL
Linkage Editors Object
Program(s)
Linkage
Library editor
Linked
program
Relocating
loader
Processing of an Object
program using LE Memory
COMPILERS
▪ Introduction
▪ Basic Compiler Function
▪ Lexical Analysis,
▪ Syntactic Analysis
Operator-Precedence Parsing
Shift Reduce Parsing
Recursive Descent Parsing
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).
CROSS-COMPILER
A CROSS-COMPILER RUNS ON ONE MACHINE, BUT
GENERATES MACHINE OR ASSEMBLY CODE FOR
ANOTHER MACHINE .
DECOMPILER
• Similar to Disassembler for Assembly Language, a Decompiler
traces back the machine or assembly code and converts it into
source HLL program.
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
Compiler Interpreter
Prog Compiled - At a time Line by line
Execution - at a time Execution- line by line
Errors- notified to user at a Errors- notified to user line by
time line
errors- compilation continued, errors- not continued
execution also continued
C, C++ python
less time more time
Source Program
Phases of Lexical
Compilers analysis
Syntax analysis
Table Intermediate Error
Management Code generation Handling
Code
Optimization
Code Generation
Target Program
Phases of Compiler
1. Lexical
2. Syntax
3. Semantic
4. ICG
5. Code Optimization
6. Code Generation
DEVICE DRIVERS
• A Device Driver is a system software that allows the
OS and other applications to communicate with a
specific hardware device.
• Every different hardware device can understand only
its own low-level commands;
• A Device Driver translates high-level commands by OS
or other applications into machine code instructions
that are directly executable on the hardware device.
OPERATING SYSTEM
• An operating system can be viewed as an integration of
system programs that act as an interface between the
user and his computer.
An OS manages CPU and different hardware devices
connected to the computer; it also provides system
calls for efficient execution of common services needed
by the applications.
SYSTEM TOOLS
• System Tools are not complete systems software;
rather they assist in writing system or application
software and perform various actions on it.
1.Editors
2.Debuggers
3.IDE
4.Profilers
5.Project manager
SUMMARY
• System programs are needed because it is impractical for a
programmer to write, debug and manage huge programs in binary
0s and 1s.
• Translators convert code of one language to another.
• Assembler translates assembly language to machine code;
Disassembler performs the reverse function.
• Compiler translates HLL code into machine code; Decompiler uses
source HLL information in machine code to do reverse of
compilation process.
• Interpreters compile programs “line-by-line”. So, they are
traditionally slow. But a main advantage is that chain of errors can
be avoided.
• Pre-processors are not translators; input and output
languages are the same, only input source is modified to
eliminate elements like whitespaces and comments.
• Linker links object files of various subroutines with that of main
program and generates .exe file. Loader manages allocation
and relocation of this .exe file in main memory.
• Device Drivers convert high-level commands from OS (or
other applications) into machine code instructions for direct
execution on the device.
• Operating System is an integration of various system
programs that act as an interface between a user and his
computer.