Unit 1 Spos Notes
Unit 1 Spos Notes
Unit 1 Spos Notes
UNIT – I
1. INTRODUCTION :
System programming involves designing and writing computer programs that allow the
computer hardware to interface with the programmer and the user, leading to the effective
execution of application software on the computer system. Typical system programs
include the operating system and firmware, programming tools such as compilers,
assemblers, I/O routines, interpreters, scheduler, loaders and linkers as well as the
runtime libraries of the computer programming languages.
i. Text Editor :
A text editor is a type of program used for editing plain text files. Such programs are
sometimes known as "notepad" software, following the Microsoft Notepad.
ii. Loaders :
a loader is the part of an operating system that is responsible for
loading programs and libraries. It is one of the essential stages in the process of
starting a program, as it places programs into memory and prepares them for
execution. Loading a program involves reading the contents of the executable
file containing the program instructions into memory, and then carrying out other
required preparatory tasks to prepare the executable for running. Once loading is
complete, the operating system starts the program by passing control to the loaded
program code.
iii. Linkers :
Linker is a program that takes one or more objects generated by a compiler and
combines them into a single executable program. Loader is the part of an
operating system that is responsible for loading programs from executables (i.e.,
executable files) into memory, preparing them for execution and then executing them.
iv. Assembler :
Assembler is a computer program which is used to translate program written in
Assembly Language in to machine language. The translated program is called as
object program. Assembler checks each instruction for its correctness and generates
diagnostic messages, if there are mistakes in the program. Various steps of
assembling are:
v. Compiler :
vi. Interpreter :
The basic purpose of interpreter is same as that of complier. In compiler, the program
is translated completely and directly executable version is generated. Whereas
interpreter translates each instruction, executes it and then the next instruction is
translated and this goes on until end of the program. In this case, object code is not
stored and reused. Every time the program is executed, the interpreter translates each
instruction freshly. It also has program diagnostic capabilities. However, it has some
disadvantages as below:
1. Instructions repeated in program must be translated each time they are executed.
2. Because the source program is translated fresh every time it is used, it is slow
process or execution takes more time. Approx. 20 times slower than complier.
A macro processor is a program that copies a stream of text from one place to
another, making a systematic set of replacements as it does so. Macro processorsare
often embedded in other programs, such as assemblers and compilers. Sometimes
they are standalone programs that can be used to process any kind of text.
viii. Debugger :
1. Instruction interpreter
2. Location counter
3. Instruction register
4. Working register
5. General register
The Instruction Interpreter Hardware is basically a group of circuits that perform the operation
specified by the instructions fetched from the memory.
The Location Counter can also be called as Program/Instruction Counter simply points to the
current instruction being excuted.
The working registers are often called as the "scratch pads" because they are used to store
temporary values while calculation is in progress.
This CPU interfaces with Memory through MAR & MBR
MAR (Memory Address Register) - contains address of memory location (to be read from or
stored into)
MBR (Memory Buffer Register) - contains copy of address specified by MAR
Memory controller is used to transfer data between MBR & the memory location specified by
MAR
The role of I/O Channels is to input or output information from memory.
Machine language :
Below is an example of machine language (binary) for the text "Hello World".
01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010
01101100 01100100
Below is another example of machine language (non-binary), which will print the letter "A" 1000
times to the computer screen.
169 1 160 0 153 0 128 153 0 129 153 130 153 0 131 200 208 241 96
Assembly Language :
Each personal computer has a microprocessor that manages the computer's arithmetical, logical,
and control activities.
Each family of processors has its own set of instructions for handling various operations such as
getting input from keyboard, displaying information on screen and performing various other
jobs. These set of instructions are called 'machine language instructions'.
A processor understands only machine language instructions, which are strings of 1's and 0's.
However, machine language is too obscure and complex for using in software development. So,
the low-level assembly language is designed for a specific family of processors that represents
various instructions in symbolic code and a more understandable form.
It is most suitable for writing interrupt service routines and other memory resident
programs.
SOFTWARE
TYPES
1. System Software
2. Application Software
2. It controls and coordinates the computer It is used for special and general purpose
operations. Operations.
3. Functions:
OS - MS Word
- Windows - Excel
- Macintosh system - Lotus
- Unix - Access
Compilers - Dbase
Assemblers
Loaders
Linkers
Language Translators :
Figure : 1
- The language in which the users program is written is called the source
language.
- The language to which the source language is converted is called the target
language.
Assembler :
Figure : 3
Characteristics of Assembler :
Compiler :
Figure : 4
Improved debugging
capability Good
documentation
1. Performance issues
For some applications, speed and size of the code are critical. An expert
assembly language programmer can often produce code that is much smaller
and much faster than a high level programmer can. Example – embedded
applications such as the code on a smart card, the code in a cellular telephone,
BIOS routines, inner loops of performance critical applications etc.
Loader : It is the part of the operating system (a system software) that is responsible for
loading programs from secondary storage devices into memory, preparing them for
execution and then executing them.
Linker : (FIGURE : 5 )
- A large program can be splitted up into many modules. All these modules have
to be connected logically and linked to form a single program.
Figure 5
2. Symbolic Operands :
3. Data declarations :
Statement format :
Instruction Format :
1. Imperative Statements
2. Declaration Statements
3. Assembler Directives
[Lable] DS <Constant>
[Label] DC <Value>
The DS (Declare Storage) statement reserves areas of memory and associates names with them.
E.g. A DS 1
B DS 150
First statement reserves a memory of 1 word and associates the name of the memory
as A.
Second statement reserves a memory of 150 word and associates the name of the
memory as B.
Associates the name ONE with a memory word containing the value ‘1’ . The
programmer can declare constants in decimal,binary, hexadecimal forms etc., These
values are not protected by the assembler. In the above assembly language program
the value of ONE Can be changed by executing an instruction MOVEM BREG,ONE
c. Assembler Directives :
Assembler directives instruct the assembler to perform certain actions during the
assembly of a program. Some Assembler directives are described in the following
START <Constant>
Indicates that the first word of the target program generated by the assembler
should be placed in the memory word with address <Constant>
First type to be
developed Most
Primitive
The operand field of an instruction containing forward reference is left blank intially
During the scan of the source program, all the symbols will be stored in a table called
SYMBOL TABLE. Symbol table consists of two important fields, they are symbol name
and address.
All the statements describing forward references will be stored in a table called
Table of Incompleted Instructions (TII)
101 ONE
By the time the END statement is processed the symbol table would contain
the address of all symbols defined in the source program
Synthesis the target form using the address information found in Symbol
table.
2. Mnemonics table
1. ORIGIN
2. EQU
3. LTROG
ORIGIN :
Indicates that Location counter should be set to the address given by < address
spec>
This statement is useful when the target program does not consist of
consecutive memory words.
EQU :
Syntax
It should be placed such that the control never reaches it during the
execution of a program.
By default, the assembler places the literals after the END statement.
3) Perform LC processing.
PASS 2:-
OPTAB :
If an imperative statement is present, then the mnemonic info field contains the
pair (machine opcode, instruction length) else it contains the pair id of a routine
to handle the declaration or directive statement.
SYMTAB :
The processing of an assembly statement begins with the processing of its label field. If
it contains a symbol, the symbol and the value in LC is copied into a new entry of
SYMTAB.
LITTAB :
POOLTAB :
This table contains the literal no. of starting literal of each literal pool.
The detailed design of pass1 assembler and pass2 assembler are explained in
detail with the flowcharts.
Pass 1:
Input:Source program
Output:Intermediate code
Pass 2:
Input:Intermediate code
Output:object code
Consists of a set of (IC) units. Each unit consisting of the following three fields.
1. Address
2. Mnemonic Opcode
3. Operands
Mnemonic
Mnemonic Opcode :
Code :
1. DC01
2. DS02
AD
1. Start01
2. END02
3. ORIGIN03
4. EQU04
5. LTORG05
There are two variants of intermediate code which differs in the information contained in
their operand fields.
Variant 1
Operand Field
It can be an
1. Register operand
2. Memory operand
A1 LT1
B2 LE2
C3 EQ3
D4 GT4
GE5
ANY6
Memory Operand
For a constant, the code field contains the internal representation of the constant
itself.
START 200
READ A
Loop MOVER AREG, A
SUB AREG, =’1’
BC GT, Loop
STOP
A DS
LTOR
G
Solution :
(AD,01)
START 200 (C,200)
STOP (IS,00)
A DS (DL,02) (C,01)
LTORG (DL,05)