Introduction to System Programming Concepts
Introduction to System Programming Concepts
Operating System
Unit -1
SPOS
System introduction
system programming is an art of designing and implementing system Programs. Unit- I
Programming
is
System
is Way to
Collection
instruct
Component of To perform
compute
College the
eg.
Various Task
SPOS
Software Hierarchy
Unit- I
Software
Software
is
System Application
Collection
Software Software
of
assist general user software developed
Many application for the specific goal
Programs
Operating System Media player
Hardware Management:
● System software, particularly the operating system (OS), acts as an intermediary between
the hardware and the user. It manages hardware resources such as the CPU, memory,
storage devices, and input/output devices.
● It ensures efficient and fair allocation of resources among various applications.
Application Support:
Network Management:
Device Drivers:
● Includes device drivers that facilitate communication between the OS and hardware devices.
● Ensures proper functioning and compatibility of peripheral devices like printers, scanners, and
network adapters.
● Handles software updates, patches, and maintenance tasks to keep the system secure and
up-to-date.
● Ensures that the system software remains compatible with new hardware and applications.
File Management:
System Program
are System Programming
Required Is an art of
for
Computer System
Components of Systems SPOS
Programming: Unit- I
● Text Editors,
● Loader and Linker
● Assembler,
● Compiler,
● Macros,
● Debugger,
● Interpreter,
● Device Drivers,
● Operating System.
SPOS
System Software
Unit- I
Text Editor
With the help
is
program
Used for
of
Editing plain text Text Editor
files
You can Example
Write Your Program C | Java
Prog.
SPOS
System Software
Unit- I
Example
Text Editor Notepad
Text Editor
Editor
is
is
Program
Computer
Program
In which
That allows Character
Primary
to Elements String
A user
create and revise a
document
being Edited are
SPOS
System Software
Unit- I
Loders
is
Object Code
and Initiates
Execution
it
SPOS
System Software
Unit- I
Loders Functions
Allocation
Linking
Relocation Loading
SPOS
System Software
Unit- I
Loders Functions
Allocation
Loader allocates space for programs in main memory.
SPOS
System Software
Unit- I
Loders Functions
Loders Functions
Linking
● If we have different modules of our
program.
Loders Functions
Loading
Physically loading the machine instructions and data
into main memory.
SPOS
Assembler
Unit- I
Assembly Lang.
Program Assembler Machine Lang.
Translate
SPOS
Macro Processor
Unit- I
Macro
Allows
Defined @ once
Referred many times
To be
Sequence
of Source Lang. Code
SPOS
Macro Processor
Unit- I
Syntax
// macro body
★ A macro processor takes a source with macro
Mend definition and macro calls and replaces each
macro call with its body
SPOS
5. Macro Processor
Unit- I
{
STA DATA1 . STA DATA1
STB DATA2
STB DATA2
STX DATA3
STX DATA3
MEND
.
{
.
STRG STA DATA1
. STB DATA2
STRG STX DATA3
. .
.
SPOS
Compiler
Unit- I
Converts
SPOS
Compiler
Unit- I
It is very easy to write a program in a high A program written in a high level language is
level language machine independent.
SPOS
Debugger
Unit- I
•Setting breakpoints.
Machine
Program
Interpreter language
statement
statement
Statement
execution
Fig.: Interpreter
8. Operating system (OS)
2. Symbolic Operand:
Ex: DS – Declare as storage
DC – Declare as Constant
3. Data Declaration:
Ex: X DC ‘-10.5’
[Link] Format
Statement Format:
[Label] <opcode> <operand1> [ <operand2>..]
Label-Optional
Opcode- it contain symbolic operation code
Operand- Operand can also be a CPU register: AREG, BREG,CREG.
Example-
LOOP : MOVER AREG, ‘=5’
Machine supports 11 Different Operations
Symbolic opcode Remark
STOP Stop Excecution
ADD Operand 🡨 Oper1+Oper2
SUB Operand 🡨 Oper1- Oper2
MULT Operand 🡨 Oper1*Oper2
MOVER CPU Register🡨 Memory move
MOVEM Memory operand🡨 CPU register
COMP Set condition code
Comparison instruction sets a condition code
The condition code can be tested by BC
BC Branch on condition
Format for BC : BC <condition code spec.>, <Memory address>
1. LT-Less than
2. LE-Less or equal
3. EQ-Equal
4. GT-Greater than
5. GE-Greater or equal
6. ANY-Implies unconditional transfer of control
Machine supports 11 Different Operations
Symbolic Remark
opcode
DIV Operand 🡨 Oper1/Oper2
READ Operand2🡨 input value
PRINT Output🡨 operand2
Imperative
Statements
Declarative/Declaration
Statements
Assembler Directive
SPOS
Assembly Language
Unit- I
Declarative/Declaration Types
Statements
Declare Storage
Syntax
Example
X DS 1
SPOS
Assembly Language
Unit- I
Declare Constant
Syntax
Example
X DC ‘5’
[Link] Directive
• Instructs the assembler to perform certain actions during assembly
of a program.
• A directive is a direction for the assembler
• A directive is also known as pseudo instruction
• machine code is not generated for AD.
[Link] Directive…
• START <Constant>
• It indicates that the first word of the m/c code should be placed in
the memory word with the address <CONSTANT>
[Link] Directive…
END [<OPERAND SPECIFICATION>]
• Optional, indicates address of the instruction where the
address of program should begin.
• By default, execution begins from the first instruction.
• It indicates the end of the source program.
• Class:AD
Advanced Assembler Directives
These directive include:
1. ORIGIN
2. EQU
3. LTORG
ORIGIN
• Useful when m/c code is not stored in consecutive memory location.
• ORIGIN <address specification>
ADD AREG, X
ADD AREG,=‘6’ ----------------
-----------------
X DC ‘6’
1. START 100
2. MOVER A REG, X
3. MOVER B REG, Y
4. ADD A REG, Y
5. MOVEM A REG, X
6. X DC ‘10’
7. Y DS 1
8. END
SPOS
Assembly Language
Code Unit- I
Identify types of statement 1. START 100
1. 3. MOVER B REG, Y
2. 4. ADD A REG, Y
3.
4.
SPOS
Assembly Language
Code Unit- I
Identify types of statement 5. MOVEM A REG, X
Sr. No IS DS AD 6. X DC ‘10’
5. 7. Y DS 1
6. 8. End
7.
8.
Types of Assembler
3 Types of Assemblers
1. Load and Go-Assembler
2. One-pass Assembler
3. Two-pass Assembler
[Link] and Go-Assembler
• Simplest form of assembler
• It produces machine language as output which are loaded directly in
main memory and executed
• The ability to design code and test the different program
components in parallel
[Link] Pass Assembler
• Normally , it does not allow forward referencing.
• An assembler cannot generate m/c code for an assembly
instruction with FR.
• Machine code is generated ,after the address of variable used in
the instruction is known.
• Symbol table is used to record the address of the variables.
Assembler SPOS
Unit- I
Assembler SPOS
Unit- I
Pass 1 Pass 2
Generates Generates
Unit- I
Two Pass
Assembler
Pass 1
Assembler Pass 2
Assembler
Labels
Determine Storage Generate the
Separate
Mnemonic Opcode Requirement machine code
START 01 AD -----
END 02 AD -------
ORIGIN 03 AD -----
EQU 04 AD -------
LTROG 05 AD -----
DS 01 DL -------
DC 02 DL 1
AREG 01 RG -----
BREG 02 RG -------
CREG 03 RG -----
Pass 1 Assembler SPOS
Unit- I
1 L1 202
2 NXT 207
3 BACK 202
Literal Table
It contains:
1. Value of the literal
2. Address of the memory location associated with
the literal. LITERAL TABLE
Example- Literal address
Index
0 5 205
1 2 206
2 1 210
3 2 211
4 4 215
POOL Table
This table contains the literal number of the starting literal of each literal
pool.
POOL TABLE
Index
0 0
1 2
2 4
Intermediate Code
• Is equivalent representation of source program.
• Pass-I of the assembler involve scanning of the source file.
• Every opcode is searched in MOT
• It helps in avoiding:
1. Scanning of source file in PASS-II
2. Searching MOT and ST in PASS-II
Format of Intermediate Code
Each Mnemonic opcode field is represented as:
( Statement class , Machine code )
Observe code
Apply LC
Pass 1 Assembler SPOS
Unit- I
Symbol Table
Construct
Pass 1 Assembler SPOS
Unit- I
Literal Table
Construct
Pass 1 Assembler SPOS
Unit- I
Pool Table
Assignment
Pass 2 Assembler SPOS
Unit- I
Pass 2 Assembler
❏ Processes the intermediate representation (IR) to
synthesize the target program.
Pass 2 Assembler
Assignment
START 200
MOVER AREG, ‘=5’…………. 200
MOVEM AREG, X ………… 201
L1 MOVER BREG, ‘=2’………….202
ORIGIN L1+3 202+3=205
LTORG ………… 205,206 for literal
NEXT ADD AREG, ‘= 1’ ………… 207
SUB BREG,’=2’ ………… 208
BC LT, BACK …………. 209
LTORG 210, 211…. for literal
BACK EQU L1 ………… 202
ORIGIN NEXT+5 207+5=212
MULT AREG,’=4’ …………212
STOP……………………………213
X DS ‘5’………………………. 214
END ……….. 219 for literal (214+5=219)
SYMBOL TABLE
LITERAL TABLE
Literal address
Index
0 5 205
1 2 206
2 1 210
3 2 211
4 4 219
Assembly Program LC Intermediate Code
START 200 ………..(AD,01) (C,200)
MOVER AREG, ‘=5’….. 200 ….(IS,04) (RG,01) (L,0)
MOVEM AREG, X…… 201….(IS,05) (RG,01) (S,0)
L1 MOVER BREG, ‘=2’….. 202 ….(IS,04) (RG,02) (L,1)
ORIGIN L1+3 (AD,03) (C,205)
LTORG 205……(DL,02) (C,5)
206 ……(DL,02) (C,2)
NEXT ADD AREG, ‘= 1’……. 207 ….(IS,01) (RG,01) (L,2)
SUB BREG,’=2’ ……… 208 ….(IS,02) (RG,02) (L,3)
BC LT, BACK…………. 209 ….(IS,07) (CC,02) (S,3)
LTORG ……….. 210, ……(DL,02) (C,1)
211 ……(DL,02) (C,2)
BACK EQU L1 ……….. 202 ………..(AD,01) (C,202)
ORIGIN NEXT+5 ………..(AD,01) (C,212)
MULT AREG,’=4’…….. 212 ….(IS,03) (RG,03) (L,4)
STOP…………………… 213 ….(IS,00)
X DS ‘5’……………. 214 ……(DL,01) (C,1)
END -------(AD,02)
219 ………(DL,02) (C,4)
Assembly Program LC Intermediate Code
START 200 machine code
MOVER AREG, ‘=5’….. 200 … 04 01 205
MOVEM AREG, X…… 201…. 05 01 214
L1 MOVER BREG, ‘=2’….. 202 ….04 02 206
ORIGIN L1+3
LTORG 205……00 00 05
206 ……00 00 02
NEXT ADD AREG, ‘= 1’……. 207 ….01 01 210
SUB BREG,’=2’ ……… 208 ….(IS,02) (RG,02) (L,3)
BC LT, BACK…………. 209 ….(IS,07) (CC,02) (S,3)
LTORG ……….. 210, ……(DL,02) (C,1)
211 ……(DL,02) (C,2)
BACK EQU L1 ……….. 202 ………..(AD,01) (C,202)
ORIGIN NEXT+5 ………..(AD,01) (C,212)
MULT AREG,’=4’…….. 212 ….(IS,03) (RG,03) (L,4)
STOP…………………… 213 ….(IS,00)
X DS ‘5’……………. 214 ……(DL,01) (C,1)
END -------(AD,02)
219………(DL,02) (C,4)
Flowchart of
Pass-1 of Two
pass assembler
Flowchart of
Pass-2 of
Two pass
assembler