System Programming Introduction What is System System is

  • Slides: 35
Download presentation
System Programming

System Programming

Introduction What is System? • System is a collection of various components. What is

Introduction What is System? • System is a collection of various components. What is Programming? • Art of designing and implementing the programs. So System Programming is the art of designing and implementing the system programs.

What is Software? Software is a collection of many programs. Two types of Software

What is Software? Software is a collection of many programs. Two types of Software - System Software : These programs assist general user application programs. Eg : Operating System, Assembler, Compiler - Application Software : These are the softwares developed for the specific goal. Eg : Media Player, Adobe Reader

System Programming System Program: These programs which are required for the effective execution of

System Programming System Program: These programs which are required for the effective execution of general user programs on computer system. System Programming: It is an art of designing and implementing system programs.

Components of System Programming v Text Editor v Loader v Assembler v Macro Processor

Components of System Programming v Text Editor v Loader v Assembler v Macro Processor v Compiler v Debugger

Text Editor A text editor is a type of program used for editing plain

Text Editor A text editor is a type of program used for editing plain text files. eg. Notepad With the help of Text Editor we can write programs. eg. C program or Java program

Loader • A loader is a program that takes object code as input and

Loader • A loader is a program that takes object code as input and prepares them for execution. • It initiates the execution. • Functions: Allocation Linking Relocation Loading

Loader Functions Allocation Loader Allocation space for programs in main memory. Linking If we

Loader Functions Allocation Loader Allocation space for programs in main memory. Linking If we have different modules of our program Linker links object modules with each other.

Loader Functions Contd… Relocation : Loader adjusting all address dependent location. Eg. If we

Loader Functions Contd… Relocation : Loader adjusting all address dependent location. Eg. If we have two programs program A and program B • Program A saved at location 100 • And user wants to save program B on same location, it is physically not possible. • So loader relocates program B to some other free location.

Loader Functions Contd… Loading: Physically loading the machine instructions and data into main memory.

Loader Functions Contd… Loading: Physically loading the machine instructions and data into main memory.

Assembler is a translator which translates assembly language program into machine language. Assembly Language

Assembler is a translator which translates assembly language program into machine language. Assembly Language Program Assembler Machine Language Program

Macro Processor Macro allows a sequence of source language code to be defined once

Macro Processor Macro allows a sequence of source language code to be defined once and then referred many times. Eg. Macro macro_name Macro body Macro Processor takes a source with macro definition and macro calls and replaces each macro call with its body.

Compiler is a translator which converts the high level language into low level language.

Compiler is a translator which converts the high level language into low level language. High Level Language Program Compiler Machine Language Program

Debugger • Debugging tool helps programmer for testing and debugging programs. • It provides

Debugger • Debugging tool helps programmer for testing and debugging programs. • It provides some breakpoints. • Displaying values of variables.

Assembly Language • Assembly language is low level language. • It is machine dependent.

Assembly Language • Assembly language is low level language. • It is machine dependent. • It differs from computer to computer. • Assembler converts assembly language into machine language.

Assembly Language programming Terms • Location Counter (LC) : points to the next instruction.

Assembly Language programming Terms • Location Counter (LC) : points to the next instruction. • Literals : Constant values • Symbols : name of the variables and labels • Procedures: methods / functions

Assembly Language Statements • Imperative Statements • Declarative/Declaration Statements • Assembler Directive

Assembly Language Statements • Imperative Statements • Declarative/Declaration Statements • Assembler Directive

Imperative Statements • Imperative means mnemonics. • These are the executable statements • Each

Imperative Statements • Imperative means mnemonics. • These are the executable statements • Each imperative statement indicates an action to be taken during execution of the program. • Eg. MOVER BREG, X STOP READ X ADD AREG, Z

Declarative Statements • Declaration statements are for reserving memory for variables. • It has

Declarative Statements • Declaration statements are for reserving memory for variables. • It has two types : DS – Declaration Storage eg. X DS 1 DC – Declare Constant eg. Y DC ‘ 5’

Assembler Directive • Assembler Directive instruct the assembler to perform certain actions during assembly

Assembler Directive • Assembler Directive instruct the assembler to perform certain actions during assembly of a program • Eg. START <address constant> END

How LC Operates? SAMPLE CODE S. No. LC 1 START 100 2 MOVER AREG,

How LC Operates? SAMPLE CODE S. No. LC 1 START 100 2 MOVER AREG, X 3 MOVER BREG, Y 4 ADD AREG, BREG 5 MOVEM AREG, X 6 X DC ‘ 10’ 7 Y DC ‘ 15’ 8 END

How LC Operates? S. No. LC 1 START 100 2 MOVER AREG, X 100

How LC Operates? S. No. LC 1 START 100 2 MOVER AREG, X 100 3 MOVER BREG, Y 101 4 ADD AREG, BREG 102 5 MOVEM AREG, X 103 6 X DC ‘ 10’ 104 7 Y DC ‘ 15’ 105 8 END

Identification of symbol, AD, IS, DS S. No. LC AD DS IS Symbol 1

Identification of symbol, AD, IS, DS S. No. LC AD DS IS Symbol 1 START 100 2 MOVER AREG, X 100 3 MOVER BREG, Y 101 4 ADD AREG, BREG 102 5 MOVEM AREG, X 103 6 X DC ‘ 10’ 104 X 7 Y DC ‘ 15’ 105 Y 8 END

Assembler • An assembly language program can be translated into machine language. • It

Assembler • An assembly language program can be translated into machine language. • It involves the following steps Ø Find address of the variable. Ø Replace symbolic addresses by numeric addresses. Ø Replace symbolic opcodes by machine operation codes. Ø Reserve storage for data.

General Design Procedure of Assembler Ø Statement of problem Ø Data Structure Ø Format

General Design Procedure of Assembler Ø Statement of problem Ø Data Structure Ø Format of database Ø Algorithms Ø Look for modularity

Statement of problem • To convert the assembly language program into machine language.

Statement of problem • To convert the assembly language program into machine language.

Data Structure Data structure used are Ø Symbol Table Ø Literal Table Ø Mnemonic

Data Structure Data structure used are Ø Symbol Table Ø Literal Table Ø Mnemonic Opcode Table Ø Pool Table

Format of database Symbol Table Name of Symbol Address Literal Table Literal Address

Format of database Symbol Table Name of Symbol Address Literal Table Literal Address

Format of database Contd. . . MOT Mnemonic Machine opcode Pool Table Literal Number

Format of database Contd. . . MOT Mnemonic Machine opcode Pool Table Literal Number Class Length

Look for modularity If the program is too long it can be make modules

Look for modularity If the program is too long it can be make modules of it.

Types of Assembler There are two types of Assembler. Ø One Pass Assembler Ø

Types of Assembler There are two types of Assembler. Ø One Pass Assembler Ø Two Pass Assembler

One Pass Assembler § A single pass assembler scans the program only once and

One Pass Assembler § A single pass assembler scans the program only once and creates the equivalent binary program. § Pass 1 assembler substitute all the symbolic instruction with machine code in one pass.

Two Pass Assembler § It performs two passes. § In Pass 1 it collects

Two Pass Assembler § It performs two passes. § In Pass 1 it collects the labels and symbols § In Pass 2 it assembles the instructionne pass.

Difference One Pass Assembler Performs single pass Two Pass Assembler Performs two passes In

Difference One Pass Assembler Performs single pass Two Pass Assembler Performs two passes In first pass itself its collects the In first pass it collects the labels and symbols and labels and assembles the symbols and in second pass it instruction assembles the instruction It stores all mnemonics and pseudocodes in a single table MOT It stores mnemonics and pseudo codes separately. Ie. MOT and POT All entries for symbols and literals are entered into symbol table only Literals and symbols are stored in symbol and literal table respectively

THANK YOU Geetha K Assistant Professor BCA Department Karpagam Academy of Higher Education

THANK YOU Geetha K Assistant Professor BCA Department Karpagam Academy of Higher Education