ch01.ppt
TRANSCRIPT
3
What is system software?
• Designed to control the operations of computer.
• Tasks performed such as controlling storage devices, monitoring CPU, I/O devices and also provide basic operations for Application Soft wares to operate.
• System programs were developed to make computers better adapted to the needs of their users.
4
Categories of System Software
• System Control Programs• System Support Programs• System Development Programs
5
System Control Programs
• Controls execution of programs• Manage storage devices• Manage processing resources• Eg:-Operating System, DBMS
6
System Support Programs
• Routine services are provided to the computer programs and users
• Eg:- libraries, task manager….
7
System Development Programs
• Helps in creation of application programs• Eg:- compilers, Interpreters,debugging aids
10
Language processors
• To understand this we need to define application domain and execution domain..
• Application domain:-When the designer expresses the ideas in his terms
• Execution domain:-Implementation of the ideas and their interpretation.
11
• Differences do arise in performing/implementing the ideas , when these differences arise the activities we perform are known as Language Processing Activities.
• This difference is known as Semantic gap.
12
Consequences of Semantic Gap
• Large development times• Large development efforts• Poor quality of software
Solution was Programming Languages
•Specification,design and coding steps
•PL Implementation steps
HENCE ONE NEW DOMAIN INTRODUCED::::PL DOMAIN
13
Semantic Gap divided into two i.e• Specification and Design Gap• Execution gap
• Specification Gap:- It is the semantic gap between two specifications of the same task.
• Execution Gap:- It is the gap between semantics of programs (that perform the same task) written in different programming languages.
14
A LANGUAGE PROCESSOR is a software which bridges a
specification or execution gap.&
LANGUAGE PROCESSING is the activity performed by a language processor.
16
Types of Language Processors
• Language Translator• Detranslator• Preprocessor• Language Migrator• Interpreter
17
Problem-oriented languages&
Procedure-oriented languages
• Problem-oriented languages are one which have large execution gap i.e PL domain is very close to application domain.
• Procedure oriented languages are which provide general purpose facilities required in most application domains. It results in large specification gap.
18
Types of Language Processing Activities
• Program Generation Activities
• Program Execution Activities
19
Program Generation
It is a software system which accepts the specification of a program to be generated, and generates a program in the target PL.It introduces a new domain i.e program generator domain.
Program specification Program
generatorProgram in target PL
Errors
20
Program Execution
Two models are proposed i.e translation and interpretation.
Program Translation :- Bridges the execution gap by translating a program written in PL i.e. source program into a machine or assembly language program of a computer system i.e. target program.
21
Characteristics of program translation:• A program must be translated before it
can be executed.• The translated program may be saved
in a file.• A program must be retranslated
following modifications.
Source programTranslator
Errors
m/c language program
Data
Target program
22
Program Interpretation
Reads the source program, stores in its memory. Determines the meaning and performs actions
reading the source statement. Instruction execution cycle:
Fetch the instructionDecode the instructionExecute the instruction
23
Interpretation cycle
•Fetch the statement
•Analyze the statement and determine its meaning, viz. the computation to be performed and its operands.
•Execute the meaning of the statement.
24
PC
Interpreter
Errors
Memory
Source program+
Data
(a)
PC
CPUMemory
Machine language programData
(b)
25
Characteristics of Interpretation
• Source program is retained in the source form itself, i.e no target program exists,
• A statement is analyzed during its interpretation.
27
A specification of the source language forms the basis of source program analysis Specification consists of three
components:. Lexical rules. Syntax rules. Semantic rules
28
Synthesis Phase
• It constructs target language statements which have the same meaning as a source statement. It consists of:-
• Creation of data structures in the target program (memory allocation)
• Generation of target code (code generation)
29
Phases and passes of a language processor
Language processor
Analysis
phase
Synthesis
phase
Target program
Source program
Errors Errors
30
Analysis of a source statement can be immediately followed by synthesis of equivalent target statements. But two things might interrupt it.
Forward ReferencesIssues concerning memory
requirements and organization of a language processor.
31
Forward references
• A forward reference of a program entity is a reference to the entity which precedes its definition in the program.
32
Language processor pass
• It is the processing of every statement in a source program, or its equivalent representation, to perform a language processing function.
• Pass I: Perform analysis of the source program and note relevant information.
• Pass II: Perform synthesis of target program
33
Intermediate Representation
• It is a representation of a source program which reflects the effect of some, but not all, analysis and synthesis tasks are performed during language processing.
34
• First pass is also known as front end and second pass is also known as back end.
Intermediate representation (IR)
Front end Back endSource program
Target
program
36
• The front end analyses the source program and constructs an IR. All actions performed by the front end, except lexical and syntax analysis, are called semantic actions.
37
Semantic actions are:
• Checking semantic validity of constructs in SP
• Determining the meaning of SP• Constructing an IR.
38
Output of front end
IR consists of:• Tables of information• Intermediate code(IC) which is a
description of the source program.
39
Tables
• It contain the information obtained during different analyses of SP.Most important table is the symbol table which contains information concerning all identifiers. It is built during lexical analysis. Semantic analysis adds information concerning symbol attributes while processing declaration statements.
40
Intermediate Code
• It is a sequence of IC units, each IC unit representing the meaning of one action in SP. IC units may contain references to the information in various tables.
43
Intermediate code
1. Convert(Id,#1) to real, giving (Id,#4)2. Add(Id,#4) to (Id,#3), giving (Id,#5)3. Store (Id,#5) in (Id,#2)
44
Lexical analysis(Scanning)
• It identifies the lexical units in a source statement.Then classifies into different lexical classes.e.g. id’s,constants, reserved id’s, etc. and enters them into different tables.
• It builds a descriptor, called a token, for each lexical unit.A token contains two fields—class code and number in class.
45
Syntax analysis(Parsing)
• It processes the string of tokens built by lexical analysis to determine the statement class.e.g assignment statement, etc.
• Then IC is build and passed to semantic analysis.
46
Semantic analysis(Scanning)
• Declaration statements: results in addition of information to the symbol table i.e type, length and dimensionality of variables.
• Imperative statements: identifies the sequence of actions necessary to implement the meaning of a source statement.
47
Semantic analysis of a:=b+i
• Information concerning the type of the operands is added to the operand tree.
• Rules of meaning an assignment statement indicate that the expression on the right hand side should be evaluated first. Hence focus shifts to the right subtree rooted at ‘+’.
• Rules of addition indicate that type conversion of i should be performed to ensure type compatibility of the operands of’+’. This leads to the action…
48
• Convert i to real, giving i*. which is added to the sequence of
actions. The IC tree under consideration is modified to represent the effect of this action. The symbol i* is now added to the symbol table.
:= :=
a,real +
b, real i,real
a,real +
b, real i*,real
49
• Rules of addition indicate that the addition is now feasible. This leads to the action ---Add i* to b, giving temp.The IC tree is transformed and temp is added to the symbol table.
:=
o The assignment can be performed now.This leads to the action---Store temp in a.
a, real temp, real
50
Scanning
Parsing
Semantic analysis
Source program
Tokens
Trees
Symbol table
Constants table
Other tables
Lexical errors
Syntax errors
Semantic errors
IC
IRFront end of the compiler
52
Memory allocation
• It is done by simple presence of symbol table.
• 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.
53
Code generation
• It uses knowledge of the target architecture, i.e. knowledge of instructions and addressing modes in the target computer, to select the appropriate instructions. The important issues in code generation are:
• Determine the places where the intermediate results should be kept, i.e. whether they should be kept in memory locations or held in machine registers.This is preparatory step for code generation.