You are on page 1of 15

Chapter 1: Systems Software

Topics in this Chapter:


Need for and Basics of Systems Software
Intro to various Systems Software:
o Translator
o Assembler, Cross-Assembler and Disassembler
o Compiler, Cross-Compiler and Decompiler
o Interpreters
o Pre-processors and Macro Processors
o Loaders and Linkers
o Device Drivers
o Operating System
o Various System Tools
Editors
Debuggers
Integrated Development Environment (IDE)
Profilers
Project Managers

1.1 Need for Systems Software

A computer understands only the language of binary 1s and 0s. To implement


even a simple function, several thousand lines of binary code may be required,
which is not practical for a computer programmer.

So, a semantic gap is said to exist between the application domain (suitable for a
programmer) and execution domain (used by the computer).
Semantic Gap

Application Execution
Domain Domain

Fig. 1.1 (a)

This semantic gap is made manageable by introduction of a new domain called


the Programming Language (PL) Domain.

Specification Gap Execution Gap

PL Domain Execution
Application Domain
Domain
Fig. 1.1
(b)

The software developer bridges the specification gap by specifying application


programs in terms of programming language i.e. a software developer converts
the specification of an application into a computer program.

The system programmer bridges the execution gap by designing system software
to interface with the machine, in machine language itself.
So, basically an application program is needed for a user to talk to his computer
and system software is needed for the computer to talk to its underlying machine
(in its machine language or assembly language).

1.2 Various Systems Software

1.2.1 Translator

A Translator is a system program that converts a program in one language to a program in


another language.

A Translator can be denoted by following symbol:


S
TTB
where S = Source Language
T = Target Language
B = Base Language in which the translator is written

Source Target
Language Translator Language
Program Program

Base Machine on
which Translator is
written

Fig. 1.2: Translator

For Example, we can write a program in Java that takes C++ source code as input and
generates its equivalent assembly language program as output, then its source is C++,
target is Assembly Language and its base language is Java.
1.2.2 Assembler

An Assembler is a translator denoted as follows:


A
TAA

That is, Assembler is a language translator which takes as input a program in assembly
language of machine A and generates its equivalent machine code for machine A, and the
assembler itself is written in assembly language of Machine A.

Imagine an 8086 ALP program (the actual assembler) that reads an input some other 8086
ALP program and generates its machine code for 8086 machine.

Program in
Assembly Machine code
Language of Assembler for Machine A
Machine A

Machine A

Fig. 1.3: Assembler

1.2.3 Cross-Assembler

A Cross-Assembler is a translator denoted as follows:


A
TAB

A Cross-Assembler runs on one machine, but assembles ALP of another machine and
generates machine code for that machine.
Program in
Assembly Machine code
Language of Cross- for Machine A
Machine A Assembler

Machine B

Fig. 1.4: Cross-Assembler

Imagine an ALP program (the actual assembler) running on a Windows machine. It takes
as input some 8086 ALP program and generates its machine code for 8086 machine. But
the main assembler still runs on Windows machine, even though source and target
languages are of a backward processor 8086. (Example: TASM programs running on
windows. TASM assembles and runs 8085 / 8086 code, on a windows machine)

So, for cross-assemblers to work, machine B must have a higher configuration than that
of machine A and must facilitate emulation of environment of machine A.

1.2.4 Disassembler

As the name suggests, it converts machine code of a particular machine back to its
assembly language. (Recall: reverse engineering).

This idea of reverse engineering is used to recover some lost source code file using its
object file.

1.2.5 Compiler

A Compiler is a language translator that takes as input a source program in some HLL
and converts it into a lower-level language (i.e. machine or assembly language).
Object File
HLL Source (for Machine
Code Compiler
A)

Machine A

Fig. 1.5: Compiler

So, an HLL program is first compiled to generate an object file with machine-level
instructions (i.e. compile time) and then instructions in object file are executed (i.e. run
time).

[Recall: Running C programs in Turbo C; first you compile the program, and then you
run it].

1.2.6 Cross-Compiler

A Cross-Compiler runs on one machine, but generates machine or assembly code for
another machine.

HLL Source Object File


Code Cross-Compiler (for Machine
A)

Machine B

Fig. 1.6: Cross-Compiler


1.2.7 Decompiler

Similar to Disassembler for Assembly Language, a Decompiler traces back the machine
or assembly code and converts it into source HLL program.

This reverse conversion is strictly dependent on how much information about source
HLL is present in the machine code (or assembly code).

1.2.8 Interpreters

Exam Question: Differentiate between Assemblers,


Compilers and Interpreters. (May 05, Dec 05 4M, June 07
5M)
[In this answer, students can include following points for
comparison: Definition, speed of execution, translation approach
(line-by-line or as a whole), whether program needs to be
translated for each run and whether an object file is created.
Finally, students can give an example of each at the end.]

An Interpreter is similar to a compiler, but one big difference is that it executes each line
of source code as soon as its equivalent machine code is generated. (This approach is
different from a compiler, which compiles the entire source code into an object file that is
executed separately).

If there are any errors during interpretation, they are notified immediately to the
programmer and remaining source code lines are not processed.

In case of a Compiler, all errors occurred during compile-time are notified collectively to
the programmer; the programmer then corrects the errors and re-compiles and executes
the code.

Since an Interpreter goes through all the compilation phases separately for each line,
speed of execution of a program is much slower than with a compiler.

Also, since it does not generate any object file, the entire code needs to be compiled
repeatedly for each run of the program (even if the source code is not modified).
But the main advantage with Interpreters is that, since it immediately notifies an error to
the programmer, debugging becomes a lot easier. Chain of errors can be avoided. For
example: spelling mistake in the name of a variable at the place of definition can be
corrected immediately, and does not result in multiple errors at places of usage of that
variable [This is a typical error that most novice and sometimes even expert programmers
make].

1.2.9 Pre-processors

A Pre-processor converts one HLL into another HLL.

Typically pre-processors are seen as system software used to perform some additional
functions (such as removal of white spaces and comments) before the actual translation
process can begin.

So, input and output of pre-processor is generally the same HLL, only some additional
functions have been performed on the source.

A Macro Processor is an example of pre-processor.

1.2.10 Macro Processor

A Macro is defined as a single-line abbreviation of a small sequence of statements.

A Macro Processor expands the macro calls and removes macro definitions from an as
input source code, which contains these macro definitions and calls.

Macros are used similar to functions, but they are much smaller (and less complex) than
functions.

When a function is called, program control is transferred to the location in memory where
the function is defined. When a macro is called, it gets expanded inline i.e. the macro call
is replaced by its corresponding set of statements.
(more on macros and macro processors in Chapter 3).

1.2.11 Linker

A Linker (or a Linkage Editor) takes the object file, loads and compiles the external sub-
routines from the library and resolves their external references in the main-program.

A Compiler generates an object file after compiling the source code. But this object file
cannot be executed immediately after it gets generated.

This is because the main program may use separate subroutines in its code (locally
defined in the program or available globally as language subroutines). The external sub-
routines have not been compiled with the main program and therefore their addresses are
not known in the program.

A Linker thus converts an object module into a load module (and an .exe file is
generated) that can be loaded in the main memory directly for execution.

Object Library
Code of
main
program

Object .exe
Code of Linke
file
Subroutine r
1
.
.
.

Object
Code of
Subroutine
N
Fig. 1.7: Linker
1.2.12 Loaders

Programmers usually define the program to be placed at some pre-defined location in the
memory. But this loading address given by the programmer may never be used, as it has
not been coordinated with the OS.

A Loader does the job of coordinating with the OS to get the initial loading address for
the program, prepares the program for execution (i.e. generates an .exe file) and loads it
at that address.

Also, during the course of its execution, a program maybe relocated to a different area of
main memory by the OS (when memory is needed for other programs). This may render
address-sensitive instructions useless (For example, load / store from a specific address in
the memory).

So, an important job of Loader is to modify these address-sensitive instructions, so that


they run correctly after relocation.

Run-time
user data
input

.exe Program
Loader loaded (or
file relocated) in
the main
memory
Operating
System

Fig. 1.8: Loader

(More on Loaders and Linkers in Chapter 4).


1.2.13 Device Drivers

A Device Driver is a system software that allows the OS and other applications to
communicate with a specific hardware device.

Every different hardware device can understand only its own low-level commands; A
Device Driver translates high-level commands by OS or other applications into machine
code instructions that are directly executable on the hardware device. (For example,
printf() function is translated into a sequence of machine code instructions for the
monitor to display the message given as its argument)

Device Drivers are OS-specific, since every OS has its own way of communicating with
the device.

Some generic device drivers (such as USB Port, Mouse or Keyboard drivers) are
integrated into all operating systems. Drivers for more advanced devices (like a game
joystick or a LAN card) are bundled with the product CD-ROM given by the
manufacturer.

1.2.14 Operating System

An operating system can be viewed as an integration of system programs that act as an


interface between the user and his computer.

An OS manages CPU and different hardware devices connected to the computer; it also
provides system calls for efficient execution of common services needed by the
applications.

A user talks to his computer either directly through OS or by using applications.


Although applications communicate directly to the hardware device they need, they often
make use of system calls provided by the OS.
1.2.15 System Tools

System Tools are not complete systems software; rather they assist in writing system or
application software and perform various actions on it.

Editors: Editors assist the programmer to write source code in a particular


language and enable them to manage the source code through files.

In addition, most editors add basic features like Save-As, Find-Replace, Cut-
Copy-Paste to make manipulation of source code easy. (E.g. Notepad is the most
basic editor and can be used for many languages)

Debuggers: A debugger presents compiler-generated errors in a human-readable


format and helps the programmer in finding and correcting the errors in the source
code.

A Debugger also provides the facility of Breakpoints i.e. the programmer defines
breakpoints at some specific locations that are likely to generate errors. The
debugger breaks the execution at those points and lets the programmer check
values of intermediate variables and function arguments to determine the exact
cause of an error.

Breakpoints are very useful in determining the cause of a logical or a functional


error.

Integrated Development Environment (IDE): IDEs are application programs


that integrate various systems software (like compiler, assembler, debugger etc)
together to enable the programmers to write source code in a specific HLL.

IDEs also add many other functions to make writing source code much easier and
faster. For example, code templates for different types of forms in VB or
ASP.NET or auto-completion of braces of program blocks.
Examples of IDEs include Turbo C++ (for C/C++), Kawa, Eclipse, NetBeans and
others (for Java), Basic4GL (for graphics programming using OpenGL).

Profilers: Profilers perform dynamic program analysis i.e. analysis of program


behavior using statistics collected during run-time.

The main use of dynamic program analysis is to spot sections of code which can
be optimized for execution or for comparing different implementations of same
function to see which one executes more efficiently.

Profilers can also be used for space and time complexity analysis of an algorithm.

Profilers can be of different types: A Code Profiler measures only frequency


and duration of function calls. Memory Profilers are capable of gathering
extensive performance data. An Instruction Set Simulator can measure totality of
programs behavior from invocation to termination.

Project Managers: Project Managers are not essentially systems software; rather
they are project management tools.

Project Managers help coordinate different versions of same source code


produced by different team members in a software project. They also maintain
history of changes to different sets of files, so that a coherent version of program
under development can be maintained.
1.3 Chapter Summary

System programs are needed because it is impractical for a programmer to write,


debug and manage huge programs in binary 0s and 1s.
Translators convert code of one language to another.
Assembler translates assembly language to machine code; Disassembler performs
the reverse function.
Compiler translates HLL code into machine code; Decompiler uses source HLL
information in machine code to do reverse of compilation process.
Interpreters compile programs line-by-line. So, they are traditionally slow. But a
main advantage is that chain of errors can be avoided.
Pre-processors are not translators; input and output languages are the same, only
input source is modified to eliminate elements like whitespaces and comments.
Linker links object files of various subroutines with that of main program and
generates .exe file. Loader manages allocation and relocation of this .exe file in
main memory.
Device Drivers convert high-level commands from OS (or other applications) into
machine code instructions for direct execution on the device.
Operating System is an integration of various system programs that act as an
interface between a user and his computer.
Editors help us write source code of a program; Debuggers help us find and
correct errors in program. IDEs include various tools and advanced functions for
program development.
Profilers are program stats collectors used for run-time complexity analysis.
Project management software helps organize files from different team members
working on same project, into a single coherent system.

1.4 Expected Viva Questions

Q.1) What are system programs? Why do we need them?

Q.2) What is a Cross-Assembler? What are Cross-Compilers? Give an example of


each.
Q.3) How are Compilers and Interpreters different as system programs?

Q.4) What is the output of pre-processors?


(Hint: Here, the expected answer is that the output language is same as the input
language, only the input code is processed to remove unwanted elements)

Q.5) What is a Linkage Editor? What are functions of loaders?


(For details on functions of a loader, see chapter 4)

Q.6) Why are device drivers called as system software?

Q.7) What is an Operating System?

Q.8.) Give examples of Profiler software and Project Management software.

You might also like