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

Module_1

Modul1 1 System software

Uploaded by

Megha B
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)
2 views

Module_1

Modul1 1 System software

Uploaded by

Megha B
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/ 50

System Programming

System Software
• Software: Two types
– System Software
– Application Software

Application Software
User
System Software
Hardware
• Application Software
– Software to perform specific task for the user as per the
requirement.
– eg:- MS word, photoshop, Google chrome, mediaplayer
etc.
• System Software
– Software to support the operation of a computer.
– Enables the user to focus on the application or the
problem to be solved.
– User need not know the internal working of the
machine.
Types of system softwares
• Assembler
• Linker
• Loader
• Text editor
• Device driver
• Debugger
• Macro processor
• Compiler
• Interpreter
• Operating system
• Text Editors
– Allows users to create and edit documents.
– Eg:- notepad, microsoft word, vi, emacs etc.
• Device Drivers
– Programs that controls a device (printer, scanner,
keyboard etc.) connected to a computer.
– Converts the requests form the OS to specific
commands the device controllers can understand.
Language Translators
• Assembler
– Translate assembly language into machine language.
• Compiler
– Translate High level language programs into machine
language.
– eg: gcc (GNU Compiler Collections)
• Interpreter
– Translate High level language programs into machine
language.
– eg: Python compiler, java script
• Linker
– High level languages use header files/libraries that are
built-in or user defined.
– Linker links the user program with functions defined in
the libraries.
• Loader
– Loads the machine code into memory for execution.
• Debugger
– Identify and remove errors.
– Examine the flow of control, values of variables at
different points, values of parameters passed to the
function and values returned.
• Macro Processor
– Macro denotes a group of commonly used statements in
the program.
– Macro processor replaces each macro instruction with
corresponding group of statements.
– Macro Processor involves definition, invocation, and
expansion.
Introduction
• Definition
– System software consists of a variety of programs that
support the operation of a computer
– One characteristic in which most system software differ
from application software is machine dependency
• Example:
– e.g. when you took the first programming course
• text editor, compiler, loader or linker, debugger

– e.g. when you wrote assembler language


• assembler, macro processor
– e.g. you control all of these processes by interacting
with the operating system
System Software vs. Machine Architecture

• One characteristic in which most system software differ


from application software is machine dependency
• System Programs are intended to support the operation and
use of the computer itself, rather than any particular
application.
• They are usually related to the architecture of the machine
on which they are to run.
System Software vs. Machine Architecture
– e.g. assembler translate mnemonic instructions into machine code
considering the instruction format, addressing modes etc.
– e.g. compilers must generate machine language code taking in to
account H/W characteristics such as the number and type of
registers and machine instructions available
– e.g. operating systems are directly concerned with the management
of nearly all of the resources of a computing system
• There are some aspects of system software that do not
directly depend upon the type of computing system
– e.g. general design and logic of an assembler
– e.g. code optimization techniques used by the compiler
– e.g. linking together independently assembled subprograms
The Simplified Instructional Computer (SIC)

• SIC is a hypothetical computer that includes the hardware


features most often found on real machines.
• Two versions of SIC
– standard model, SIC
– XE version , SIC/XE(“extra equipment”)
• Upward compatible.
SIC Machine Architecture
Memory
• Memory consists of 8-bit bytes.
• 3 consecutive bytes form a word (24 bits).
• All addresses in SIC are byte addresses.
• Words are addressed by the lowest numbered byte.
• A total of 215 bytes (32,768) in the memory.
Registers
• Five registers, each have special use.
• Each register is 24 bits in length.
Data Format
• Integers are stored as 24-bit binary numbers; 2’s
complement representation is used for negative numbers.
• Characters are store using their 8-bit ASCII codes.
• There is no floating-point hardware on SIC.
Instruction Format
• All machine instructions on SIC has the following
24-bit format.

Flag bit ‘x’ is used to indicate indexed-addressing mode.


Addressing Modes
• Only two modes are supported: indicated by the setting up
of ‘x’ bit in the instruction.
– Direct addressing mode
– Indexed addressing mode

address – address given in the instruction


(X) - contents of register X
SIC Machine Architecture

• Instruction Set
– load and store registers: LDA, LDX, STA, STX, etc.
– integer arithmetic operations: ADD, SUB, MUL, DIV,
etc.
• All arithmetic operations involve register A and a word in
memory, with the result being left in the register.
– comparison: COMP
• COMP compares the value in register A with a word in
memory, this instruction sets a condition code CC to indicate
the result(<,=,>).
Instruction set
• Load and store instruction - LDA, LDX, STA, STX
– Ex: LDA ALPHA ⇔ (A) ← (ALPHA)
– STA ALPHA ⇔ (ALPHA) ← (A)

• Arithmetic instruction - ADD, SUB, MUL, DIV


– Involve register A and a word in memory
– Ex: ADD ALPHA ⇔ (A) ← (A) + (ALPHA)

• Comparison instruction – COMP


– Involves register A and a word in memory
– save result in the condition code (CC)
– Ex: COMP ALPHA ⇔ CC ←(<,+,>) of (A)?(ALPHA)
– conditional jump instructions: JLT, JEQ, JGT
• these instructions test the setting of CC and jump
accordingly
– subroutine linkage: JSUB, RSUB
• JSUB jumps to the subroutine, placing the return
address in register L.
• RSUB returns by jumping to the address contained
in register L.
Input and Output
• Transfer one byte at a time to or from the rightmost 8 bits of
register A.
• Each device has a unique 8-bit code.
• Three I/O instructions; each use device code as operand.
• Test device (TD): tests if a device is ready to send or
receive a byte of data.
– CC : < : ready
– CC : = : busy
• Read data (RD): read a byte from the device to register A
• Write data (WD): write a byte from register A to the device.
SIC/XE Machine Architecture
- Memory

• Memory structure of SIC/XE is same as SIC.


• 8-bit bytes
• 3 consecutive bytes form a word
– Addressed by the lowest number byte
• Maximum memory: 1 megabytes (220 bytes)
SIC/XE Machine Architecture
• Memory structure of SIC/XE is same as SIC.
• Maximum memory: 1 megabytes (220 bytes)

Additional Registers
SIC/XE - Data Formats
Integers are stored as 24-bit binary numbers.
• Negative numbers are stored as 2’s complement
representation.
• Characters are stored using their 8-bit ASCII codes.
• Additionally, there is a 48-bit floating-point data type

• Fraction : a value b/w 0 and 1 (0~1)


• Exponent : 0~2047
• s – indicate the sign of the floating point number.
• s=0 (positive) s=1 (negative)
• Absolute value of a number : frac*2(exp-1024)
Instruction Formats
• In SIC, there is only 1 format (24-bit).
• As the memory size is large in SIC/XE, the instruction
format in SIC is not enough to address the whole memory.
• larger memory -> extend addressing capacity
• Two Options:
a) Use relative addressing or (format 3)
b) Extend the address field to 20 bits. (format 4)

• SIC/XE also supports some instructions that do not


reference memory at all. (format 1 & 2)
Instruction Formats
There are 4 formats of instructions available in SIC/XE

e=0

e=1
Instruction Format

• Example: RSUB

Example: COMPR A,S


• Format 3

• The instruction will be interpreted as a simple SIC instruction


if and only if both bits are 0.
– n is used to show the indirect bit
– i is used to show the immediate bit
– x is used to show the index bit
– b is used to show the base bit
– p is used to show the PC relative bit
– e is used to show the extended bit
• Format 4

Bit representation Use


x=1 It is used to show the indexed addressing
e=0 It is used to show the 3-byte format
e=1 It is used to show the 4-byte format
b = 0 and p = 1 It is used to show the PC relative addressing
b = 1 and p = 0 It is used to show the base or displacement
addressing
n = 1 and i = 1 It is used to show the direct addressing
n = 1 and i = 0 It is used to show the indirect addressing
n = 0 and i = 1 It is used to show the immediate addressing
n = 0 and i = 0 It is used to show the simple SIC interpretation.
Addressing Mode
Two relative addressing modes are introduced for format 3:

For Base relative, displacement is a 12-bit unsigned integer.


For Program-counter relative, disp is a 12-bit signed integer.

In format 3, if b=0 and p=0, then disp is the target address.


In format 4 instruction, bits b and p are normally set to 0 and target
address is taken from address field of the instruction.
This is called direct addressing mode.

Both format 3 and 4 modes can be combined with indexed addressing –


if bit x is set to 1, the value of register X is added in the target Address
calculation.
Addressing Modes
Direct addressing
• In the direct addressing mode, the target address can be
directly taken from the field of address or disp if and only if
bits b and p are set to 0.

• For format 3 and format 4 in direct addressing, the


indication, target address, and calculation are described as
follows:
Format 3 (e = 0): n = 1, i = 1, b = 0, p = 0, TA = disp (0 ≤ disp ≤ 4095)
Format 4 (e = 1): n = 1, i = 1, b = 0, p = 0, TA = address
Addressing Modes
• Indexed addressing
• The term (x) is added in indexed addressing to calculate the
target address. If bit x is set to 1, in this case, the register X's
value will be added in the calculation of a target address.

• For format 3 and format 4 in direct indexed addressing, the


indication, target address are described as follows:
Format 3: n = 1, i = 1, x = 1, TA = (X) + disp
Format 4: n = 1, i = 1, x = 1, TA = (X) + address
Addressing Modes
For format 3 and 4:
• Bits i and n specify how the target address is used.
• (i =1, n = 0): immediate addressing mode. The target
address is used as the operand. No memory reference.
• (i = 0, n = 1): indirect addressing mode. The word at the
location given by the target address is fetched; the value
contained in this word is then used as the address of the
operand value.
• (i = 0, n = 0) used by SIC, (i=1, n=1) used by SIC/XE:
simple addressing mode. The target address is taken as the
location of the operand.
Indexing cannot be used with immediate or indirect modes.
Addressing Modes
Immediate mode

• In this image, i stand for immediate.


Addressing Modes

• Indirect mode

• In this image, n stands for indirect.


Addressing Modes

• Simple addressing mode

Case 1:

Case 2:
Example(Addressing modes)

All of these instructions are LDA.


Instruction Set
• Instructions to load and store new registers.( eg:-
LDB and STB etc.)
• Floating-point operations (ADDF, SUBF, MULF,
DIVF)
• Register move (RMO)
• Register-to-register operations (ADDR, SUBR,
MULR, DIVR)
• Supervisor call (SVC) for generating system calls
(interrupt) into the operating system.
Input and Output
• SIC/XE has input channels.
• Input channels are used to perform input and
output while CPU is executing other instructions.
• It allows overlapping of computing and I/O.
• I/O channel operation (SIO: start, TIO: test, HIO:
halt), similar to DMA
SIC Programming Example (Data Movement
operations)
SIC instruction sets

SIC/XE instruction sets

Use immediate mode will


make the program run faster
because it need not fetch
five from the memory.
SIC Programming Example (Arithmentic
Instructions)

BETA <- (ALPHA + INCR - 1)


DELTA <- (GAMMA + INCR - 1)
SIC/XE Programming Example (Arithmentic
Instructions)

This program will execute faster because


it need not load INCR from memory
each time when INCR is needed.
SIC Programming Example (Looping and
Indexing operations)
SIC/XE Programming Example (Looping and
Indexing operations)

This program will execute faster because


TIXR need not compare the index value
to a memory variable.
SIC Programming Example (Looping and
Indexing-2)

Gamma [] <- Alpha [] + Beta []


SIC Programming Example (Looping and
Indexing)

This program will execute faster


because it uses register-to-register
add to reduce memory accesses.
Input and Output Examples
Subroutine Call Example

Read 100 words into the record buffer


Subroutine Call Example (5.b)

Use TIXR makes this program run


faster

You might also like