0% found this document useful (0 votes)
4 views

Introduction System Software new (1) (1)

Uploaded by

mdsaif804403
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Introduction System Software new (1) (1)

Uploaded by

mdsaif804403
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

System Software

CS301
What is System Software?

• System software refers to the low-level software that manages and


controls a computer’s hardware and provides basic services to higher-
level software. There are two main types of software: systems
software and application software. Systems software includes the
programs that are dedicated to managing the computer itself, such as
the operating system, file management utilities, and disk operating
system (or DOS).
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.
What is Utility Software?

• Utility Software is a type of software which is used to analyse and


maintain a computer.
• Software is focused on how OS works on that basis it performs tasks
to enable the smooth functioning of the computer.
• Software may come with OS like windows defender and disk cleanup
tools. Antivirus, backup software, file manager, and disk compression
tool all are utility software.
Systems Programming
• Development of computer software that is part of a computer
operating system or other control program, especially as used in
computer networks.
• Systems programming covers data and program management,
including operating systems, control programs, network software, and
database management systems.
Need for New Software Development
Technology/Trend
• New software development technology is necessary because it helps us
make better and faster computer programs.
• Nowadays, programs need to be quicker and more secure.
• This new technology makes sure our data is safe and helps people work
together on projects by providing different collaboration tools and
frameworks.
• New technology helps developers work faster and smarter, making
software quicker to create and improving how much work they can do.
• Example: Artificial Intelligence (AI) & Machine Learning (ML) -
AI and ML are emerging tools that make computers function like
human brains.
What is Language Processors?

• A language processor, or language translator, is a computer program


that convert source code from one programming language to another
language or to machine code (also known as object code). They also
find errors during translation.
• Compilers, interpreters, translate programs written in high-level
languages into machine code that a computer understands
and assemblers translate programs written in low-level or assembly
language into machine code. In the compilation process, there are
several stages. To help programmers write error-free code, tools are
available.
Semantic Gap
Semantic Gap

Application Execution
Domain Domain

• Semantic Gap has many consequences


1. Large development time
2. Large development effort
3. Poor quality of software
Specification and Execution Gaps
Specification Gap Execution Gap

Application PL Execution
Domain Domain Domain

• The software engineering steps aimed at the use of a PL


can be grouped into
1. Specification, design and coding steps
2. PL implementation steps
Specification and Execution Gaps
• Specification Gap - It is the semantic gap between two specifications
of the same task.
• Execution Gap - It is the gap between the semantics of programs (that
perform the same task) written in different programming languages.
Language Processors?

• “A language processor is a software which bridges a specification or


execution gap”.
• The program form input to a language processor as the source program
and to its output as the target program.
• The languages in which these programs are written are called source
language and target language, respectively.
Language Processors - Examples
Errors

C++ Program
C++ C Program
preprocessor

Errors

C++ Program
C++ Machine Language
translator Program
Interpreters
 An interpreter is a language processor which bridges an execution gap
without generating a machine language program.
 An interpreter is a language translator according to classification.

Interpreter Domain

Application PL Execution
Domain Domain Domain
Language Processing Activities
• Program Generation Activities
• Program Execution Activities
Program Generation
Errors

Program Program Generator Program in


Specification target PL

Specification Gap

Application Program Target PL Execution


Domain Generator Domain Domain
Domain
Program Execution
Two popular models for program execution are
translation and interpretation.
Program translation
Errors Data

m/c
Source Translator language Target
Program
Program program
• A program must be translated before it can be executed.
• The translated program may be saved in a file. The saved program
may be executed repeatedly.
• A program must be retranslated following modifications.
Program Execution
Program interpretation
Interpreter Memory CPU Memory

PC PC Machine
Source
Language
Program
Program
+
Errors +
Data
Data

Interpretation Program execution


Fundamentals of Language Processing
• Language Processing = Analysis of SP + Synthesis of TP
• Collection of LP components engaged in analysis a source program as
the analysis phase and components engaged in synthesizing a target
program constitute the synthesis phase.
Analysis Phase
• The specification consists of three components:
• Lexical rules which govern the formation of valid lexical units in the source language.
• Syntax rules which govern the formation of valid statements in the source language.
• Semantic rules which associate meaning with valid statements of the language.

• Consider the following example:


percent_profit = (profit * 100) / cost_price;
• Lexical units identifies =, * and / operators, 100 as constant, and the remaining strings as
identifiers.
• Syntax analysis identifies the statement as an assignment statement with percent_profit as the left
hand side and (profit * 100) / cost_price as the expression on the right hand side.
• Semantic analysis determines the meaning of the statement to be the assignment of profit X 100 /
cost_price to percent_profit.
Synthesis Phase
• The synthesis phase is concerned with the construction of target language
statements which have the same meaning as a source statement.
• It performs two main activities:
• Creation of data structures in the target program (memory allocation)
• Generation of target code (code generation)
• Example
MOVER AREG, PROFIT
MULT AREG, 100
DIV AREG, COST_PRICE MOVEM

Phases and Passes of LP
Language Processor

Source
Analysis Synthesis Target
Program Phase Phase Program

Errors Errors

• Analysis of source statements can not be immediately followed by


synthesis of equivalent target statements due to following reasons:
• 🞑 Forward References
• 🞑 Issues concerning memory requirements and organization of a LP
Lexical Analysis (Scanning)
• It identifies the lexical units in a source statements. It then classifies
the units into different lexical classes, e.g. id‟s, constants, reserved
id‟s, etc. and enters them into different tables.
• It builds a descriptor, called token, for each lexical unit. A token
contains two fields – class code and number in class.
• class code identifies the class to which a lexical unit belongs. number
in class is the entry number of the lexical unit in the relevant table.
• We depict a token as Code # no, e.g. Id # 10
Lexical Analysis (Scanning) - Example
Symbol Type Length Address

i : integer; 1 i int
2 a real
a, b : real; 3 b real
a := b + i; 4 i* real
5 temp real

Note that int i first needed to be converted into real, that is why 4th entry is
added into the table.
Addition of entry 3 and 4, gives entry 5 (temp), which is value b + (i *).

The statement a := b+i; is represented as the string of tokens

Id#2 Op#5 Id#3 Op#3 Id#1 Op#10


Syntax Analysis (Parsing)
• It processes the string of tokens built by lexical analysis to determine the
statement class, e.g. assignment statement, if statement etc.
• It then builds an IC which represents the structure of a statement. The IC is passed
to semantic analysis to determine the meaning of the statement.

real
:=

a b a +

a, b : real b i

a := b + i
Semantic Analysis
• It identifies the sequence of actions necessary to implement the meaning of a
source statement.
• It determines the meaning of a sub tree in the IC, it adds information to a table
or adds an action to the sequence of actions. The analysis ends when the tree
has been completely processed.
:= := :=

a, real + a, real + a, real temp, real

b, real i, int b, real i*, real


Analysis Phase (Front end)
Source Program

Lexical
Errors Scanning
Tokens
Symbol Table
Syntax Parsing Constants Table
Errors
Trees Other tables
Semantic Semantic
Errors
Analysis

IC

IR
Synthesis Phase (Back end)
It performs memory allocation and code generation.

Memory Allocation
• The memory requirement of an identifier is computed from its type,
length and dimensionality and memory is allocated to it.
• The address of the memory area is entered in the symbol table.
Symbol Type Length Address
1 i int 2000
2 a real 2001
3 b Real 2002
Synthesis Phase (Back end)
• Code Generation
• It uses knowledge of the target architecture, viz. knowledge of
instructions and addressing modes in the target computer, to select
the appropriate instructions.
• The synthesis phase may decide to hold the values of i* and temp in
machine registers and may generate the assembly code.
• a := b + i;
CONV_R AREG, I
ADD_R AREG, B
MOVEM AREG, A
Synthesis Phase (Back end)
IR

IC Memory
Allocation
Symbol Table
Constants Table
Other tables
Code
Generation

Target
Program
Fundamentals of Language Specification
• PL Grammars
• The lexical and syntactic features of a programming language are
specified by its grammar.
• A language L can be considered to be a collection of valid sentences.
• Each sentence can be looked upon as a sequence of words, and each
word as a sequence of letters or graphic symbols acceptable in L.
• A language specified in this manner is known as a formal language.
Example
1. Lexical Analysis

Purpose: The lexical analyzer (or lexer) scans the source code and breaks it down into tokens.
Tokens are the basic building blocks of the language, such as keywords, identifiers, operators, and literals.

Input: a := b + c * 5

Output (Tokens):
•a (identifier)
•:= (assignment operator)
•b (identifier)
•+ (addition operator)
•c (identifier)
•* (multiplication operator)
•5 (literal integer)
2. Syntax Analysis

Purpose: The syntax analyzer (or parser) takes the tokens produced by the lexer and
arranges them into a syntactic structure according to the grammar of the language.
This phase generates a parse tree or abstract syntax tree (AST).

Input (Tokens):
•a :=
•:=
•b id1
•+ +
•c
•* id2 *
•5

Output (AST): id3 5


3. Semantic Analysis
Purpose: The semantic analyzer checks for semantic errors and ensures that the syntax tree follows the
rules of the language. It also performs type checking and collects information for later stages.
Input (AST):

• Output (Annotated AST):


• Check that a, b, and c are declared variables.
• Ensure the expression rate * 5 is valid.
• Ensure initial and rate are compatible with the operations being performed.
:=

id1
+

id2 *

id3 5
4. Intermediate Code Generation

Purpose: The intermediate code generator translates the AST into an intermediate representation (IR),
which is more abstract than machine code but closer to the hardware level.

Input (Annotated AST):

Output (Intermediate Code):

t1 = c * 5
t2 = b + t1
a = t2

Here, t1 and t2 are temporary variables used to hold intermediate results.


5. Code Optimization

Purpose: The optimizer improves the intermediate code to make it more efficient without changing its output.
This can involve eliminating redundant calculations, simplifying expressions, or reordering instructions.

Input (Intermediate Code):

t1 = c * 5
t2 = b + t1
a = t2

Output (Optimized Intermediate Code):

t1 = c * 5
a = b + t1

•The given example is quite simple, so optimization might not change much,
but in a more complex scenario, it could remove redundant computations or simplify operations.
7. Code generator

Purpose: The final phase in compiler model is the code generator. It takes as input an intermediate representation of
the source program and produces as output an equivalent target program (assembly, relocatable, absolute).

Input :
t1 = c * 5
a = b + t1
Output:
MOVF c. R2
MULF 5, R2
MOVF b, R1
ADDF R2, R1
MOVF R1, a
Phases of compiler
• Lexical Analysis: Tokenizing the source code.
• Syntax Analysis: Creating a parse tree or AST.
• Semantic Analysis: Checking types and ensuring correctness.
• Intermediate Code Generation: Producing an intermediate
representation.
• Code Optimization: Improving intermediate code efficiency.
• Code Generation: Producing machine or assembly code.

You might also like