0% found this document useful (0 votes)
3 views20 pages

Summarize System Programming Note

System programming focuses on creating software that interacts directly with computer hardware, requiring a deep understanding of hardware specifics. It typically involves low-level programming languages and includes tasks such as operating system management and resource allocation. Assembly languages, which are low-level and machine-dependent, are used for efficient hardware communication, while operating systems manage software execution, I/O operations, and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views20 pages

Summarize System Programming Note

System programming focuses on creating software that interacts directly with computer hardware, requiring a deep understanding of hardware specifics. It typically involves low-level programming languages and includes tasks such as operating system management and resource allocation. Assembly languages, which are low-level and machine-dependent, are used for efficient hardware communication, while operating systems manage software execution, I/O operations, and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DEFINITION

System programming is the activity of programming system software. The primary

distinguishing characteristic of systems programming when compared to application

programming is that application programming aims at producing software which provides

services to the user (e.g. word processor, Spreadsheets, databases, Accounting packages)

Systems programming aims at producing software which provides services to the computer

hardware (e.g. disk defragmenter, Operating Systems).

It also requires a greater degree of hardware awareness that is to say it is machine dependent and

the programmer needs to know the hardware within which the software will operate

BRIEF OVERVIEW OF SYSTEM PROGRAMMING

In system programming more specifically:

• The programmer will make assumptions about the hardware and other properties of the

system that the program runs on, and will often exploit those properties (for example by

using an algorithm that is known to be efficient when used with specific hardware)

• Usually a low-level programming language or programming language dialect is used and

does the following:

 Operate in resource-constrained environments

 Is very efficient and has little runtime overhead

 Has a small runtime library, or none at all

 Allows for direct and "raw" control over memory access and control flow

 Let the programmer write parts of the program directly in assembly language

1
• Debugging can be difficult if it is not possible to run the program in a debugger due to resource

constraints. Running the program in a simulated environment can be used to reduce this problem.

System Programming and Application Programming

System Programming Application Programming


Low level Language Both high level and low level language
Machine dependence Machine independence
For system application like O.S For user application like firefox, games e.t.c
Require Assembler Require compiler and interpreter

What Is an Assembly Language?

An assembly language is a type of low-level programming language that is intended to

communicate directly with a computer’s hardware. Unlike machine language, which consists of

binary and hexadecimal characters, assembly languages are designed to be readable by humans.

Today, assemble languages are rarely written directly, although they are still used in some niche

applications such as when performance requirements are particularly high.

Assembler translates or compiles assembly language code into machine code for execution

Types of Assemblers

1) A One-pass Assembler: One that performs all its functions by reading the source files

once.

2) A Two-Pass Assembler: One that reads the source files twice.

3) A Resident Assembler: One that is permanently loaded in memory. Typically such an

assembler resides in ROM, is very simple (supports only a few directives and no macros),

and is a one-pass assembler.

2
4) A Macro-Assembler: One that supports macros

5) A Cross-Assembler: An assembler that runs on one computer and assembles programs for

another. Many cross-assemblers are written in a higher-level language to make them

portable. They run on a large machine and produce object code for a small machine.

6) A Meta-Assembler: One that can handle many different instruction sets.

7) A Disassembler: This, in a sense, is the opposite of an assembler. It translates machine

code into a source program in assembler language

Assembly Language vs. High-Level Language


Assembly Language High-Level language

Assembly language is machine-dependent. It A high-level language is machine-independent. It


depend on computer architecture does not dependent on the computer’s architecture.
Example: C, C++, Python, Javascript.

The assembly language requires an A high-level language conversion requires the use of
assembler to convert. an interpreter or compiler.

It is closely related to hardware and is thus It has no hardware interactions and is only used to
used to write hardware programs. write software application programs.

Faster program execution. Program execution is slow.

Operating system

An operating system (commonly abbreviated computer system that is responsible for the

management and coordination of activities and the sharing of the limited resources of the

computer. The operating system acts as a host for applications that are run on the machine.

3
Functions of an Operating System

An operating system has three main functions:

i. Manages the software

ii. Provide basis for application program

iii. Acts as an intermediary between the computer and the hardware

Operating Systems Services

Following are the five services provided by an operating systems to the convenience of the users.

Program Execution

The purpose of computer systems is to allow the user to execute programs. So the operating

systems provide an environment where the user can conveniently run programs. The user does

not have to worry about the memory allocation or multitasking or anything. These things are

taken care of by the operating systems.

Running a program involves the allocating and de-allocating memory, CPU scheduling in case of

4
multi-process. These functions cannot be given to the user-level programs. So user-level

programs cannot help the user to run programs independently without the help from operating

systems.

I/O Operations

Each program requires an input and produces output. This involves the use of I/O. The operating

systems hides the user the details of underlying hardware for the I/O. All the user sees is that the

I/O has been performed without any details. So the operating systems by providing I/O makes it

convenient for the users to run programs. For efficiently and protection users cannot control I/O

so this service cannot be provided by user level programs.

File System Manipulation

The output of a program may need to be written into new files or input taken from some files.

The operating systems provide this service. The user does not have to worry about secondary

storage management. User gives a command for reading or writing to a file and sees his her task

accomplished. Thus operating systems make it easier for user programs to accomplish their task.

Memory Management

The operating system manage the memory through

i. Keeping track of which parts of memory are currently being used and by whom.

ii. Deciding which processes and data to move into and out of memory.

iii. Allocating and de-allocating memory space as needed.

Process, Process State, Scheduler and Thread

5
Process - a program in execution. A program loaded in the memory which is currently in

execution is called a process. We have two types of processes

I. Operating system processes

II. User processes

OS processes execute system code while user processes execute user codes. A process is made

up of single or multiple threads.

Process State

Process state is the current activity of such a process. A process may be in any of the following

states:

1) New: the process is being created

2) Running: Instructions are being executed

3) Waiting: process is waiting for some events to occur (such as I/O completion or reception of

signal)

4) Ready: the process is waiting to be assigned to a processor.

5) Terminate: the process has finished execution

6
Scheduler

A scheduler is software that helps schedule the processes in an operating system. It helps to keep

all computer resources busy and allows multiple users to share system resources effectively

Process Scheduling is responsible for selecting a processor process based on a scheduling

method as well as removing a processor process.

Types of Process Schedulers

 Long-Term Scheduler or Job Scheduler. The job scheduler is another name for Long-

Term scheduler. ...

 Short-Term Scheduler or CPU Scheduler. CPU scheduler is another name for Short-Term

scheduler. ...

7
 Medium-Term Scheduler. The switched-out processes are handled by the Medium-Term

scheduler.

Interrupt

An interrupt is a signal emitted by a device attached to a computer or from a program within the

computer. It requires the operating system (OS) to stop and figure out what to do next. An

interrupt temporarily stops or terminates a service or a current process.

An interrupt is a hardware-provided or software feature which causes the currently running task

to be suspended and program control is handed to a predefined interrupt handling routine.

Thread

A thread is unit of execution in a process, with its own program counter that keeps track of

which instruction to execute next, system registers which hold its current working variables and

stack which contains the execution history. Each thread belongs to exactly one process and no

thread can exist outside a process. Each thread represents a separate flow of control.

Stages of Translation
1. Lexical analysis
2. Syntax analysis
3. Semantic analysis
4. Intermediate code generation
5. Code Optimization
6. Code generation

Lexical analysis

This is the initial part of reading and analysing the program text: The text is read and divided into
tokens, each of which corresponds to a symbol in the programming language, e.g., a variable

8
name, keyword or number.
Syntax analysis

It processes the tokens, synthesized by the lexical analyzer, to determine the syntactic structure
of an input statement. This process is known as parsing. Output of the parsing step is a
representation in the form of syntax tree.

Semantic analysis

This phase checks the source program for semantic errors and gathers type of information for the
subsequent phase.

Intermediate code generation

After syntax and semantic analysis, some compilers generate an explicit intermediate
representation of the source program. It can have a variety of forms. This form called three-
address code. It consists of sequence of instructions, each of which has at most three operands.

What are the formats of Intermediate code?

1. Three address code


2. Postfix Notation
3. Syntax tree notation

Code Optimization

The next phase does code optimization of the intermediate code. Optimization can be assumed as
something that removes unnecessary code lines, and arranges the sequence of statements in order
to speed up the program execution without wasting resources (CPU, memory).

9
Utility Software

The Utility Software is system software that helps to maintain the proper and smooth functioning

of a Computer System. It assists the Operating System to manage, organize, maintain, and

optimize the functioning of the computer system.

Utility Software performs certain tasks like virus detection, installation, and uninstallation, data

backup, deletion of unwanted files, etc. Some examples are antivirus software, file management

tools, compression tools, disk management tools, etc.

Several types of utility software are as follows:

 Antivirus.

 File Management System.

 Disk Management tools.

 Compression tools.

 Disk cleanup tool.

 File Management System.

 Disk Defragmenter.

 Backup utility.

Kernel is responsible for maintaining all the important abstractions of the operating system,

including such things as virtual memory and processes;

10
System libraries define a standard set of functions through which applications can interact with

the kernel, and which implement much of the operating system functionality that does not need

full privileges of kernel code;

System utilities are programs that perform individual, specialized management tasks

ASSEMBLER DIRECTIVES

Assembler directives are pseudo instructions, they provide instructions to the assembler itself

and they are not translated into machine operation codes. Example for SIC assembler directive

• START : specify name & starting address

• END : end of source program, specify the first execution instruction

• BYTE,

• WORD,

• RESB,

• RESW

• End of record : null char (00)

• End of file : zero- length record

11
Sample Assembly Code

FUNCTIONS INCLUDE:

1. Converting mnemonic operation codes to their machine language equivalents

2. Converting symbolic operands to their equivalent machine addresses

3. Deciding the proper instruction format

4. Converting the data constants to internal machine representations

Processor Registers

There are ten 32-bit and six 16-bit processor registers in IA-32 architecture. The registers are
grouped into three categories −

12
 General registers,
 Control registers, and
 Segment registers.

The general registers are further divided into the following groups −

 Data registers,
 Pointer registers, and
 Index registers.

1. Data Registers

Four 32-bit data registers are used for arithmetic, logical, and other operations. These 32-
bit registers can be used in three ways −

 As complete 32-bit data registers: EAX, EBX, ECX, EDX.

Some of these data registers have specific use in arithmetical operations.

AX is the primary accumulator; it is used in input/output and most arithmetic


instructions. For example, in multiplication operation, one operand is stored in EAX or
AX or AL register according to the size of the operand.

BX is known as the base register, as it could be used in indexed addressing.

CX is known as the count register, as the ECX, CX registers store the loop count in
iterative operations.

DX is known as the data register. It is also used in input/output operations. It is also


used with AX register along with DX for multiply and divide operations involving large
values.

2. Pointer Registers

The pointer registers are 32-bit EIP, ESP, and EBP registers and corresponding 16-bit
right portions IP, SP, and BP. There are three categories of pointer registers −

13
 Instruction Pointer (IP) − The 16-bit IP register stores the offset address of the
next instruction to be executed. IP in association with the CS register (as CS:IP)
gives the complete address of the current instruction in the code segment.
 Stack Pointer (SP) − The 16-bit SP register provides the offset value within the
program stack. SP in association with the SS register (SS:SP) refers to be current
position of data or address within the program stack.
 Base Pointer (BP) − The 16-bit BP register mainly helps in referencing the
parameter variables passed to a subroutine. The address in SS register is
combined with the offset in BP to get the location of the parameter. BP can also
be combined with DI and SI as base register for special addressing.

3. Index Registers

The 32-bit index registers, ESI and EDI, and their 16-bit rightmost portions. SI and DI,
are used for indexed addressing and sometimes used in addition and subtraction. There
are two sets of index pointers −

 Source Index (SI) − It is used as source index for string operations.


 Destination Index (DI) − It is used as destination index for string operations.

4. Control Registers

The 32-bit instruction pointer register and the 32-bit flags register combined are
considered as the control registers.

Many instructions involve comparisons and mathematical calculations and change the
status of the flags and some other conditional instructions test the value of these status
flags to take the control flow to other location.

The common flag bits are:

 Overflow Flag (OF) − It indicates the overflow of a high-order bit (leftmost bit)
of data after a signed arithmetic operation.
 Direction Flag (DF) − It determines left or right direction for moving or
comparing string data. When the DF value is 0, the string operation takes left-to-
right direction and when the value is set to 1, the string operation takes right-to-
left direction.
 Interrupt Flag (IF) − It determines whether the external interrupts like keyboard
entry, etc., are to be ignored or processed. It disables the external interrupt when
the value is 0 and enables interrupts when set to 1.

14
 Trap Flag (TF) − It allows setting the operation of the processor in single-step
mode. The DEBUG program we used sets the trap flag, so we could step through
the execution one instruction at a time.
 Sign Flag (SF) − It shows the sign of the result of an arithmetic operation. This
flag is set according to the sign of a data item following the arithmetic operation.
The sign is indicated by the high-order of leftmost bit. A positive result clears the
value of SF to 0 and negative result sets it to 1.
 Zero Flag (ZF) − It indicates the result of an arithmetic or comparison operation.
A nonzero result clears the zero flag to 0, and a zero result sets it to 1.
 Auxiliary Carry Flag (AF) − It contains the carry from bit 3 to bit 4 following
an arithmetic operation; used for specialized arithmetic. The AF is set when a 1-
byte arithmetic operation causes a carry from bit 3 into bit 4.
 Parity Flag (PF) − It indicates the total number of 1-bits in the result obtained
from an arithmetic operation. An even number of 1-bits clears the parity flag to 0
and an odd number of 1-bits sets the parity flag to 1.
 Carry Flag (CF) − It contains the carry of 0 or 1 from a high-order bit (leftmost)
after an arithmetic operation. It also stores the contents of last bit of a shift or
rotate operation.

COMPONENTS OF ASSEMBLY LANGUAGE

Syntax

When writing any code in any program language, there is an observable, specific order of rules
that must be followed to allow a compiler to execute the code without error. These rules are
defined as the syntax, and they contain criteria such as the maximum number of allowable
characters, what characters code lines must start with, or what certain symbols "i.e. a semi-
colon" means.

Label

A label is a symbol that represents the address where an instruction or data is stored. It's purpose
is to act as the destination when referenced in a statement. Labels can be used anywhere an
address can be used in assembly languages. A symbolic label consists of an identifier followed
by a colon, while numeric labels consist of a single digital followed by a colon.

15
Operators

Also referred to as commands, operators are logical expressions that occur after the label field. In
addition, it must be preceded by at least one white-space character. Operators can either be
opcode or directive. Opcode correspond directly to machine instructions, and the operation code
includes any register name associated with the instruction. Alternatively, directive operation
codes are instructions known by the assembler.

Registers:
The processor can operate on numeric values (numbers) but must first save somewhere. The data
is now kept in memory, inside the instruction opcode, or in special on-chip memory placed
directly in the processor, known as registers. To work with a value, users don’t need to address it
by address; instead, special mnemonic “names” such as ax on x86, A on Z80, or r0 on ARM are
in use

Directive

Directives are instructions to the assembler that tell what actions must take place during the
assembly process. Directives have the importance of declaring or reserving memory for
variables; these variables can be recalled later in processes to perform more dynamic functions.
Directives are also used to break programs into different sections.

16
Here is the list of the op codes we will be using to construct assembly language programs.

17
BATCH PROCESSING

BATCH Processing can be defined as executing a series of non interactive jobs all at one time.
The term originated in the days when users entered programs on punch cards. They would give a
batch of these programmed cards to the system operator, who would feed them into the
computer. Batch jobs can be stored up during working hours and then executed during the
evening or whenever the computer is idle. Batch processing is particularly useful for operations
that require the computer or a peripheral device for an extended period of time. Once a batch job
begins, it continues until it is done or until an error occurs. Note that batch processing implies
that there is no interaction with the user while the program is being executed. An example of
batch processing is the way that credit card companies process billing or Power Holding
Company processes their bills . The customer does not receive a bill for each separate credit card
purchase or meter reading but one monthly bill for all of that month. The bill is created through
batch processing, where all of the data are collected and held until the bill is processed as a batch
at the end of the billing cycle. The opposite of batch processing is transaction processing or
interactive processing. In interactive processing, the application responds to commands as soon
as you enter them.

18
TIME SHARING This involves the CPU allocating individual slices of time to a number of users
on the computer system. As the number of users increases the response time for each terminal
declines. The speed of the CPU compared to that of the VDU and terminal is so much faster that
it gives the user the impression that they are the sole user of the system
MULTIPROGRAMMING MULTITASKING AND MULTIPROCESSING SYSTEMS
Multiprograming: In multiprogramming systems, the running task keeps running until it
performs an operation that requires waiting for an external event (e.g. reading from a tape) or
until the computer's scheduler forcibly swaps the running task out of the CPU.
Multiprogramming systems are designed to maximize CPU usage. Multitasking: In computing,
multitasking is a method by which multiple tasks, also known as processes, share common
processing resources such as a CPU. In the case of a computer with a single CPU, only one task
is said to be running at any point in time, meaning that the CPU is actively executing instructions
for that task. Multitasking solves the problem by scheduling which task may be the one running
at any given time, and when another waiting task gets a turn. The act of reassigning a CPU from
Multiprocessing: Multiprocessing is a generic term for the use of two or more central processing
units (CPUs) within a single computer system. There are many variations on this basic theme,
and the definition of multiprocessing can vary with context, mostly as a function of how CPUs
are defined (multiple cores on one die, multiple chips in one package, multiple packages in one
system unit, etc.). Multiprocessing sometimes refers to the execution of multiple concurrent
software processes in a system as opposed to a single process at any one instant. one task to
another one is called a context switch.

REAL TIME OPERATING SYSTEM Real-Time Operating System (RTOS; generally


pronounced as "R-toss") is a multitasking operating system intended for real-time applications.
Such applications include embedded systems (programmable thermostats, household appliance
controllers), industrial robots, spacecraft, industrial control and scientific research equipment. A
RTOS facilitates the creation of a real-time system, but does not guarantee the final result will be
realtime; this requires correct development of the software. An RTOS does not necessarily have
high throughput; rather, an RTOS provides facilities which, if used properly, guarantee deadlines
can be met generally (soft real-time) or deterministically (hard real-time). An RTOS will

19
typically use specialized scheduling algorithms in order to provide the real-time developer with
the tools necessary to produce deterministic behavior in the final system. An RTOS is valued
more for how quickly and/or predictably it can respond to a particular event than for the given
amount of work it can perform over time. Key factors in an RTOS are therefore minimal
interrupt latency and a minimal thread switching latency. An early example of a large-scale real-
time operating system can be identified in the some Airline reservation operating in Nigeria and
overseas such as Transaction Processing Facility developed by American Airlines and IBM for
the Sabre Airline Reservations System. Others may be found in some communication companies

20

You might also like