System Programming and Compiler
Construction
CSC 602
Subject Incharge
Varsha Shrivastava
Assistant Professor
email: varshashrivastava@sfit.ac.in
Room No: 407
1
CSC 602 System Programming and
Compiler Construction
Module 1
Introduction of System Software
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 2
Course Outcomes
CO1: Identify the relevance of different system programs and also
distinguish different loaders and linkers, their contribution in
developing efficient user applications.
CO2: Analyze the various data structures and passes of assembler
design
CO3: Identify the need for different features and designing of macros.
CO4: Design Lexical Analyzer of a grammar.
CO5: Construct different parsers for given context free grammars.
CO6: Justify the need synthesis phase to produce object code
optimized in terms of high execution speed and less memory usage
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 3
Text books to refer-
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 4
Term work Distribution
• Lab work (experiments): 15 Marks
• Assignment: 05 Marks
• Attendance : 05 Marks
TOTAL 25 Marks
Final University Marks Distribution
• University final exam 80 Marks
• Internal Assessment 20 Marks
• Term work 25 Marks
• Practical exam 25 Marks
TOTAL 150 Marks
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 5
Contents as per syllabus
Introduction
Concept of System Software
Goals of System Software
System Program And System Programming
Introduction to various system programs such as
Assembler, Macro processor, Loader, Linker,
Compiler, Interpreter, Device Drivers, Operating
system, Editors, Debuggers.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 6
Introduction to Language Processor
• A language processor is a software which bridges a
specification and execution gap.
• Language processing activities arise due to:
• The difference between software designer’s idea
related to behavior of software and the manner in
which these ideas are implemented.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 7
Introduction to Language Processor
• The designer expresses the ideas in terms related to
the application domain.
• To implement these ideas in terms related to execution
domain.
• The difference between the two domain termed as
semantic gap.
Semantic Gap
Application Execution
Domain Domain
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 8
Introduction to Language Processor
• The semantic gap has many difficulties, some of the
important ones being large development time and
efforts, and poor quality of software.
• These issues are tackled through the use of
programming language (PL).
• Software implementation using PL introduces a new
domain as PL domain.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 9
Introduction to Language Processor
• Now the semantic gap is bridged by the software
engineering steps.
• The first step bridges gap between application domain
and PL domain known as specification gap.
• While the second step bridges the gap between PL
domain and execution domain as execution gap.
Specification Gap Execution Gap
Application PL Execution
Domain Domain Domain
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 10
Introduction to Language Processor
• The specification gap is bridge by the software
development team.
• While the execution gap is bridged by the designer of
the programming language processor. Like compiler or
interpreter.
• PL domain reduces the difficulties of semantic gap
mentioned earlier.
• The language processor also provides a diagnostics
capability which detects and indicates errors in its
input. This helps in improving the quality of the
software.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 11
Introduction to Language Processor
A range of LP is defined to meet practical requirements.
1. A language translator bridges an execution gap to the
machine language like assembler and compiler.
2. A detranslator bridges the same as the language
translator, but in the reverse manner.
3. A preprocessor is a language processor which
bridges an execution gap but not translator.
4. A language migrator bridges specification gap
between two PLs.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 12
Language Processing Activities
The Language Processing activities can be divided into
those that bridge the specification gap and those that
bridge the execution gap.
There are two types of such activities :
1. Program Generation Activities
2. Program Execution Activities
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 13
Language Processing Activities
1. Program Generation Activities
Generates the target program in machine language by
accepting the specification of the source program
Program Program Program in Target
Specification Generator Language
Errors
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 14
Language Processing Activities
2. Program Execution Activities
Program execution is divided into 2 parts:
(a) Program Translation
(b) Program Interpretation
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 15
Language Processing Activities
2. Program Execution Activities
(a) Program Translation
DATA
M/C
Source Translator language Target
Program Program Program
Errors
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 16
Language Processing Activities
2. Program Execution Activities
(a) Program Translation :
This activity is used to convert source program into machine
code.
Features of the program translation:-
• Translation of program should be done before it is
executed.
• Translation of program should be saved for repetitive
execution.
• Retranslation of the program should be done if there are
any changes
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 17
Language Processing Activities
2. Program Execution Activities
(b) Program Interpretation :
Interpretation of program consists of following steps:
• The code is fetched.
• Analyze the code.
• Execute the meaning of the code.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 18
Introduction
What is System Program?
A program which directly interacts with the
hardware.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 19
Introduction to System Software
• Software - the programs and other operating
information used by a computer.
• 2 types :
• Application Software
• System Software
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 20
Software's
Software
Application Software System Software
Word OS
Processors
Compilers
Databases
Assemblers
Games
Utilities
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 21
Application Software
• Application software is a set of one or more
programs designed to carry out operations for a
specific application.
• Application software cannot run on itself but is
dependent on system software to execute.
• Example : games, word processors, image
processors, etc.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 22
System Software
• System software is computer software designed to
operate and control the computer hardware.
• It is used to provide a platform for running
application software.
• Example : compilers, assemblers, utilities, etc.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 23
System Software
System Software
Program Develop Environment Run Time Environment
Text Editor Loader
Compiler
Libraries
Assembler
Dynamic Linker
Static Linker
Low level Debugger Operating System
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 24
System Software vs Application Software
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 25
System Programs
• Operating Systems
• Device Drivers
• Compilers
• Preprocessor
• Interpreters
• Macro Processors
• Assemblers
• Linkers
• Loaders
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 26
Operating System
• An operating system (OS) is software that manages
computer hardware and software resources and
provides common services for computer programs.
• The operating system is an essential component of
the system software in a computer system.
• Application programs usually require an operating
system to function.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 27
Device Drivers
• A device driver is a program that controls a particular
type of device that is attached to your computer.
• There are device drivers for printers, displays, CD-
ROM readers, diskette drives, and so on.
• When you buy an operating system, many device
drivers are built into the product.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 28
OS and Device drivers
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 29
Compilers
• Preprocessors
• A tool that produces input for compilers.
• Deals with macro-processing, augmentation, file inclusion,
language extension, etc.
• Interpreters
• Similar to compilers (translates high-level language into low-
level machine language)
• An interpreter reads a statement from the input, converts it
to an intermediate code, executes it, then takes the next
statement in sequence.
• If an error occurs, an interpreter stops execution and reports
it.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 30
Compilers
• Compiler is a program (or set of programs) that
translates a source code (high level language) into
machine understandable code (low level language).
Source Target
Program
COMPILER Program
Error messages
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 31
Compilers
• A compiler reads the whole source code at once,
creates tokens, checks semantics, generates
intermediate code and executes the whole program
• May involve many passes.
• A compiler reads the whole program even if it
encounters several errors.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 32
Interpreter vs Compiler
Interpreter Compiler
Translates program one statement at a Scans the entire program and translates it as
time. a whole into machine code.
It takes less amount of time to analyze It takes large amount of time to analyze the
the source code but the overall execution source code but the overall execution time is
time is slower. comparatively faster.
Generates intermediate object code which
No intermediate object code is
further requires linking, hence requires more
generated, hence are memory efficient.
memory.
Continues translating the program until It generates the error message only after
the first error is met, in which case it scanning the whole program. Hence
stops. Hence debugging is easy. debugging is comparatively hard.
Programming language like Python, Ruby Programming language like C, C++ use
use interpreters. compilers.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 33
Macro Processors
• A macro instruction is a notational convenience for
the programmer.
• It allows the programmer to write shorthand
version of a program (module programming).
• The macro processor replaces each macro
invocation with the corresponding sequence of
statements (expanding).
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 34
Macro Processors
• A macro processor can –
• Recognize macro definitions
• Save the macro definition
• Recognize macro calls
• Expand macro calls
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 35
Assemblers
• An assembler translates assembly language
programs into machine code.
• The output of an assembler is called an object file.
• The object file contains the data required to place these
instructions in memory and information to enable
loader to prepare program for execution.
Source Assembly Object
Program
COMPILER code
ASSEMBLER Code
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 36
Linkers
• Linker is a computer program that links and merges
various object files together in order to make an
executable file.
• The major task of a linker is to search and locate
referenced modules in a program and to determine
the memory location where these codes will be
loaded, making the program instruction to have
absolute references.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 37
Linkers
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 38
Loaders
• Loader is a part of operating system and is
responsible for loading executable files into
memory and execute them.
• It calculates the size of a program (instructions and
data) and creates memory space for it.
• It initializes various registers to initiate execution.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 39
Stages
Source Assembly
Program
COMPILER code
ASSEMBLER
Executabl Object
e Code
LINKER Code
Object
Program
LOADER ready for
execution
Memory
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 40
Compilation steps
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 41
University Questions
What is System Programming? List some system
programs and write their functions.
Difference between Application and system
Software.
Differentiate between application program and
system program . Indicate the order in which
following system programs are used, from
developing programs up to its execution.
Assembler, loader,linker,macroprocessor,compiler,
editor
What is Language Processing? Explain Application,
PL & Execution domain.
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 42
THE END!
Have a nice day!
St. Francis Institute of Technology 20 July 2020 CSC 602:System Programming & Compiler Construction
Department of Computer Engineering Ms. Varsha Shrivastava 43