You are on page 1of 75

SYSTEM SOFTWARE

Subject Code : CS633P


Subject Type : CORE
 TEXT BOOKS
 Donovan, “John, System programming”, Tata McGraw-Hill, Reprint 2008
 Beck, Leland, “System Software An Introduction to System Programming”,
Addison-Wesley, 3rd Edition, Reprint 2009

 REFERENCE BOOKS
Dhamdhere D M, “Systems programming and operating systems”, Tata
McGraw-Hill, Reprint 2006.
Unit 1:Introduction
Background
What does a computer system consists of?

Hardware

Software

Data

User
Background
Software are of 2 types. What are they?

System Software
Application Software
Background
Application Software:

◦ It is a set of one or more programs designed to


carry out operations for a specific application. 

◦ Application software cannot run on itself but


is dependent on system software to execute.
Background
System Software:

◦ System software (systems software) is


computer software designed to operate and
control the computer hardware and to provide
a platform for running application software.
Background
System Software:

◦ Operating Systems
 Kernel
 User Interface – Graphical and Command Line

◦ Utility Software
 analyse, configure, optimize and maintain the computer.

◦ Software Development Tools


 Assembler, Compiler, Interpreter, Macroprocessor,
Linker and so on.
Language Translation Flow in HLL

Problem
Definition Program Coding Compile

Object Execution file


Linker
File *.exe

*.OBJ
Library
DIFFERENT STEPS INVOLVED IN USING
ASSEMBLY LANGUAGE

◦ Step 1: Program written using macro


instructions to read & write data

◦ Step 2: Uses assembler, which probably


included a macro processor to translate these
programs into machine language

◦ Step 3: loader or linker (prepared for


execution)

◦ Step 4: tested using debugger


System Software and Machine
Architecture

◦ Applications: focus on the particular


application and not on the computing
system - machine independent.

◦ System Software: intend to support


computer operations and uses - machine
dependent.
System Software and Machine
Architecture

Machine Dependent Features of System


Software:

◦ Machine Architecture
◦ Instruction formats
◦ Addressing modes
◦ The number of registers
◦ The type of registers
◦ OS – Management of all the resources
System Software and Machine
Architecture

Machine Independent Features of


System Software:

◦ The general design and logic of an assembler.

◦ Some of code optimization techniques.

◦ The process of linking independently


assembled subprograms together.
Components and evolution of
programming system
Assembler
Macro processor
Loader
Compiler
Operating system
The Simplified Instructional
Computer (SIC)
Itis a hypothetical computer that has been carefully
designed to include the hardware features most
often found on real machines, while avoiding
unusual or irrelevant complexities.

There are two versions of SIC, they are, standard


model (SIC), and, extension version (SIC/XE)
(extra equipment or extra expensive).

Upward compatible.
 Programs for SIC can run on SIC/XE.
SIC Machine Architecture
Memory
Registers
Data Formats
Instruction Formats
Addressing Modes
Instruction Set
Input and Output
SIC Machine Architecture
Memory:
◦ 8 – bit bytes.
◦ 3 consecutive bytes form a word (24 bits).
◦ There are 215 bytes in the computer memory,
that is 32,768 bytes .
◦ It uses Little Endian format to store the
numbers.
SIC Machine Architecture
Registers:
◦ There are five registers, each 24 bits in length.
Mnemonic Number Special Use

A 0 Accumulator; used for arithmetic operations

X 1 Index register; used for addressing

L 2 Linkage register; Jump to Subroutine (JSUB)


Instructions stores the return address in this register

PC 8 Program counter ; contains the address of the next


instruction to be fetched for execution

SW 9 Status word, contains a variety of information,


including Condition Code (CC )
SIC Machine Architecture
Registers:

◦ SIC does not have any stack. It uses the linkage


register to store the return address.

◦ It is difficult to write the recursive program. A


programmer has to maintain memory for return
addresses when he writes more than one layer
of function call.
SIC Machine Architecture
Data Formats:

◦ Integers are stored as 24-bit binary numbers.


◦ 2’s complement representation is used for
negative values.

◦ Characters are stored using their 8-bit ASCII


codes.
◦ No floating-point hardware on the standard
version of SIC. Exists in SIC / XE.
SIC Machine Architecture
Instruction Formats:

◦ All machine instructions on the standard


version of SIC have the 24-bit format as shown
below.

Opcode (8) X Address (15)

◦ The flag bit X is used to indicate indexed –


addressing mode.
SIC Machine Architecture
Addressing Modes:
◦ Two addressing modes
 Indicated by the x bit in the instruction.

(X): the contents of register X


SIC Machine Architecture
Addressing Modes - Example:

◦ Direct Addressing Mode:


 LDA TEN

0000 0000 0 001 0000 0000 0000

0 0 x 1 0 0 0
 Effective address (EA) = 1000
 Content of the address 1000 is loaded to Accumulator.
SIC Machine Architecture

◦ Indexed Addressing Mode:


 STCH BUFFER, X

0101 0100 1 001 0000 0000 0000

5 4 X 1 0 0 0

 Effective address (EA) = 1000 + (X)


Accumulator content ,character is loaded
in to the effective address.
SIC Machine Architecture
Instruction Set:

◦ Load/store registers: LDA, LDX, STA, STX


◦ Integer arithmetic: ADD, SUB, MUL, DIV
 All involve register A (Accumulator) and a word in
memory, result stored in register A
◦ COMP
 Compare value in register A with a word in memory
 Set a condition code CC (<, =)
◦ Conditional jump instructions
 JLT, JEQ, JGT: test CC and jump
SIC Machine Architecture
Instruction Set:

◦ Subroutine Linkage:

 JSUB – jumps to the subroutine, placing the return


address in register L.

 RSUB – returns by jumping to the address


contained in the register L.
SIC Machine Architecture
Input and Output:

◦ Performed by transferring 1 byte at a time to or


from the rightmost 8 bits of register A.

◦ Each device is assigned a unique 8-bit code, as


an operand of I/O instructions.

◦ Test Device (TD): < (ready), = (not ready).

◦ Read Data (RD), Write Data (WD).


SIC Machine Architecture
Data movement and Storage Definition:

◦ LDA, STA, LDL, STL, LDX, STX ( A-


Accumulator, L – Linkage Register, X – Index
Register), all uses 3-byte word.

◦ LDCH, STCH associated with characters uses 1-


byte.

◦ There are no memory-memory move


instructions.
SIC Machine Architecture
Storage definitions:

WORD: ONE - WORD CONSTANT


RESW: ONE - WORD VARIABLE
BYTE: ONE - BYTE CONSTANT
RESB: ONE - BYTE VARIABLE
Sample data movement example
inta;
Char ch;
a = 5; ch=‘z’;
Sample data movement operations
SIC / XE Machine Architecture
Memory
Registers
Data Formats
Instruction Formats
Addressing Modes
Instruction Set
Input and Output
SIC / XE Machine Architecture
Memory:

◦ 220 bytes in the computer memory.

◦ More instruction formats and addressing


modes.
SIC / XE Machine Architecture
Registers:
◦ There are five registers, each 24 bits in length.
Mnemonic Number Special Use

A 0 Accumulator; used for arithmetic operations

X 1 Index register; used for addressing

L 2 Linkage register; Jump to Subroutine (JSUB)


Instructions stores the return address in this register

PC 8 Program counter ; contains the address of the next


instruction to be fetched for execution

SW 9 Status word, contains a variety of information,


including Condition Code (CC )
SIC / XE Machine Architecture
Registers:

◦ Additional Registers.

Mnemonic Number Special Use

B 3 Base Register used for addressing

S 4 General working register

T 5 General working register

F 6 Floating-point accumulator (48 bits)


SIC / XE Machine Architecture
Data Formats:

◦ Integers are stored as 24-bit binary numbers.


◦ 2’s complement representation is used for
negative values.
 -N = 2n - N
◦ Characters are stored using their 8-bit ASCII
codes.
SIC / XE Machine Architecture
Data Formats:
S EXPONENT FRACTION

 The fraction value is interpreted as a value between 0


and 1.
 The exponent is interpreted as an unsigned binary
number between 0 and 2047.
 If the exponent has a value e and the fraction has a
value f, the absolute value of the number is
represented as f * 2(e -1024)
 S:
◦ 0 – Positive
◦ 1 - Negative
SIC / XE Machine Architecture
Instruction Formats:
SIC / XE Machine Architecture
Instruction Formats:
8
Format 1 (1 byte) –
opcode

 Eg – RSUB (Return to subroutine)

0100 1100

4 C
 Format 2 (2 bytes) –
opcode r1 r2

8 4 4

 Eg – COMPR A,S
A S

1010 0000 0000 0100

8-bit 4-bit 4-bit


 Format 3 (3 bytes) –
1 1 1 1 1 1

opcode n i x b p e displacement

6 bit 12 bit

 Eg – LDA #3 ( Load 3 to A),object code->010003

0000 00 0 1 0 0 0 0 0000 0000 0011

6 bit 12 bit
 Format 4 (4 bytes) –

opcode n i x b p e address

6 bit 20 bit

 Eg – +JSUB RDREC ( jump to address , 1036),object code:4B101036

0100 10 1 1 0 0 0 1 0000 0001 0000 0011 0110

4 0 1 0 3 6
SIC / XE Machine Architecture
Addressing Modes:

Mode Indication Target address calculation


Base relative b=1, p=0 TA=(B)+disp (0<=disp<=4095)
Program-counter b=0, p=1 TA=(PC)+disp (-2048<=disp<=2047)
relative
Direct b=0, p=0 TA=disp (format 3) or address (format 4)
Indexed x=1 TA=TA+(X)
SIC / XE Machine Architecture
Addressing Modes:
◦ Five addressing modes

Direct (x, b, and p all set to 0)

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
Relative (either b or p equal to 1 and the
other one to 0):

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
Immediate (i = 1, n = 0):

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
6 1 1 1 1 1 1 12
Indirect (i = 0, n = 1): Op n i x b p e disp

Indexed (x = 1): 6 1 1 1 1 1 1 12
Op n i x b p e disp
SIC / XE Machine Architecture
e = 1 means format 4.

Bits x, b, p: Used to calculate the target


address using relative, direct, and
indexed addressing Modes

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
Bits i and n: Says, how to use the target
address. (Indirect i=0, n=1 / Immediate
i=1, n=0)

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
b and p - both set to 0, disp field from
format 3 instruction is taken to be the
target address. (Direct)

6 1 1 1 1 1 1 12

Op n i x b p e disp
SIC / XE Machine Architecture
x - x is set to 1, X register value is added for
target address calculation.

i=1, n=0 Immediate addressing


◦ TA: TA is used as the operand value, no memory
reference.

i=0, n=1 Indirect addressing


◦ ((TA)): The word at the TA is fetched. Value of
TA is taken as the address of the operand value.

i=0, n=0 or i=1, n=1 Simple addressing, (TA)


◦ TA is taken as the address of the operand value
SIC / XE Machine Architecture
Instruction Set:

◦ SIC/XE provides all of the instructions that are available on the


standard version.

◦ In addition we have, Instructions to load and store the new


registers LDB, STB, etc.

◦ Floating-point arithmetic operations, ADDF, SUBF, MULF,


DIVF.

◦ Register move instruction : RMO.

◦ Register-to-register arithmetic operations, ADDR, SUBR,


MULR, DIVR.

◦ Supervisor call instruction : SVC


SIC / XE Machine Architecture
Input and Output:

◦ There are I/O channels that can be used to


perform input and output while the CPU is
executing other instructions.

◦ Allows overlap of computing and I/O, resulting


in more efficient system operation.

◦ The instructions SIO, TIO, and HIO are used to


start, test and halt the operation of I/O channels.
• Write a sequence of instructions for
SIC to set ALPHA equal to the integer
portion of BETA ÷ GAMMA.
 
LDA BETA
DIV GAMMA
STA ALPHA

ALPHA RESW 1
BETA RESW 1
GAMMA RESW 1 
Write a sequence of instructions for SIC
to set ALPHA equal to the product of
BETA and GAMMA.
LDA BETA
MUL GAMMA
STA ALPHA

BETA RESW 1
GAMMA RESW 1
ALPHA RESW 1
Write SIC instructions to swap the
values of ALPHA and BETA.
 
LDA ALPHA
STA GAMMA
LDA BETA
STA ALPHA
LDA GAMMA
STA BETA

ALPHA RESW 1
BETA RESW 1
GAMMA RESW 1
Write a sequence of instructions
for SIC / XE to set ALPHA equal
to 4 * BETA – 9. Use immediate
addressing for the constants.
LDA BETA
LDS #4
MULR S,A
SUB #9
STA ALPHA

ALPHA RESW 1
BETA RESW 1
Write a sequence of instructions
in SIC to clear a 20-byte string to
all blanks.
LDX ZERO ;INITIALIZE INDEX REGISTER TO ZERO
LDCH CHR ;STORE BLANK IN REGISTER A

MOVEC STCH STR1, X ; STORE CHARACTER INTO STR1


TIX TWENTY ; ADD 1 TO INDEX AND COMPARE WITH 20
JLT MOVEC ; LOOP IF LESS THAN 20
 
ZERO WORD 0 CONSTANT 0
TWENTY WORD 20 CONSTANT 20
CHR BYTE C’ ‘ CONSTANT CHAR BLANK
STR1 RESB 20 20 BYTE STRING VARIABLE
Sample looping and indexing operations :
Assignment : SIC and SIC/XE
instructions to copy one 11 byte character
string to another.
SIC
LDX ZERO
MOVECH LDCH STR1, X
STCH STR2, X ; STORE character TO STR2
TIX ELEVEN ; ADD 1 TO X, TEST
JLT MOVECH

STR1 BYTE C ‘HELLO WORLD’


STR2 RESB 11
ZERO WORD 0
ELEVEN WORD 11
SIC/XE
LDT #11
LDX #0 ;X = 0
MOVECH LDCH STR1, X ;LOAD A FROM STR1
STCH STR2, X ;store character into str2.
TIXR T ;ADD 1 TO X, TEST (T)
JLT MOVECH

STR1 BYTE C ‘HELLO WORLD’


STR2 RESB 11
ALPHA is an array of 100 words. Write a sequence of
instructions for SIC/XE to set all 100 elements of the
array to 0. Use immediate addressing and register-to-
register instructions to make the process as efficient as
possible.
LDS #3
LDT #300
LDX #0
LOOP LDA #0
STA ALPHA,X
ADDR S, X
COMPR X, T
JLT LOOP

ALPHA RESW 100


Comparision between SIC and
SIC/XE
Memory.
Running of programs.
Number of Registers.
Data Formats.
Instruction Formats.
Addressing Modes.
Instruction Set : SVC ,RMO in SIC/XE
Input and Output.
Complete Instruction Set
P: privileged
instruction
X: available
Only on XE
F: floating-
Point
Instruction
C: condition
code CC set
to indicate
result of
operation

You might also like