Introduction to various system programs such as Assembler, Macro processor, Loader, Linker, Compiler, Interpreter, Device Drivers, Operating system, Editors, Debuggers._9049ce67290423e469cbf393c1bded2e
Introduction to various system programs such as Assembler, Macro processor, Loader, Linker, Compiler, Interpreter, Device Drivers, Operating system, Editors, Debuggers._9049ce67290423e469cbf393c1bded2e
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
1.2.2 Assembler
Program in
Assembly Machine code
Language of Assembler for Machine A
Machine A
Machine A
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
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.
Machine B
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
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 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
Subroutine N
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
Operating System
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.
System Tools are not complete systems software; rather they assist in writing system or
application software and perform various actions on it.
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)
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.
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