0% found this document useful (0 votes)
4 views

Introduction to various system programs such as Assembler, Macro processor, Loader, Linker, Compiler, Interpreter, Device Drivers, Operating system, Editors, Debuggers._9049ce67290423e469cbf393c1bded2e

Chapter 1 discusses systems software, which bridges the gap between application programs and machine language, highlighting the need for various system programs such as assemblers, compilers, interpreters, and device drivers. It explains the roles of translators, linkers, loaders, and the operating system in managing hardware and facilitating communication between users and computers. The chapter concludes with a summary of the functions of system tools like editors and debuggers, emphasizing their importance in software development.

Uploaded by

Omkar Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Introduction to various system programs such as Assembler, Macro processor, Loader, Linker, Compiler, Interpreter, Device Drivers, Operating system, Editors, Debuggers._9049ce67290423e469cbf393c1bded2e

Chapter 1 discusses systems software, which bridges the gap between application programs and machine language, highlighting the need for various system programs such as assemblers, compilers, interpreters, and device drivers. It explains the roles of translators, linkers, loaders, and the operating system in managing hardware and facilitating communication between users and computers. The chapter concludes with a summary of the functions of system tools like editors and debuggers, emphasizing their importance in software development.

Uploaded by

Omkar Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter 1: Systems Software

Topics in this Chapter:


Concept of System Software,
Goals of system software,
system program and system programming,
Introduction to various system programs such as
• Assembler,
• Macro processor,
• Loader,
• Linker,
• Compiler,
• Interpreter,
• Device Drivers,
• Operating system,
• Editors,
• Debuggers..

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).
This semantic gap is made manageable by introduction of a new domain called
the Programming Language (PL) Domain.
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.
Specification Gap Execution Gap

PL Domain Execution
Application Domain
Domain
Fig. 1.1 (b)
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.

Source Language Target Language


Program Translator Program

Base Machine on which


Translator is written
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

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 theassembler
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 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 Code (for Machine A)
Compiler

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.4 Cross-Compiler

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

HLL Source Code Object File


Cross-Compiler (for Machine A)

Machine B

Fig. 1.6: Cross-Compiler


1.2.5 Interpreters

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].

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.

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).
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 Code of Library


main program

Object Code of .exe file


Subroutine 1 Linker

.
.
.

Object Code of
Subroutine N

Fig. 1.7: Linker

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 file Program loaded


Loader (or relocated) in
the main memory

Operating System

Fig. 1.8: Loader

(More on Loaders and Linkers in Chapter 4).

1.2.6 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.

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.
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).
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?

You might also like