SYSTEM PROGRAMMING
Chapter one:
Introduction to System Programming
After you have studied this unit, you will be able to:
• Know the difference between Application Programs and System Programs
• Understand the Hierarchies of Computer System
• Know about the System Programming Languages
• Explain about the Machine Structures and developing phases of programming
system
Introduction
A modern software application typically needs to manage both private and system
resources. Private resources are its own data, such as the values of its internal data
structures and system resources are things such as files, screen displays, and network
connections. Threads and sub processes are also system resources. Modern operating
systems prevent application software from managing system resources directly, instead
providing interfaces that these applications can use for managing such resources.
Although it may seem that functions from the C standard library such as fprintf() access
files directly, they do not; they make calls to system routines that do the work on their
behalf.
Definition
Systems Programming is the design and implementation of system software. System
Software: a variety of programs supporting the operation of a computer. Typical system
programs: OS, Complier, Assembler (Linker, Loader, Macro Processors), Text Editor,
Debugger…
Application software focuses on an application or problem to be solved but, systems
Programs were developed to make computers better adaptable to the needs of the users.
COMPILED BY: EPHREM W. 1
SYSTEM PROGRAMMING
One characteristic in which most system software differ from application software is
machine dependency, free users from knowing the detail of machines.
Computer System Hierarchies
Figure1.1: Foundations of system programming
✓ Compilers are system programs that accept human like language and translate
them into machine languages.
✓ Loaders prepare machine languages for execution. Macro processors allow
programs to use abbreviations.
✓ Programming Languages: Machine Language (ML)->Assembly Language (AL)->
HighLevel Programming Language (HL)
• ML: machine code, i.e, binary code, e.g., 01100110
• AL: mnemonic instructions, e.g., STO (Store)
• HL: statements, e.g. if … Then … else …
✓ Programs in High Level Language is converted to Object Code in Machine
Language by (Compiler)
✓ Programs in Assembly language is converted to Object Code in Machine
Language by (Assembler)
COMPILED BY: EPHREM W. 2
SYSTEM PROGRAMMING
Relations
✓ Type and modify a program in HL or AL (by an editor)
✓ Translate it into object code in ML (by a compiler or assembler)
✓ Load it into memory for execution (by a linker and/or loader)
✓ Execute it on CPU (by an OS)
✓ Detect errors in the code (by a debugger)
✓ All the processes and programs are run under and controlled by an OS such as
Windows or Linux.
✓ IDE (Integrated Development Environment)
Machine Structure
✓ One characteristic in which most system software differs from application
software is machine dependency.
• Assembler: instruction format, addressing modes
• Compiler: registers (number, type), machine instructions
• OS: all of the resources of a computing system.
✓ Of course, some aspects of system software are machine independent.
• General design and logic of an assembler
• Code optimization in a compiler
• Linking of independently assembled subprograms.
COMPILED BY: EPHREM W. 3
SYSTEM PROGRAMMING
Figure 1.2: General Hardware Organization of a Computer System
Memory is the device where information is stored. Information in memory is
coded into group of bits that may be interpreted as a characters, words or bytes. A code
is a set of rules for interpreting a group of bits. Eg. BCD-code for decimal digits, ASCII-
code for characters, specific processor operation codes – for instruction. Memory
locations are specified by address where each address identifies a specific word, byte …
The content of a word may be interpreted as a data (value to be operated on) or
instruction (operation to be performed).
A processor a device that performs a sequence of operations specified by
instruction in the memory. Processors operate on the information stored. I/O processors
are concerned with the transfer of data between memory and peripheral devices. The
Central Processing Units (CPUs) are concerned with the manipulation of data stored in
memory. The I/O processors execute instruction in the memory; they are generally
activated by a command from CPUs. Typically, this consists an “execute I/O” instruction
whose argument is the address of the start of the I/O program.
COMPILED BY: EPHREM W. 4
SYSTEM PROGRAMMING
Evolution of the Components of a Programming system
The programming system has undergone a series of development phases,
basically:
• Basic Machine
• Mnemonic(Symbol)
• High level programming
Basic Machine
In this development phase the programmer has a basic machine at his disposal
that interprets instruction by hardware. Then a programmer writes series of 0s and 1s
(machine language) place them into memory. Finally, press a button and start executing.
This approach is not suitable as it is difficult to read/write in machine language. Hence,
programmers have to find a better remedy (mnemonic for each instruction).
Mnemonics (Symbol)
As a solution to the difficulty of using machine language, mnemonic symbols or
Assembly language was introduced. Assemblers were written to automate the
translation of assembly language to machine language. Assembler converts source
program to object program and every time a program is executed an assembler has to
assemble and pass the control residing in core memory. Wastes memory and translation
time due to retranslation for every execution.
Loader: a program that places program into memory and prepares them for execution.
Minimizes usage of core memory, loader is much smaller than assembler. Avoids re-
translation for each execution. Assembler translates the symbols (once) and stores the
output in secondary memory. Many programmers wrote essentially the same program.
This led to development of ready-made programs or packages written by computer
manufacturers or users. As programs got sophisticated users wanted to mix ready-made
programs and with their own. Users can create main program that calls several other
programs (subroutines; body of computer instructions designed to be used by other
COMPILED BY: EPHREM W. 5
SYSTEM PROGRAMMING
routines to accomplish a task). Closed and open (macro) subroutines: transfer control
to subroutine vs insert the subroutine into the main program.
Relocation: is the process of assigning load addresses to various parts of a program
and adjusting the code and data in the program to reflect the assigned addresses.
Relocating loaders perform:
• Allocate space in memory for programs (allocation)
• Resolve symbolic references between objects decks (linking)
• Adjust all address dependent locations such as address constants to correspond
to allocated space (relocation)
• Physically place the machine instruction and data into memory (loading)
Macros allows programmers to define an abbreviation of part of a program that will be
used now and again in the program. Macro processor: Treats identical parts of a
program defined by the abbreviation as macro definition and saves it. Substitutes all
occurrences of the abbreviation (macro call).
High level Programming
User problems became more categorized into areas such as scientific, business
and statistical problems: specialized languages (high level programming) were
developed. Examples: FORTRAN, COBOL, ALGOL, PL/I. And they are processed by
compilers and interpreters. A compiler is a program that accepts program written by
high level language and produces an object program. Same name like FORTRAN is often
used for both the language and its compiler. An interpreter is a program that appears
to execute a source program like a machine language.
COMPILED BY: EPHREM W. 6
SYSTEM PROGRAMMING
Summary
The major components of a programming system are:
1. Assembler
Input to an assembler is an assembly language program. Output is an object program
plus information that enables the loader to prepare the object program for execution
2. Macro Processor
A macro call is an abbreviation for some code. A macro definition is a sequence of code
that has a name (macro call). A macro processor is a program that substitutes and
specializes macro definitions for macro calls.
3. Loader
A loader is a routine that loads an object program and prepares it for execution.
4. Compilers
A compiler is a program that accepts a source program "in a high-level language" and
produces a corresponding object program.
5. Operating System
An operating system is concerned with the allocation of resources and services, such as
memory, processors, devices and information.
END OF CHAPTER ONE!
COMPILED BY: EPHREM W. 7