SlideShare a Scribd company logo
1 of 85
Download to read offline
Introduction
Prerequisite and Course Outline
1. Operating System
a) Definition of OS
b) Services and Functions of OS
c) Process Management , Process Synchronization
d) Memory management :- Paging and Segmentation
e) Disk Management
2. Data Structure
a) How to define data structure?
b) Classification of data structure
c) Searching in DS
d) Sorting in DS
How the C programs are executed in a system
Preprocessor removes comment and include header file in source
code , replace micro names with code.
Introduction to System Software
Introduction to System Software
Concept of System Software
● Definition of Software.
● There are two categories of software
○ Application Software
■ Develop using programming lang. And Tools
■ Application software interact with system software
■ Design to perform a group of coordinated functions , tasks, activities for benefits of users.
■ Eg. Word, Exel, browsers, Account management system.
○ System Software
■ System software provide platform to the application software.
■ Task such as editing, linking,translating, managing resource, I/O Devices and error handling.
■ It is a set of programs which are developed to operate, control & extend processing capabilities of computer itself.
■ Eg. Operating system, compiler, Assembler, Interpreter etc.
How does application software interact with OS?
• System Software is usually written using Low-level
language such as Assembly language. Some
essential functions of System software are:
– Disk Management
– Memory Management
– Device controlling
– Loading and execution of other programs.
Needs and Goals of system softwares
1. To run the hardware parts of computer and other
applications.
2. To provide platform to all the applications software’s.
3. Handles all the hardware , software and network together.
4. Converts all human instructions into machine
understandable formats.
5. Manage basic functions such as storing data, retrieving
files & scheduling task etc.
6. To make effective execution of each program.
7. To make effective utilization of human resources.
1. System calls and System program.
A system call creates an interface between the user process and the services offered by the operating
system. So, the user process can directly communicate with the operating system and request the service it
requires.
While developing an application program or the system program the developer needs to embed these system
calls in the code. This helps the program in utilizing the services of the operating system. Each operating
system has its own set of system calls that decides what operations the operating system is able to perform.
Example of System Call
Let us say there is a user program that copies the content of one file to another file.
sequence of system calls are
1. Prompt a message on the screen for the user to provide the name of the source and destination files.
2. Read the name of the source and destination file character by character from the keyboard.
3. Open a source file. Open (and if not available Create) the destination file.
4. Read from the source file and write to the destination file.
5. Close the source and destination file.
6. Prompt a message that displays the successful execution of the program.
7. Terminate the user program.
● System Program :- System programs are computer
programs that provide platform for application
programs to work.
● System Programming :- A System Programming
language is basically referred to a programming
language designed for writing system software , which
usually requires different development approaches
when compared with application software.
Language
Processor/LanguageTranslater
Semantic Gap has many difficulties :- Large development time and efforts
Poor quality of software
Language Processor
Programming language (PL’s Domain) is used to
solve this issues and bridge the gap between the
application domain and execution domain.
Need of Language Domain
● It helps in minimizing the errors caused by the
semantic gap.
● It helps in bridging the gap between the different
domain and find out if there are errors in the input
of any domain.
Language Processor
A language processor, or translator, is a computer program that translates source code from one
programming language to another. They also identify errors during translation.
Language Processor Activities
● Language processing activity bridges the ideas of software designers with actual execution on the computer system.
● The designer expresses the idea related to the application domain of the software.
● To implement these ideas, the description of the ideas has to be interpreted as related to the execution domain of the computer
system.
● Two categories:
● Program generation activity
● Program Execution activity
Program generation activity
● This activity generates a program from its specification program.
Program generation activity bridges the specification gap.
○ A program generator is a software system program that accepts the
specifications of the program to be generated and generates the program in
the target program in a target programming language.
○ This activity generates a program from its specification.
○ The program generator introduces a new domain between the application and
the programming language domain called the program generator domain.
○ It accepts the source program and generates a program in the target
language.
Program Execution activity
● This activity aims at bridging the execution gap by organizing the execution of a
program written in a programming language on a computer system. A program
may be executed through translation and interpretation.
○ This activity involves the actual execution of the program generated by the program
generator. The program execution activity bridges the implementation gap.
○ The program execution activity involves loading the program into the memory of the
computer system, interpreting the program instructions, and executing them on the
computer system.
○ During program execution, the computer system reads the program instructions from
memory and executes them one by one, performing the necessary computations and
producing the desired results.
○ The program execution activity involves various components of the computer system,
including the processor, memory, input/output devices, and other system resources
required to execute the program
Difference between Application and
system software
– What it is?
– Installation?
– Level of language?
– Use?
– Design requirements?
– Fixed for machine?
– Who uses it?
– Examples?
System Software Application Software
System software is a set of computer programs that is designed to
manage system resources.
Application Software is a type of software that is mainly developed
to perform a specific task as per the user's request.
It acts as an interface between the Application Software and
Computer hardware.
It acts as an interface between the end-user and System Software.
It is a general-purpose software. It is a specific-purpose software.
System software is usually installed on the computer system at the
time of OS installation.
Application Software is usually installed on the system as per the
requirement of the user.
This software runs independently and works as a platform for
working application software.
This software is not capable of running independently, which means
they need system software to work on.
These are usually written in low-level languages such as Assembly
language.
These are usually written in a high-level language such as C, C++,
Java, etc.
System software work on the background, hence user don't directly
interact with them.
Application software work on user-interface, hence user directly
interact with them.
A system software starts running as we turn on our computer system
and stops when the system is turned off.
Application software runs as per user request. It means when we
launch them, then only they start and stop when we close them.
The development of System software is complicated and takes more
time compared to application software, as they are built by
considering the hardware compatibility.
Development of Application software is comparatively easier and
takes less time than system software.
A computer system can't run without system software. A computer system can always run without application software.
However, for users, it is required to have some important
application software to work on.
The working of system software is automated and starts functioning
automatically after starting the computer system.
The working of application software is manual, which means the
user needs to start using it.
Examples of System Software are Operating systems, Compiler,
Assembler, Device drivers, etc.
Examples of Application Software are Web browsers, MS office,
Graphic design software, etc.
Introduction to various System
Programs
1. Assemblers :- Single, Two and Multipass Assembler
2. Loaders :- Four Functions
a. Allocation
b. Linking
c. Relocation(Changing certain instruction)
d. Loading
3. Linkers
4. Macro Processors
5. Compiler
6. Interpreters
7. Operating System
8. Device Drivers(abstraction layer between hardware and application or OS)
9. Editors
10. Debuggers
Eclipse IDE(Java)
Nodeclipse (Java Script)
Microsoft Visual studio debugger etc.
● What is system software & application software?
● List and explain various types of System programming components.
● What is a language processor?
● Write a note on the evolution of system software.
● Define Loader. What are the different functions of loaders?
● Arrange the following System Softwares according to their role in Program
Execution: Linker, Loader, Compiler, Macro-preprocessor, Assembler, Text Editor.
● Enlist the functions of loader.
● List and explain activities performed by Language processor.
Thank You
Module 2:- Assemblers
Assembler
Assembler is a program for converting instructions written in low-level assembly code into relocatable machine
code and generating along information for the loader.
The assembler performs a one-to-one mapping from mnemonic instructions to machine statement and data.
Mnemonic is a code usually 1 to 5 letters that represents an op-code followed by one or more numbers.
This is in contrast with high level language in which single statement generally results in many machine
instructions.
Assembly Language: Assembly language is a kind of low level programming language, which uses symbolic
codes mnemonics as instruction.
ADD,SUB,LTD and STA.
Some example of mnemonics are
Instruction Op code Assembly Mnemonic
00 STOP
01 ADD
02 SUB
03 MULT
04 MOVER
05 MOVEM
06 COMP
07 BC
08 DIV
09 READ
10 PRINT
Elements of Assembly Language
● Mnemonic operation codes
Instead of using numeric operation code (op code) , mnemonics are used.
Eliminates the need to memorize numeric operation codes.
Eg . ADD, SUB , MOVE etc.
● Symbolic operands
Symbolic names can be associated with data or instructions. Symbolic names can be
used as operands in assembly statements (need not know details of memory bindings).
Eg . ADD R1,R2,R3
● Data declarations
Data can be declared in a variety of notations, including the decimal notation (avoids
conversion of constants into their internal representation)
Eg. NUM1 03
or NUM 0011H
Assembly Language Statements
● Assembly language programs consist of three types of statements −
• Executable instructions or Imperative Statements
The executable instructions or simply instructions tell the processor what to do. Each instruction consists of
an operation code (opcode). Each executable instruction generates one machine language instruction.
Eg. ADD, SUB etc.
• Assembler directives
Statement this kind of neither represent the machine instruction to be included in the object program nor indicate the
allocation of storage for constant or program variable. They are use to indicate certain things regarding how assembly of
the input program is to be performed.
Eg. ABC START 1000
END
• Declaration Statements
These are non executable statements. They declare constants or storage areas or storage areas in a program.
Eg. X DS 2 DS – Declare storage. -🡪 indicate that a storage area namely X reserved for 2 word.
G DS 200 ---🡪 ?
Format of Assembly language Statement
● Assembly language statements are entered one statement per line. Each
statement follows the following format −
[label] ,mnemonic/opcode ,operand specification, [;comment]
● The fields in the square brackets are optional.
● A basic instruction has two parts, the first one is the name of the instruction (or the
mnemonic), which is to be executed. Eg. ADD , SUB, MOVE
● First operand is always register. Eg. R1, R2, R3
● Second operand is memory word using symbolic name.
● Eg. ADD R1 ONE/1
Literals and Symbol
Literals are the constant value enclosed in ‘ ‘ .
Example:-
MOVER AREG, =‘5’.
Symbols are the labels or variables.
Example:-
LOOP MOVER AREG,X
Symbol
Symbol
Literals and Symbol Data Structure
Literal Table
Symbol Table
INDEX NAME OF
LITERALS
ADDRESS
INDEX NAME OF
SYMBOLS
ADDRESS
Advanced Assembler Directives
ORIGIN(ORG)
• This can be used to indirectly assign values to symbols.
• When this statement is encountered during assembly of a program, the assembler reset its location counter to the
specified values.
• The ORG statement will thus affect the values of all labels defined until the next ORG.
Syntax :- ORIGIN <address spec>
Example :- ORIGIN 201 , ORIGIN LOOP+ 4 🡪(Expression)
Advanced Assembler Directives
LTORG
• LTORG allows placing literals into a pool at some other location in the object program.
• Directives LTORG creates a literal pool that contain all of the literal operands used since the previous LTORG or
the beginning of the program.
• The LTORG statement permit a programmer to specify where literals should be placed. By default, assembler
places the literals after the END statement.
EQU
• Most assemblers provide an assembler directive that allows the programmer to define symbols and assign the value
evaluate by the expression in the operand field.
Syntax
Symbol EQU Value/ symbol name
Example :- 1. A EQU 1 --🡪 1 value assign to A
2. X EQU Y 🡪 X is set to the address of Y.
3. X EQU LOOP 🡪 X is set to the address of LOOP.
Let’s take a look on how this program is working:
● START: This instruction starts the execution of
program from location 200 and label with START
provides name for the program.(JOHN is name
for program)
● MOVER: It moves the content of literal(=’3′) into
register operand R1.
● MOVEM: It moves the content of register into
memory operand(X).
● MOVER: It again moves the content of
literal(=’2′) into register operand R2 and its label
is specified as L1.
● LTORG: It assigns address to literals(current LC
value).
● DS(Data Storage): It assigns a data space of 1
to Symbol X.
● END: It finishes the program execution.
Basic function of Assembler:
● Translate mnemonics opcodes to machine language.
● Convert symbolic operands to their machine addresses.
● Build machine instructions in the proper format
● Convert data constants into machine representation.
● Error checking is provided.
● Changes can be quickly and easily incorporated with a reassembly.
● Variables are represented by symbolic names, not as memory locations.
● Assembly language statements are written one per line. A machine code
program thus consists of a sequence of assembly language statements,
where each statement contains a mnemonics.
Advantages:
● Reduced errors
● Faster translation times
● Changes could be made easier and faster.
● Addresses are symbolic, not absolute
● Easy to remember
Disadvantages:
● Assembler language are unique to specific types of computer
● Program is not portable to the computer.
● Many instructions are required to achieve small tasks
● Programmer required knowledge of the processor architecture and instruction set.
Translation phase of Assembler:
The six steps that should be followed by the designer
1. Specify the problem
2. Specify data structure
3. Define format of data structure
4. Specify algorithm
5. Look for modularity
6. Repeat 1 through 5 on modules
Two Pass Assembler
Data Structure of the Assembler
Pass 1 Purpose:- Define symbols and literals
● Determine length of machine instructions(MOTGET1)
● Keep track of Location Counter(LC)
● Remember values of symbols until pass 2(STSTO)
● Process some pseudo ops, e.g. EQU , DS(POTGET1)
● Remember literals(LITSTO)
Numericals
Example 1 :- For the following program Show
Symbol and Literal Table
JOHN START 200
MOVER R1,=‘3’
MOVEM R1,X
L1 MOVER R2,=‘4’
X DS 1
END
2.
START 1000
READ N
MOVER B, =’1’
MOVEM B, TERM
AGAIN MULT B, TERM
MOVER C, TERM
ADD C, =’2’
MOVEM C, TERM
COMP C, N
BC LE, AGAIN
MOVEM B RESULT
LTORG
PRINT RESULT
STOP
N DS 1
RESULT DS 3
TERM DS 1
END
START 1000
READ N 1000
MOVER B, =’1’ 1001
MOVEM B, TERM 1002
AGAIN MULT B, TERM 1003
MOVER C, TERM 1004
ADD C, =’2’ 1005
MOVEM C, TERM 1006
COMP C, N 1007
BC LE, AGAIN 1008
MOVEM B RESULT 1009
LTORG 1010,1011
PRINT RESULT 1012
STOP 1013
N DS 1 1014
RESULT DS 3 1015
200
201
202
205
206
207
208
209
210
211
212
213
214
START 1000
READ N
MOVER B, =’1’
MOVEM B, TERM
AGAIN MULT B, TERM
MOVER C, TERM
ADD C, =’2’
MOVEM C, TERM
COMP C, N
BC LE, AGAIN
MOVEM B RESULT
LTORG
PRINT RESULT
ADD C, =’6’
SUB C, X
STOP
N DS 1
RESULT DS 3
POOL TABLE
Phases Of Assembler
Analysis phase:
• Separate contents of the label, mnemonic opcode and operand fields of a statement.
• If a symbol is present in the label field, enter the pair (symbol, <LC>) in a new entry of
the symbol table.
• Check validity of the mnemonic opcode through a look-up in the Mnemonics table.
• Perform LC processing, i.e., update the address contained in the location counter by
considering the opcode and operands of the statement.
Synthesis phase:
• Read the machine opcode corresponding to the mnemonic from the Mnemonics table.
• Get an address of each memory operand from the Symbol table.
• Synthesize a machine instruction or the correct representation of a constant, as the case
may be.
Data Structure with analysis and synthesis phase
Intermediate code (IC)
● If a compiler translates the source language to its target machine language without
having the option for generating intermediate code, then for each new machine, a full
native compiler is required.
● Intermediate code eliminates the need of a new full compiler for every unique
machine by keeping the analysis portion same for all the compilers.
● The second part of compiler, synthesis, is changed according to the target machine.
● It becomes easier to apply the source code modifications to improve code
performance by applying code optimization techniques on the intermediate code.
Data Structures used for Intermediate Code
Mnemonic Opcode Table (MOT)
Op code Assembly
Mnemonic
Type
00 STOP IS
01 ADD IS
02 SUB IS
03 MULT IS
04 MOVER IS
05 MOVEM IS
06 COMP IS
07 BC IS
08 DIV IS
09 READ IS
10 PRINT IS
Assembler Directives (AD) (POT)
Op code Assembly
Directives
Type
01 START AD
02 END AD
03 EQU AD
04 ORIGIN AD
05 LTORG AD Declaration Statements(DL)
Op code Assembly
Directives
Type
01 DS DL
02 DC DL
Variant I of IC
Single digit number is the code used for a register. This is the first operand.
Memory operand is the second operand and represent in the following format.
(operand class , code)
Where , operand class 🡪 C (constant) , S(symbol) , L(Literal)
Example (C,300) , (S, 01) , (L, 01)
Index from
ST and LT
● (AD,O1) (C,200)
● (IS,04) (RG,01) , (L,0)
● (IS,05) (RG,01) (S,0)
● (S,01) (IS,04) (RG,02) (L,1)
● (AD,05)
● (S,00) (DL,06) (C,1)
● (AD,02)
For imperative statement(IS) , Assembler Directives (AD) , Declaration
Statements(DL)
Variant II for IC
• In variant II, operands are processed selectively.
• Constants and literals are processed. Symbols, condition codes and CPU
registers are not processed.
Example
Assembly program
START 200
MOVER AREG, = ‘5’
MOVEM AREG , X
L1 MOVER BREG, = ‘3’
LTORG
X DS 1
END
Gernerate the Intermediate code
for given program.
START 1000
READ N
MOVER B, =’1’
MOVEM B, TERM
AGAIN MULT B, TERM
MOVER C, TERM
ADD C, =’2’
MOVEM C, TERM
COMP C, N
BC LE, AGAIN
MOVEM B RESULT
LTORG
PRINT RESULT
ADD C, =’6’
SUB C, X
STOP
N DS 1
RESULT DS 3
PASS 1 OF TWO PASS
ASSEMBLER
(FLOW CHART)
USING
DROP
Pass 2 Purpose :- Object Code is Generated
After the symbol table is completed in PASS 1 it does the actual assembly by
translating the operations and so on. The purpose of PASS 2 is to generate
object code.
1. Look up value of symbols(STGET)
2. Generate instructions(MOTGET2)
3. Generate data(for DC,DS and literals)
4. Process pseudo ops(POTGET2)
5. Base table :- Indicate which registers are specified as base registers by USING
pseudo-op codes and what the specified contents of these registers are.
Generate Target Code
OP-CODE REG. MEMORY
For Imperative Statement (IS)
REG 🡪 Opcode for register
Memory 🡪 Address of
symbol or literal
Target Code
LC OPCODE REG MEMORY
--- ---- ---
200 9 --- 209
201 9 --- 210
202 4 1 212
203 1 1 210
204 4 2 209
205 2 2 209
206 5 2 211
207 10 -- 211
208 00 -- --
209 -- -- --
210 -- -- --
211 -- -- --
-- -- --
Example:- Generate target code
Example.
PASS 2
–Flowcha
rt
Forward Reference Problem
• The assembler specifies the symbols should be declared anywhere in the program. There
may be chances of using a symbol before its declaration which gives rise to a forward
reference problem.
• The solution for forward references problem is having an assembler of two pass. The
assembler cannot know the address of the forward reference label until it reads the
definition of the label.
• In forward referencing, variable or label is referenced before it is declared. Different
problems can be solved using One Pass or Two Pass forward referencing.
Single Pass Assembler
● A single pass assembler scan the input file only once. During that single pass
the assembler handles both table definitions and assembly.
● It is generally faster than a two pass assembler.
● Single pass assembler construct symbol table, literal table and pseudo-op
table.
● The main problem encountered in one pass is that of a forward reference.
● The problem of forward reference is handled by single pass assembler is
back patching.
● Back patching is a process in which the operand field of an instruction
containing a forward reference is left blank initially.
● The address of the forward reference symbol is put into this field when its
definition is encountered in the program.
● In order to perform back patching , single pass assembler requires an
additional data structure called Table of incomplete instruction(TII).
Single Pass Assembler
No Intermediate code generate
Target code
LC OPCODE REG MEM
Forward Reference in One-Pass Assembler
1. Omit the operand address if the symbol has not yet been defined.
2. Enter this undefined symbol into SYMTAB and indicate that it is undefined.
3. Adds the address of this operand address to list of forward reference associated with the SYMTAB entry.
4. When the definition for the symbol is encountered, scans the reference list and insert the address.
5. At the end of the program , reports the error if there are still SYMTAB entries indicated undefined
symbols.
Thank You

More Related Content

What's hot

OSI and TCP/IP Model
OSI and TCP/IP ModelOSI and TCP/IP Model
OSI and TCP/IP ModelMaksudujjaman
 
Presentation on 8086 microprocessor
Presentation on 8086 microprocessorPresentation on 8086 microprocessor
Presentation on 8086 microprocessorDiponkor Bala
 
CCNAv5 - S1: Chapter 7 - Transport Layer
CCNAv5 - S1: Chapter 7 - Transport LayerCCNAv5 - S1: Chapter 7 - Transport Layer
CCNAv5 - S1: Chapter 7 - Transport LayerVuz Dở Hơi
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using javaUC San Diego
 
Chapter 4 - Digital Transmission
Chapter 4 - Digital TransmissionChapter 4 - Digital Transmission
Chapter 4 - Digital TransmissionWayne Jones Jnr
 
Research Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingResearch Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingShitalkumar Sukhdeve
 
Application Layer and Protocols
Application Layer and ProtocolsApplication Layer and Protocols
Application Layer and ProtocolsRubal Sagwal
 
Arp (address resolution protocol)
Arp (address resolution protocol)Arp (address resolution protocol)
Arp (address resolution protocol)tigerbt
 
Switching
Switching Switching
Switching Abid Ali
 

What's hot (20)

OSI and TCP/IP Model
OSI and TCP/IP ModelOSI and TCP/IP Model
OSI and TCP/IP Model
 
Presentation on 8086 microprocessor
Presentation on 8086 microprocessorPresentation on 8086 microprocessor
Presentation on 8086 microprocessor
 
Chapter 8: Switching
Chapter 8: SwitchingChapter 8: Switching
Chapter 8: Switching
 
CCNAv5 - S1: Chapter 7 - Transport Layer
CCNAv5 - S1: Chapter 7 - Transport LayerCCNAv5 - S1: Chapter 7 - Transport Layer
CCNAv5 - S1: Chapter 7 - Transport Layer
 
Delay , Loss & Throughput
Delay , Loss & ThroughputDelay , Loss & Throughput
Delay , Loss & Throughput
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Connecting devices
Connecting devicesConnecting devices
Connecting devices
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
 
Chapter 4 - Digital Transmission
Chapter 4 - Digital TransmissionChapter 4 - Digital Transmission
Chapter 4 - Digital Transmission
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
 
Switch
SwitchSwitch
Switch
 
Ftp
FtpFtp
Ftp
 
Research Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingResearch Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel Programming
 
Chapter 3: Data & Signals
Chapter 3: Data & SignalsChapter 3: Data & Signals
Chapter 3: Data & Signals
 
Application Layer and Protocols
Application Layer and ProtocolsApplication Layer and Protocols
Application Layer and Protocols
 
Arp (address resolution protocol)
Arp (address resolution protocol)Arp (address resolution protocol)
Arp (address resolution protocol)
 
Switching
Switching Switching
Switching
 
Application Layer
Application LayerApplication Layer
Application Layer
 
Data Link Layer
Data Link LayerData Link Layer
Data Link Layer
 
Chapter 7
Chapter 7Chapter 7
Chapter 7
 

Similar to SPCC:System programming and compiler construction

SPOS_UNIT I System Programming and Operating System.pdf
SPOS_UNIT I System Programming and Operating System.pdfSPOS_UNIT I System Programming and Operating System.pdf
SPOS_UNIT I System Programming and Operating System.pdfreshma96176
 
system software and application software, compiler, interpreter & assembler
system software  and application software, compiler, interpreter & assemblersystem software  and application software, compiler, interpreter & assembler
system software and application software, compiler, interpreter & assemblerchetan birla
 
Computer software and operating system
Computer software and operating systemComputer software and operating system
Computer software and operating systemsonykhan3
 
Vskills c developer sample material
Vskills c developer sample materialVskills c developer sample material
Vskills c developer sample materialVskills
 
Vskills c++ developer sample material
Vskills c++ developer sample materialVskills c++ developer sample material
Vskills c++ developer sample materialVskills
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programmingsonalikharade3
 
Computer Programs & System Softwares
Computer Programs & System SoftwaresComputer Programs & System Softwares
Computer Programs & System SoftwaresAbijah Naresh Jumani
 
System programming note
System programming noteSystem programming note
System programming noteSANTOSH RATH
 
System Software and Programming.pptx
System Software and Programming.pptxSystem Software and Programming.pptx
System Software and Programming.pptxVanshikaPatel41
 
c and data structures first unit notes (jntuh syllabus)
c and data structures first unit notes (jntuh syllabus)c and data structures first unit notes (jntuh syllabus)
c and data structures first unit notes (jntuh syllabus)Acad
 
System Software vs.Application Software
System Software vs.Application SoftwareSystem Software vs.Application Software
System Software vs.Application SoftwareAashima Wadhwa
 
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)SURBHI SAROHA
 
software development and programming languages
software development and programming languages software development and programming languages
software development and programming languages PraShant Kumar
 
C PROGRAMING AND PC
C PROGRAMING AND PCC PROGRAMING AND PC
C PROGRAMING AND PC4044uday
 
Inroduction System Software -features Types
Inroduction System Software -features TypesInroduction System Software -features Types
Inroduction System Software -features TypesSwapnaliPawar27
 

Similar to SPCC:System programming and compiler construction (20)

SPOS_UNIT I System Programming and Operating System.pdf
SPOS_UNIT I System Programming and Operating System.pdfSPOS_UNIT I System Programming and Operating System.pdf
SPOS_UNIT I System Programming and Operating System.pdf
 
system software and application software, compiler, interpreter & assembler
system software  and application software, compiler, interpreter & assemblersystem software  and application software, compiler, interpreter & assembler
system software and application software, compiler, interpreter & assembler
 
Computer software and operating system
Computer software and operating systemComputer software and operating system
Computer software and operating system
 
System software
System softwareSystem software
System software
 
Richa garg itm
Richa garg itmRicha garg itm
Richa garg itm
 
Vskills c developer sample material
Vskills c developer sample materialVskills c developer sample material
Vskills c developer sample material
 
Vskills c++ developer sample material
Vskills c++ developer sample materialVskills c++ developer sample material
Vskills c++ developer sample material
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Patrick armstrong athens
Patrick armstrong athensPatrick armstrong athens
Patrick armstrong athens
 
Computer Programs & System Softwares
Computer Programs & System SoftwaresComputer Programs & System Softwares
Computer Programs & System Softwares
 
System programming note
System programming noteSystem programming note
System programming note
 
Software ppt
Software pptSoftware ppt
Software ppt
 
System Software and Programming.pptx
System Software and Programming.pptxSystem Software and Programming.pptx
System Software and Programming.pptx
 
c and data structures first unit notes (jntuh syllabus)
c and data structures first unit notes (jntuh syllabus)c and data structures first unit notes (jntuh syllabus)
c and data structures first unit notes (jntuh syllabus)
 
SOFTWARE PARADIGM
SOFTWARE PARADIGMSOFTWARE PARADIGM
SOFTWARE PARADIGM
 
System Software vs.Application Software
System Software vs.Application SoftwareSystem Software vs.Application Software
System Software vs.Application Software
 
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)
ESSENTIAL COMPONENTS OF COMPUTERS(UNIT 2)
 
software development and programming languages
software development and programming languages software development and programming languages
software development and programming languages
 
C PROGRAMING AND PC
C PROGRAMING AND PCC PROGRAMING AND PC
C PROGRAMING AND PC
 
Inroduction System Software -features Types
Inroduction System Software -features TypesInroduction System Software -features Types
Inroduction System Software -features Types
 

Recently uploaded

Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Path loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelPath loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelDrAjayKumarYadav4
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...manju garg
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementDr. Deepak Mudgal
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...josephjonse
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...ssuserdfc773
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsmeharikiros2
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information SystemsAnge Felix NSANZIYERA
 

Recently uploaded (20)

Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Path loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelPath loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata Model
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information Systems
 

SPCC:System programming and compiler construction

  • 3.
  • 4.
  • 5.
  • 6.
  • 7. 1. Operating System a) Definition of OS b) Services and Functions of OS c) Process Management , Process Synchronization d) Memory management :- Paging and Segmentation e) Disk Management
  • 8. 2. Data Structure a) How to define data structure? b) Classification of data structure c) Searching in DS d) Sorting in DS
  • 9. How the C programs are executed in a system
  • 10. Preprocessor removes comment and include header file in source code , replace micro names with code.
  • 11.
  • 12.
  • 13.
  • 15. Introduction to System Software Concept of System Software ● Definition of Software. ● There are two categories of software ○ Application Software ■ Develop using programming lang. And Tools ■ Application software interact with system software ■ Design to perform a group of coordinated functions , tasks, activities for benefits of users. ■ Eg. Word, Exel, browsers, Account management system. ○ System Software ■ System software provide platform to the application software. ■ Task such as editing, linking,translating, managing resource, I/O Devices and error handling. ■ It is a set of programs which are developed to operate, control & extend processing capabilities of computer itself. ■ Eg. Operating system, compiler, Assembler, Interpreter etc. How does application software interact with OS?
  • 16.
  • 17.
  • 18. • System Software is usually written using Low-level language such as Assembly language. Some essential functions of System software are: – Disk Management – Memory Management – Device controlling – Loading and execution of other programs.
  • 19. Needs and Goals of system softwares 1. To run the hardware parts of computer and other applications. 2. To provide platform to all the applications software’s. 3. Handles all the hardware , software and network together. 4. Converts all human instructions into machine understandable formats. 5. Manage basic functions such as storing data, retrieving files & scheduling task etc. 6. To make effective execution of each program. 7. To make effective utilization of human resources.
  • 20. 1. System calls and System program. A system call creates an interface between the user process and the services offered by the operating system. So, the user process can directly communicate with the operating system and request the service it requires. While developing an application program or the system program the developer needs to embed these system calls in the code. This helps the program in utilizing the services of the operating system. Each operating system has its own set of system calls that decides what operations the operating system is able to perform.
  • 21. Example of System Call Let us say there is a user program that copies the content of one file to another file. sequence of system calls are 1. Prompt a message on the screen for the user to provide the name of the source and destination files. 2. Read the name of the source and destination file character by character from the keyboard. 3. Open a source file. Open (and if not available Create) the destination file. 4. Read from the source file and write to the destination file. 5. Close the source and destination file. 6. Prompt a message that displays the successful execution of the program. 7. Terminate the user program.
  • 22. ● System Program :- System programs are computer programs that provide platform for application programs to work. ● System Programming :- A System Programming language is basically referred to a programming language designed for writing system software , which usually requires different development approaches when compared with application software.
  • 23. Language Processor/LanguageTranslater Semantic Gap has many difficulties :- Large development time and efforts Poor quality of software
  • 24. Language Processor Programming language (PL’s Domain) is used to solve this issues and bridge the gap between the application domain and execution domain.
  • 25. Need of Language Domain ● It helps in minimizing the errors caused by the semantic gap. ● It helps in bridging the gap between the different domain and find out if there are errors in the input of any domain.
  • 26. Language Processor A language processor, or translator, is a computer program that translates source code from one programming language to another. They also identify errors during translation. Language Processor Activities ● Language processing activity bridges the ideas of software designers with actual execution on the computer system. ● The designer expresses the idea related to the application domain of the software. ● To implement these ideas, the description of the ideas has to be interpreted as related to the execution domain of the computer system. ● Two categories: ● Program generation activity ● Program Execution activity
  • 27. Program generation activity ● This activity generates a program from its specification program. Program generation activity bridges the specification gap. ○ A program generator is a software system program that accepts the specifications of the program to be generated and generates the program in the target program in a target programming language. ○ This activity generates a program from its specification. ○ The program generator introduces a new domain between the application and the programming language domain called the program generator domain. ○ It accepts the source program and generates a program in the target language.
  • 28. Program Execution activity ● This activity aims at bridging the execution gap by organizing the execution of a program written in a programming language on a computer system. A program may be executed through translation and interpretation. ○ This activity involves the actual execution of the program generated by the program generator. The program execution activity bridges the implementation gap. ○ The program execution activity involves loading the program into the memory of the computer system, interpreting the program instructions, and executing them on the computer system. ○ During program execution, the computer system reads the program instructions from memory and executes them one by one, performing the necessary computations and producing the desired results. ○ The program execution activity involves various components of the computer system, including the processor, memory, input/output devices, and other system resources required to execute the program
  • 29. Difference between Application and system software – What it is? – Installation? – Level of language? – Use? – Design requirements? – Fixed for machine? – Who uses it? – Examples?
  • 30. System Software Application Software System software is a set of computer programs that is designed to manage system resources. Application Software is a type of software that is mainly developed to perform a specific task as per the user's request. It acts as an interface between the Application Software and Computer hardware. It acts as an interface between the end-user and System Software. It is a general-purpose software. It is a specific-purpose software. System software is usually installed on the computer system at the time of OS installation. Application Software is usually installed on the system as per the requirement of the user. This software runs independently and works as a platform for working application software. This software is not capable of running independently, which means they need system software to work on. These are usually written in low-level languages such as Assembly language. These are usually written in a high-level language such as C, C++, Java, etc. System software work on the background, hence user don't directly interact with them. Application software work on user-interface, hence user directly interact with them. A system software starts running as we turn on our computer system and stops when the system is turned off. Application software runs as per user request. It means when we launch them, then only they start and stop when we close them. The development of System software is complicated and takes more time compared to application software, as they are built by considering the hardware compatibility. Development of Application software is comparatively easier and takes less time than system software. A computer system can't run without system software. A computer system can always run without application software. However, for users, it is required to have some important application software to work on. The working of system software is automated and starts functioning automatically after starting the computer system. The working of application software is manual, which means the user needs to start using it. Examples of System Software are Operating systems, Compiler, Assembler, Device drivers, etc. Examples of Application Software are Web browsers, MS office, Graphic design software, etc.
  • 31. Introduction to various System Programs 1. Assemblers :- Single, Two and Multipass Assembler 2. Loaders :- Four Functions a. Allocation b. Linking c. Relocation(Changing certain instruction) d. Loading 3. Linkers 4. Macro Processors 5. Compiler 6. Interpreters 7. Operating System 8. Device Drivers(abstraction layer between hardware and application or OS)
  • 32. 9. Editors 10. Debuggers Eclipse IDE(Java) Nodeclipse (Java Script) Microsoft Visual studio debugger etc.
  • 33.
  • 34. ● What is system software & application software? ● List and explain various types of System programming components. ● What is a language processor? ● Write a note on the evolution of system software. ● Define Loader. What are the different functions of loaders? ● Arrange the following System Softwares according to their role in Program Execution: Linker, Loader, Compiler, Macro-preprocessor, Assembler, Text Editor. ● Enlist the functions of loader. ● List and explain activities performed by Language processor.
  • 36.
  • 38. Assembler Assembler is a program for converting instructions written in low-level assembly code into relocatable machine code and generating along information for the loader. The assembler performs a one-to-one mapping from mnemonic instructions to machine statement and data. Mnemonic is a code usually 1 to 5 letters that represents an op-code followed by one or more numbers. This is in contrast with high level language in which single statement generally results in many machine instructions. Assembly Language: Assembly language is a kind of low level programming language, which uses symbolic codes mnemonics as instruction. ADD,SUB,LTD and STA.
  • 39. Some example of mnemonics are Instruction Op code Assembly Mnemonic 00 STOP 01 ADD 02 SUB 03 MULT 04 MOVER 05 MOVEM 06 COMP 07 BC 08 DIV 09 READ 10 PRINT
  • 40. Elements of Assembly Language ● Mnemonic operation codes Instead of using numeric operation code (op code) , mnemonics are used. Eliminates the need to memorize numeric operation codes. Eg . ADD, SUB , MOVE etc. ● Symbolic operands Symbolic names can be associated with data or instructions. Symbolic names can be used as operands in assembly statements (need not know details of memory bindings). Eg . ADD R1,R2,R3 ● Data declarations Data can be declared in a variety of notations, including the decimal notation (avoids conversion of constants into their internal representation) Eg. NUM1 03 or NUM 0011H
  • 41. Assembly Language Statements ● Assembly language programs consist of three types of statements − • Executable instructions or Imperative Statements The executable instructions or simply instructions tell the processor what to do. Each instruction consists of an operation code (opcode). Each executable instruction generates one machine language instruction. Eg. ADD, SUB etc. • Assembler directives Statement this kind of neither represent the machine instruction to be included in the object program nor indicate the allocation of storage for constant or program variable. They are use to indicate certain things regarding how assembly of the input program is to be performed. Eg. ABC START 1000 END • Declaration Statements These are non executable statements. They declare constants or storage areas or storage areas in a program. Eg. X DS 2 DS – Declare storage. -🡪 indicate that a storage area namely X reserved for 2 word. G DS 200 ---🡪 ?
  • 42. Format of Assembly language Statement ● Assembly language statements are entered one statement per line. Each statement follows the following format − [label] ,mnemonic/opcode ,operand specification, [;comment] ● The fields in the square brackets are optional. ● A basic instruction has two parts, the first one is the name of the instruction (or the mnemonic), which is to be executed. Eg. ADD , SUB, MOVE ● First operand is always register. Eg. R1, R2, R3 ● Second operand is memory word using symbolic name. ● Eg. ADD R1 ONE/1
  • 43. Literals and Symbol Literals are the constant value enclosed in ‘ ‘ . Example:- MOVER AREG, =‘5’. Symbols are the labels or variables. Example:- LOOP MOVER AREG,X Symbol Symbol
  • 44. Literals and Symbol Data Structure Literal Table Symbol Table INDEX NAME OF LITERALS ADDRESS INDEX NAME OF SYMBOLS ADDRESS
  • 45. Advanced Assembler Directives ORIGIN(ORG) • This can be used to indirectly assign values to symbols. • When this statement is encountered during assembly of a program, the assembler reset its location counter to the specified values. • The ORG statement will thus affect the values of all labels defined until the next ORG. Syntax :- ORIGIN <address spec> Example :- ORIGIN 201 , ORIGIN LOOP+ 4 🡪(Expression)
  • 46. Advanced Assembler Directives LTORG • LTORG allows placing literals into a pool at some other location in the object program. • Directives LTORG creates a literal pool that contain all of the literal operands used since the previous LTORG or the beginning of the program. • The LTORG statement permit a programmer to specify where literals should be placed. By default, assembler places the literals after the END statement. EQU • Most assemblers provide an assembler directive that allows the programmer to define symbols and assign the value evaluate by the expression in the operand field. Syntax Symbol EQU Value/ symbol name Example :- 1. A EQU 1 --🡪 1 value assign to A 2. X EQU Y 🡪 X is set to the address of Y. 3. X EQU LOOP 🡪 X is set to the address of LOOP.
  • 47. Let’s take a look on how this program is working: ● START: This instruction starts the execution of program from location 200 and label with START provides name for the program.(JOHN is name for program) ● MOVER: It moves the content of literal(=’3′) into register operand R1. ● MOVEM: It moves the content of register into memory operand(X). ● MOVER: It again moves the content of literal(=’2′) into register operand R2 and its label is specified as L1. ● LTORG: It assigns address to literals(current LC value). ● DS(Data Storage): It assigns a data space of 1 to Symbol X. ● END: It finishes the program execution.
  • 48. Basic function of Assembler: ● Translate mnemonics opcodes to machine language. ● Convert symbolic operands to their machine addresses. ● Build machine instructions in the proper format ● Convert data constants into machine representation. ● Error checking is provided. ● Changes can be quickly and easily incorporated with a reassembly. ● Variables are represented by symbolic names, not as memory locations. ● Assembly language statements are written one per line. A machine code program thus consists of a sequence of assembly language statements, where each statement contains a mnemonics.
  • 49. Advantages: ● Reduced errors ● Faster translation times ● Changes could be made easier and faster. ● Addresses are symbolic, not absolute ● Easy to remember Disadvantages: ● Assembler language are unique to specific types of computer ● Program is not portable to the computer. ● Many instructions are required to achieve small tasks ● Programmer required knowledge of the processor architecture and instruction set.
  • 50. Translation phase of Assembler: The six steps that should be followed by the designer 1. Specify the problem 2. Specify data structure 3. Define format of data structure 4. Specify algorithm 5. Look for modularity 6. Repeat 1 through 5 on modules
  • 51.
  • 53. Data Structure of the Assembler
  • 54. Pass 1 Purpose:- Define symbols and literals ● Determine length of machine instructions(MOTGET1) ● Keep track of Location Counter(LC) ● Remember values of symbols until pass 2(STSTO) ● Process some pseudo ops, e.g. EQU , DS(POTGET1) ● Remember literals(LITSTO)
  • 56. Example 1 :- For the following program Show Symbol and Literal Table JOHN START 200 MOVER R1,=‘3’ MOVEM R1,X L1 MOVER R2,=‘4’ X DS 1 END
  • 57. 2. START 1000 READ N MOVER B, =’1’ MOVEM B, TERM AGAIN MULT B, TERM MOVER C, TERM ADD C, =’2’ MOVEM C, TERM COMP C, N BC LE, AGAIN MOVEM B RESULT LTORG PRINT RESULT STOP N DS 1 RESULT DS 3 TERM DS 1 END START 1000 READ N 1000 MOVER B, =’1’ 1001 MOVEM B, TERM 1002 AGAIN MULT B, TERM 1003 MOVER C, TERM 1004 ADD C, =’2’ 1005 MOVEM C, TERM 1006 COMP C, N 1007 BC LE, AGAIN 1008 MOVEM B RESULT 1009 LTORG 1010,1011 PRINT RESULT 1012 STOP 1013 N DS 1 1014 RESULT DS 3 1015
  • 59. START 1000 READ N MOVER B, =’1’ MOVEM B, TERM AGAIN MULT B, TERM MOVER C, TERM ADD C, =’2’ MOVEM C, TERM COMP C, N BC LE, AGAIN MOVEM B RESULT LTORG PRINT RESULT ADD C, =’6’ SUB C, X STOP N DS 1 RESULT DS 3
  • 61. Phases Of Assembler Analysis phase: • Separate contents of the label, mnemonic opcode and operand fields of a statement. • If a symbol is present in the label field, enter the pair (symbol, <LC>) in a new entry of the symbol table. • Check validity of the mnemonic opcode through a look-up in the Mnemonics table. • Perform LC processing, i.e., update the address contained in the location counter by considering the opcode and operands of the statement. Synthesis phase: • Read the machine opcode corresponding to the mnemonic from the Mnemonics table. • Get an address of each memory operand from the Symbol table. • Synthesize a machine instruction or the correct representation of a constant, as the case may be.
  • 62. Data Structure with analysis and synthesis phase
  • 63. Intermediate code (IC) ● If a compiler translates the source language to its target machine language without having the option for generating intermediate code, then for each new machine, a full native compiler is required. ● Intermediate code eliminates the need of a new full compiler for every unique machine by keeping the analysis portion same for all the compilers. ● The second part of compiler, synthesis, is changed according to the target machine. ● It becomes easier to apply the source code modifications to improve code performance by applying code optimization techniques on the intermediate code.
  • 64. Data Structures used for Intermediate Code Mnemonic Opcode Table (MOT) Op code Assembly Mnemonic Type 00 STOP IS 01 ADD IS 02 SUB IS 03 MULT IS 04 MOVER IS 05 MOVEM IS 06 COMP IS 07 BC IS 08 DIV IS 09 READ IS 10 PRINT IS Assembler Directives (AD) (POT) Op code Assembly Directives Type 01 START AD 02 END AD 03 EQU AD 04 ORIGIN AD 05 LTORG AD Declaration Statements(DL) Op code Assembly Directives Type 01 DS DL 02 DC DL
  • 65. Variant I of IC Single digit number is the code used for a register. This is the first operand. Memory operand is the second operand and represent in the following format. (operand class , code) Where , operand class 🡪 C (constant) , S(symbol) , L(Literal) Example (C,300) , (S, 01) , (L, 01) Index from ST and LT
  • 66. ● (AD,O1) (C,200) ● (IS,04) (RG,01) , (L,0) ● (IS,05) (RG,01) (S,0) ● (S,01) (IS,04) (RG,02) (L,1) ● (AD,05) ● (S,00) (DL,06) (C,1) ● (AD,02) For imperative statement(IS) , Assembler Directives (AD) , Declaration Statements(DL)
  • 67. Variant II for IC • In variant II, operands are processed selectively. • Constants and literals are processed. Symbols, condition codes and CPU registers are not processed.
  • 68. Example Assembly program START 200 MOVER AREG, = ‘5’ MOVEM AREG , X L1 MOVER BREG, = ‘3’ LTORG X DS 1 END
  • 69. Gernerate the Intermediate code for given program. START 1000 READ N MOVER B, =’1’ MOVEM B, TERM AGAIN MULT B, TERM MOVER C, TERM ADD C, =’2’ MOVEM C, TERM COMP C, N BC LE, AGAIN MOVEM B RESULT LTORG PRINT RESULT ADD C, =’6’ SUB C, X STOP N DS 1 RESULT DS 3
  • 70. PASS 1 OF TWO PASS ASSEMBLER (FLOW CHART) USING DROP
  • 71. Pass 2 Purpose :- Object Code is Generated After the symbol table is completed in PASS 1 it does the actual assembly by translating the operations and so on. The purpose of PASS 2 is to generate object code. 1. Look up value of symbols(STGET) 2. Generate instructions(MOTGET2) 3. Generate data(for DC,DS and literals) 4. Process pseudo ops(POTGET2) 5. Base table :- Indicate which registers are specified as base registers by USING pseudo-op codes and what the specified contents of these registers are.
  • 72. Generate Target Code OP-CODE REG. MEMORY For Imperative Statement (IS) REG 🡪 Opcode for register Memory 🡪 Address of symbol or literal
  • 73. Target Code LC OPCODE REG MEMORY --- ---- --- 200 9 --- 209 201 9 --- 210 202 4 1 212 203 1 1 210 204 4 2 209 205 2 2 209 206 5 2 211 207 10 -- 211 208 00 -- -- 209 -- -- -- 210 -- -- -- 211 -- -- -- -- -- --
  • 76.
  • 78. Forward Reference Problem • The assembler specifies the symbols should be declared anywhere in the program. There may be chances of using a symbol before its declaration which gives rise to a forward reference problem. • The solution for forward references problem is having an assembler of two pass. The assembler cannot know the address of the forward reference label until it reads the definition of the label. • In forward referencing, variable or label is referenced before it is declared. Different problems can be solved using One Pass or Two Pass forward referencing.
  • 79. Single Pass Assembler ● A single pass assembler scan the input file only once. During that single pass the assembler handles both table definitions and assembly. ● It is generally faster than a two pass assembler. ● Single pass assembler construct symbol table, literal table and pseudo-op table. ● The main problem encountered in one pass is that of a forward reference. ● The problem of forward reference is handled by single pass assembler is back patching.
  • 80. ● Back patching is a process in which the operand field of an instruction containing a forward reference is left blank initially. ● The address of the forward reference symbol is put into this field when its definition is encountered in the program. ● In order to perform back patching , single pass assembler requires an additional data structure called Table of incomplete instruction(TII).
  • 81. Single Pass Assembler No Intermediate code generate Target code LC OPCODE REG MEM
  • 82. Forward Reference in One-Pass Assembler 1. Omit the operand address if the symbol has not yet been defined. 2. Enter this undefined symbol into SYMTAB and indicate that it is undefined. 3. Adds the address of this operand address to list of forward reference associated with the SYMTAB entry. 4. When the definition for the symbol is encountered, scans the reference list and insert the address. 5. At the end of the program , reports the error if there are still SYMTAB entries indicated undefined symbols.
  • 83.
  • 84.