OSSP Unit 5 Presentation

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 35

Unit V- Introduction to Systems Programming and Assemblers

Introduction: Need of System Software, Components of System


Software, Language Processing Activities, Fundamentals of Language
Processing. Assemblers: Elements of Assembly Language Programming,
A simple Assembly Scheme, Pass structure of Assemblers, Design of
Two Pass Assembler.

Department of Information Technology, VIIT, Pune-48


System software

System software components are defined as the software system


designed to operate the computer’s hardware;
It provides a platform to run the application software and the basic
functions for the computer usage.
It works as a linking interface between a hardware device and the end-
user.

Department of Information Technology, VIIT, Pune-48


System software

Department of Information Technology, VIIT, Pune-48


Types of System Software

Department of Information Technology, VIIT, Pune-48


Components of System Software

1. Operating System:
An Operating System is the most basic type of System Software that helps to
manage computer hardware and software.
It is the central part of any computer system which is responsible for the smooth
functioning of any computer device
An Operating system primarily operates your computer when you start it.
If you haven't installed the operating system on your computer, then you will not
be able to start your computer.
Some most common examples of OS are macOS, Linux, Android, and Microsoft
Windows

Department of Information Technology, VIIT, Pune-48


Components of System Software

Programming Language Translators


• software that converts high-level language into machine language.
• A computer can only understand the machine language or binary bits pattern,
either 0 or 1.
• A CPU understands this machine language that is not easy to understand by a
normal human.
• Hence, First, the end-user interacts with the computer in a high-level language
like Java, Python, C, PHP, and C++, etc., then the translator converts these
languages into machine code.
• The process to convert high-level language into machine code or binary codes
are known as compilation.
• Language translators are of mainly two types: Compiler and Interpreter.

Department of Information Technology, VIIT, Pune-48


Components of System Software
Device drivers

• The operating system communicates with hardware components controlled with the help of
device drivers.
• The operating system contains a number of device drivers to drive the hardware components.
• Here are some devices that require drivers to perform the smooth functions of any computer
system:
• Keyboards
• Mouse
• Printers
• Function keys
• Network card
• Display card
• Touchpad
• Sound, etc

Department of Information Technology, VIIT, Pune-48


Components of System Software
Firmware softwares
• These are the operational software installed on the computer motherboards
that help the operating system to identify the Flash, ROM, EPROM, EEPROM,
and memory chips.
• The manufacturer installs the firmware on the motherboard, and it can be
accessed through these two types of chips.
 BIOS(Basic Input Output System)
 UEFI (Unified Extended Firmware Interface) chip.
• When the computer is powered on and is going through POST (Power On Self
Test), then it is first loaded.
• The motherboard firmware wakes all the hardware when it starts.
• It ensures that all the components of a computer are operational.
• If all the ingredients are properly working, then it will run the boot-loader,
which will further load the operating system.
Department of Information Technology, VIIT, Pune-48
Components of System Software
Utility softwares
It is used to manage hardware and application software and also performs small
tasks.
These are those programs which are specifically designed for some particular
purpose like maintenance of the computer or diagnose any error in the computer.
Ex –
 firewall To protect us against external threats
 WinRAR - To compress the data
 Windows Disk Management. – To perform partition services
 iCare Data Recovery
 Disk Derangement, Little Snitch etc.,
 Antivirus

Department of Information Technology, VIIT, Pune-48


Language Processing activities

A language processor is a special type of software


program that has the potential to translate the
program codes into machine codes.

Department of Information Technology, VIIT, Pune-48


Language Processing activities

We can group Language Processing Activity in two category •


1) Program Generation Activity –This activity generates the program from its
specification.

Department of Information Technology, VIIT, Pune-48


Language Processing activities

2) Program execution Activity –This activity aims at bridging the execution gap by
organizing execution of a program written in a programming language on a
computer system.

Department of Information Technology, VIIT, Pune-48


Language Processing activities
Translation -
The program translation model bridges the execution gap by translating a program
written in PL,called the source program(SP),in to an equivalent program in the
machine or assembly language of the computer system,called target program

Department of Information Technology, VIIT, Pune-48


Components of System Software
Interpretation
interpretor reads the source program and stores in its memory.
• During interpretation it takes a source statement ,determines its meaning and
performs actions which implement it.
• This includes computational and input output actions.

Department of Information Technology, VIIT, Pune-48


Language Processing System

Department of Information Technology, VIIT, Pune-48


Language Processing System

• Linker
• The main function of the linker is to generate executable files.
• The linker takes the input as the object code which would be generated by a
compiler/assembler.
• The process of linking can be understood as a method to combine different
snippets of code in order to obtain executable code.
• There are two types of linkers available: Linkage Editor and Dynamic Linker.
• Linker also helps combine all the object modules.
• Linker is responsible to arrange the objects in the program’s address space.

Department of Information Technology, VIIT, Pune-48


Language Processing System

• Loader
• The main function of a loader is to load executable files to the main memory.
• It takes the executable files (generated by linker) as its input.
• It can be understood as a process of loading the executable codes into main
memory where it is executed further.
• There are 3 types of loaders: Absolute loading, Relocatable loading and
Dynamic run-time loading.
• It helps allocate the addresses to executable codes or files.
• It is also responsible to adjust the references that are used within the program.

Department of Information Technology, VIIT, Pune-48


Language Processing System

S.No. Linker Loader


1 A linker is an important utility program that A loader is a vital component of an
takes the object files, produced by the operating system that is accountable
assembler and compiler, and other code to for loading programs and libraries.
join them into a single executable file.
2 It uses an input of object code produced by It uses an input of executable files
the assembler and compiler. produced by the linker.
3 The foremost purpose of a linker is to The foremost purpose of a loader is to
produce executable files. load executable files to memory.
4 Linker is used to join all the modules. Loader is used to allocate the address
to executable files.
5 It is accountable for managing objects in the It is accountable for setting up
program’s space. references that are utilized in the
program.

Department of Information Technology, VIIT, Pune-48


Types of language Processors

1. Compiler
2. Interpreter
3. Assembler

Department of Information Technology, VIIT, Pune-48


Fundamentals of Assembly Language Programming

• Assembly language program consist of mnemonics that is translated into machine code.
• Assembly language is a low-level programming language for a computer or other
programmable device specific to a particular computer architecture
• Assembly language is converted into executable machine code by a utility program
referred to as an assembler like NASM, MASM, etc.
• A processor understands only machine language instructions, which are strings of 1's
and 0's.
• However, machine language is too obscure and complex for using in software
development.
• So, the low-level assembly language is designed for a specific family of processors that
represents various instructions in symbolic code and a more understandable form.
• Assembly language is also called as low-level language because it directly works with
the internal structure of CPU.

Department of Information Technology, VIIT, Pune-48


Fundamentals of Assembly Language Programming

• Mostly, programmers use high-level languages but, when more specific code is
required, assembly language is used.
• It uses opcode for the instructions. An opcode basically gives information about
the particular instruction.
• The symbolic representation of the opcode (machine level instruction) is
called mnemonics.
• Programmers use them to remember the operations in assembly language.
• For example ADD A,B
• Here, ADD is the mnemonic that tells the processor that it has to perform
addition function. Moreover, A and B are the operands. Also, SUB, MUL, DIVC,
etc. are other mnemonics.

Department of Information Technology, VIIT, Pune-48


Assembler
• Assembler is a Software that converts an assembly language code to machine
code.
• It takes basic Computer commands and converts them into Binary Code that
Processor can use to perform its Basic Operations.
• These instructions are assembly language.
• We can also name an assembler as the compiler of assembly language.

Department of Information Technology, VIIT, Pune-48


Assembler
• n assembly program can be divided into three sections −
• The data section,
• The bss section, and
• The text section.

• The data Section


• The data section is used for declaring initialized data or constants. This data
does not change at runtime. You can declare various constant values, file
names, or buffer size, etc., in this section.
• The syntax for declaring data section is −
• section.data

Department of Information Technology, VIIT, Pune-48


Assembler

• The bss Section


• The bss section is used for declaring variables. The syntax for declaring bss
section is −
• section.bss
• The text section
• The text section is used for keeping the actual code. This section must begin
with the declaration global _start, which tells the kernel where the program
execution begins.
• The syntax for declaring text section is −
• section.text global _start _start:

Department of Information Technology, VIIT, Pune-48


Assembler

• Comments
• Assembly language comment begins with a semicolon (;). It may contain any
printable character including blank. It can appear on a line by itself, like −
• ; This program displays a message on screen or, on the same line along with an
instruction, like −
• add eax, ebx ; adds ebx to eax

• Syntax of Assembly Language Statements


• [label] mnemonic [operands] [;comment]

Department of Information Technology, VIIT, Pune-48


A Simple Assembly scheme

• Assembly language statements are entered one statement per line. Each
statement follows the following format −
• Assembly Program:
• Label Op-code operand LC value(Location counter)
• JOHN START 200
• MOVER R1, ='3' 200
• MOVEM R1, X 201
• L1 MOVER R2, ='2' 202
• LTORG 203
• X DS 1 204
• END 205

Department of Information Technology, VIIT, Pune-48


A Simple Assembly scheme

• 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.
• DS(Data Space): It assigns a data space of 1 to Symbol X.
• END: It finishes the program execution.

Department of Information Technology, VIIT, Pune-48


A Simple Assembly scheme

[label] mnemonic [operands] [;comment]


INC COUNT ; Increment the memory variable COUNT
MOV TOTAL, 48 ; Transfer the value 48 in the memory variable TOTAL
ADD AH, BH ; Add the content of the BH register into the AH register
AND MASK1, 128 ; Perform AND operation on the variable MASK1 and 128
ADD MARKS, 10 ; Add 10 to the variable MARKS
X1 MOV AL, 10 ; Transfer the value 10 to the AL register

Department of Information Technology, VIIT, Pune-48


A Simple Assembly scheme

Compiling and Linking an Assembly Program in NASM


• Type the above code using a text editor and save it as hello.asm.
• Make sure that you are in the same directory as where you
saved hello.asm.
• To assemble the program, type nasm -f elf hello.asm
• If there is any error, you will be prompted about that at this stage.
Otherwise, an object file of your program named hello.o will be
created.
• To link the object file and create an executable file named hello,
type ld -m elf_i386 -s -o hello.o
• Execute the program by typing ./hello

Department of Information Technology, VIIT, Pune-48


Type of statements in Assembly scheme

• Imperative Statements Assembler Directives


• READ A Instructs the assembler to perform certain action
• PRINT Y during execution.
• ADD X,Y
• SUB A,B
• MOVER R1,3 Example – START
STOP
• Declarative statements
• DS - Declare storage
• DC - Declare constants
• Example
• A DS 1
• A DC ‘5’
• OR
• B DC ‘5’ Department of Information Technology, VIIT, Pune-48
Pass structure of Assemblers, Design of Two Pass Assembler.

• When you enter the as command, the assembler makes two passes
over the source program.
• First pass
During the first pass, the assembler checks to see if the instructions
are legal in the current assembly mode.
• Second pass
During the second pass, the assembler examines the operands for
symbolic references to storage locations and resolves these symbolic
references using information in the symbol table and produces the
object code.

Department of Information Technology, VIIT, Pune-48


Pass structure of Assemblers, Design of Two Pass Assembler.

Opcode table – translate Symbol table – stores


mnemonic opcodes into addresses assignmed to
machine language lables(symbol that represent
equivalent memory address)

Department of Information Technology, VIIT, Pune-48


Pass structure of Assemblers, Design of Two Pass Assembler.

Department of Information Technology, VIIT, Pune-48


Pass structure of Assemblers, Design of Two Pass Assembler.

Department of Information Technology, VIIT, Pune-48


Pass structure of Assemblers, Design of Two Pass Assembler.

• It generates instructions by evaluating the mnemonics (symbols) in operation


field and find the value of symbol and literals to produce machine code.
• If assembler do all this work in one scan then it is called single pass assembler,
otherwise if it does in multiple scans then called multiple pass assembler.
• Here assembler divide these tasks in two passes:
• Pass-1: (Analysis phase)
• Analysis phase reads the source program and splits it into multiple tokens and
constructs the intermediate representation of the source program.
• Checks for the syntax and semantic errors of a source program.
• Collects information about the source program and prepares the symbol table.
• Pass-2: (Synthesis phase)
– Generate object code by converting intermediate code
• Translates source statements into machine code and constants, thus filling the
allocated space with object code.
• Produces a file containing error
Department messages,
of Information if any have
Technology, occurred.
VIIT, Pune-48

You might also like