CST 305 SYSTEM SOFTWARE
MODULE 1
Dec 1, 2024 1
CSE, AJCE
SYLLABUS
Introduction: System Software vs Application Software,
Different System Software– Assembler, Linker, Loader, Macro
Processor, Text Editor, Debugger, Device Driver, Compiler,
Interpreter, Operating System (Basic Concepts only).
SIC & SIC/XE Architecture, Addressing modes, SIC &
SIC/XE Instruction set, Assembler Directives.
Dec 1, 2024 2
CSE, AJCE
System Software?
• Consists of a variety of programs that support the operation of a
computer.
• Helps to run computer hardware and computer system
• makes it possible for users to focus on an application or other
problem to be solved, without knowing the details of how the
machine works internally.
Dec 1, 2024 CSE, AJCE 3
System Software Concept
Users
Application Program
Utility Program
Debugger Macro Processor Text Editor
(Library)
Complier Assembler Load and Linker
OS
Memory Process Device Information
Management Management Management Management
Bare Machine (Computer)
Dec 1, 2024 CSE, AJCE 4
System Software Vs Application
Software
Aspect System Software Application Software
Purpose Manages and controls hardware components and provides Helps users perform specific tasks or applications.
a platform for running application software.
Operating Systems (Windows, macOS, Linux), Device Drivers Office Suites (Microsoft Office, Google Workspace) , Web
- Utility Programs (antivirus software, disk management Browsers (Google Chrome, Mozilla Firefox), Media Players (VLC
Examples tools) Media Player), Graphic Design Software (Adobe Photoshop),
Games
Functionality • Manages hardware resources (CPU, memory, I/O • Performs specific user-oriented tasks (word processing,
devices) browsing, image editing, gaming)
• Provides basic functionalities for the computer system's • Designed to meet end-user needs
operation
• Ensures smooth system performance
User • Typically runs in the background • Directly interacted with by the user
Interaction • Provides a user interface (graphical or command-line) • Provides a user interface designed for ease of use and
for hardware interaction and system resource productivity
management
Development Often more complex due to interactions with hardware and Focuses on user experience, functionality, and ease of use
Complexity the need for security, efficiency, and stability rather than low-level hardware interactions
Dec 1, 2024 CSE, AJCE 5
Compiler
a computer program that translates computer code written in one programming
language (the source language) into another (the target language) language.
The name "compiler" is primarily used for programs that translate source code
from a high-level programming language to a low-level programming language
(e.g. assembly language, object code, or machine code) to create an executable
program
Dec 1, 2024 CSE, AJCE 6
Compiler
Dec 1, 2024 CSE, AJCE 7
Assembler
• A program that automatically translates the source program written in assembly
language and produces as output an object code written in binary machine code.
Dec 1, 2024 CSE, AJCE 8
Compiler Vs Assembler
Compiler Assembler
Converts the source code written by the programmer to a machine level Converts the assembly code into the machine code.
language.
input source code. input assembly language code.
converts the whole code into machine language at a time. But the Assembler can’t do this at once.
takes less execution time compared to an assembler. It takes more time than a compiler.
It detects errors in the first phase, fixes them, and then the second
It shows the whole program error after the whole program is scanned. phase is start to execute.
A Compiler is more intelligent than an Assembler. But, an Assembler is less intelligent than a Compiler.
The compilation phases are lexical analyzer, syntax analyzer, semantic Assembler makes two phases over the given input, first phase and the
analyzer, intermediate code generated, a code optimizer, code second phase.
generator, and error handler
The output of compiler is a mnemonic version of machine code. The output of assembler is binary code.
C, C++, Java, and C# are examples of compiled languages. GAS, GNU is an example of an assembler.
Dec 1, 2024 CSE, AJCE 9
Interpreter
A program that ultimately performs the same function as a compiler,
but in a different manner.
It works by scanning through the source program instruction by
instruction.
As each instruction is encountered, the interpreter translates it into
m/c code and executes it directly.
useful for scripting and rapid prototyping.
They provide immediate feedback, which is beneficial for debugging.
Dec 1, 2024 CSE, AJCE 10
Compiler Vs Interpreter
Compiler Interpreter
Converts the source code program into m/c Converts each source program line into m/c
code before program execution code as it executes, line by line.
Can be removed from memory after Must be continuously resident in memory
compilation is finished while the program is being executed
Compilation is faster, translation occurs with Interpretation is slower. There is no
program execution concurrent translation and so consumes
time
Compilation results in an object code on No object code results for that can be
direct execution executed later
More complicated error checking Easier error checking
Dec 1, 2024 CSE, AJCE 11
Linker
Combines multiple object files generated by an assembler or
compiler into a single executable file.
It takes the object code generated by the compiler and combines it
with other necessary libraries and modules to create an executable
file.
Dec 1, 2024 CSE, AJCE 12
Linker
Dec 1, 2024 CSE, AJCE 13
Loader
Loads the executable file into memory for execution.
Dec 1, 2024 CSE, AJCE 14
Macros
A macro is a piece of code in a program that is
replaced by the value of the macro.
Output
defined by #define directive.
Example 1 The value of LIMIT is 5
// C program to illustrate macros
#include <stdio.h>
// Macro definition
#define LIMIT 5
// Driver Code
int main()
{
// Print the value of macro defined
printf("The value of LIMIT is %d", LIMIT);
return 0;
}
Dec 1, 2024 CSE, AJCE 15
Macros
Example 2
#include <stdio.h>
#define AREA(l, b) (l * b) // Macro definition
int main() Output
{ Area of rectangle is: 50
// Given lengths l1 and l2
int l1 = 10, l2 = 5, area;
// Find the area using macros
area = AREA(l1, l2);
// Print the area
printf("Area of rectangle is: %d", area);
return 0;
}
Dec 1, 2024 CSE, AJCE 16
Macros
Example 3
// C program to illustrate macros
#include <stdio.h>
Output
// Function-like Macro definition Minimum value between 18 and 76 is
#define min(a, b) (((a) < (b)) ? (a) : (b)) 18
int main()
{
int a = 18;
int b = 76;
printf("Minimum value between %d and %d is %d\n", a, b, min(a, b));
return 0;
}
Dec 1, 2024 CSE, AJCE 17
Macros
Example 4
#include <iostream>
using namespace std;
Output
7
#define CUBE(b) b*b*b
int main()
{
cout << CUBE(1 + 2);
return 0;
}
Dec 1, 2024 CSE, AJCE 18
Macros Vs Functions
Macro Function
Macros are Preprocessed Functions are Compiled
No Type Checking is done in Macro Type Checking is Done in Function
Using Macro increases the code length Using Function keeps the code length unaffected
Use of macro can lead to side effect at later stages Functions do not lead to any side effect in any case
Speed of Execution using Macro is Faster Speed of Execution using Function is Slower
Before Compilation, macro name is replaced by macro value During function call, transfer of control takes place
Macros are useful when small code is repeated many times Functions are useful when large code is to be written
Macro does not check any Compile-Time Errors Function checks Compile-Time Errors
Dec 1, 2024 CSE, AJCE 19
Macro Processor
Processes macros, which are sequences of code or instructions that
are represented by a single macro instruction.
Dec 1, 2024 CSE, AJCE 20
Text Editor
software programs that enable the user to create and edit text files.
eg: Notepad, Wordpad
Features normally associated with text editors are — moving the cursor,
deleting, replacing, pasting, finding, finding and replacing, saving etc.
Dec 1, 2024 CSE, AJCE 21
Debugger
A debugger is a tool that allows to examine the state of a running
program.
Debugging is the process of locating and then removing bugs or
errors in a program.
An interactive debugging system gives programmers tools to help
them test and debug their programs.
Debugging is the methodical process of locating and eliminating bugs
or defects in a computer program.
Dec 1, 2024 CSE, AJCE 22
Device drivers
controls a specific hardware device that enables different hardware
devices to communicate with the computer’s Operating System.
A device driver communicates with the computer hardware by
computer subsystem or computer bus connected to the hardware.
Without a device driver the particular hardware fails to work
accordingly, which means it fails in doing the function/action it was
created to do.
Dec 1, 2024 CSE, AJCE 23
Device drivers
Dec 1, 2024 CSE, AJCE 24
SIC and SIC/XE
Simplified Instructional Computer
SIC/XE (Extra equipment)
is a theoretical computer used primarily for educational purposes to
familiarize computer architecture and assembly language
programming.
Dec 1, 2024 CSE, AJCE 25
SIC Architecture
Memory:
Memory consists of 8-bit bytes, 3 consecutive bytes form a word (24 bits)
There are a total of 32768 bytes (32 KB) in the computer memory.
Registers:
5 registers
24 bits in length
Mnemonic Number Name Special Use
A 0 Accumulator For arithmetic operations
X 1 Index register For addressing
L 2 Linkage The JSUB stores the return address in this register
register
PC 8 Program Address of next instruction
Dec 1, 2024 counter
CSE, AJCE 26
SIC Architecture
Data Formats
Integers are stored as 24-bit binary number
2’s complement representation for negative values
Characters are stored using 8-bit ASCII codes
No floating-point hardware on the standard version of SIC
Dec 1, 2024 CSE, AJCE 27
SIC Architecture
Instruction format
24-bit format
The flag bit x is used to indicate addressing mode
8 1 15
opcode x address
Addressing Modes
two addressing modes available
Indicated by x bit in the instruction
(X) represents the contents of register X
Dec 1, 2024 CSE, AJCE 28
• DIRECT ADDRESSING MODE
• LDA TEN-Effective Address(EA)=1000(TEN-just a name to indicate
memory)
• CONTENT OF ADDRESS 1000 IS LOADED TO ACCUMULATOR
• INDIRECT ADDRESSING MODE
• STCH BUFFER,X
• EA=1000+[X]=1000+CONTENT OF INDEX REG,X
• THE ACCUMULATOR CONTENT,THE CHARACTER IS LOADED TO EA
Dec 1, 2024 CSE, AJCE 29
SIC Architecture
Instruction set
Load and store registers (LDA, LDX, STA, STX, etc.)
Integer arithmetic operations (ADD, SUB, MUL, DIV)
Compare instruction (COMP),CC IS SET BY THIS INSTRN
Conditional jump instructions (JLT, JEQ, JGT)
JSUB jumps to the subroutine, placing the return address in register
L.
RSUB returns by jumping to the address contained in register L.
Dec 1, 2024 CSE, AJCE 30
SIC Architecture
Input /Output
• I/O are 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.
• 3 I/O OPERATION-OPERAND SPECIFIES DEVICE CODE
• Test Device (TD): tests whether the addressed device is ready to send or
receive
• Condition code (flag)is set to indicate the result of this test.
• < ready , = not ready
• Read Data (RD)
• Write Data (WD)
Dec 1, 2024 CSE, AJCE 31
SIC/XE Architecture
Memory
1 megabytes (1024 KB) in memory
Registers:
3 additional registers, 24 bits in length
Mnemonic Number Name Special Use
B 3 Base register used for addressing
S 4 General working register No special use
T 5 General working register No special use
F 6 Floating point accumulator 48 bits
Dec 1, 2024 CSE, AJCE 32
SIC/XE Architecture
Data format
24-bit binary number for integer
2’s complement for negative values
48-bit floating-point data type
The exponent is between 0 and 2047
If the exponent has the value e and the fraction has value f , the absolute value of the
number represented is
f*2(e-1024)
1 11 36
S exponent fraction
Dec 1, 2024 CSE, AJCE 33
SIC/XE Architecture
Floating point Data representation • Sign Bit:
• Example Number: −45.25 • Negative number, so S = 1.
• Convert to Binary: • Exponent:
• Integer part: 45→101101 • Actual exponent: 5
• Fractional part: 0.25→.01 • Bias: 1024
• Combined: 101101.01 • Stored exponent: 5+1024=1029
• Normalized: 1.0110101×2^5 • Binary exponent: 10000000101
• Fraction:
• Normalized fraction: 0110101
• (padded to 36 bits:
• 011010100000000000000000000000000000)
48-bit Representation: 1 10000000101 011010100000000000000000000000000000
Dec 1, 2024 CSE, AJCE 34
SIC/XE Architecture
Instruction formats
Format 1
do not refer memory
Examples
FIX
Convert a floating-point number in register A to a fixed-point number.
FLOAT
Convert a fixed-point number in register A to a floating-point number.
HIO
Halt input/output channel.
NORM
Normalize the floating-point number in register A.
RSUB
Dec 1, 2024 CSE, AJCE 35
SIC/XE Architecture
Instruction formats
Format 2
do not refer memory
Examples
CLEAR
Clear a register.
Opcode: B4 Format: B4 r1 0 (r2 is set to 0)
TIXR
Increment the X register by 1 and compare it to the specified register.
Opcode: B8 Format: B8 r1 0 (r2 is set to 0)
ADDR
Add the values in two registers and store the result in the first register.
Opcode: 90 Format: 90 r1 r2
SUBR
Dec 1, 2024
Subtract the value in the second register from the first register and store the result in the first
CSE, AJCE 36
register.
Opcode: 94 Format: 94 r1 r2
SIC/XE Architecture
Instruction formats
Format 3
Relative addressing
e=0
Examples
LDA
STA
JUMP
Dec 1, 2024 CSE, AJCE 37
SIC/XE Architecture
Instruction formats
Format 4
Extend the address to 20 bits
e=1
Examples
+LDA
+STA
+JUMP
Dec 1, 2024 CSE, AJCE 38
SIC/XE Architecture
Instruction formats
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
Dec 1, 2024 CSE, AJCE 39
SIC/XE Architecture
Addressing modes
1. Immediate Addressing
2. Simple Addressing
3. Indirect Addressing
4. Indexed Addressing
5. PC-Relative Addressing
6. Base-Relative Addressing
Dec 1, 2024 CSE, AJCE 40
SIC/XE Architecture
Addressing modes
1. Immediate Addressing
The operand is a constant value specified directly in the instruction.
flag: n=0,i=1,x=0
Example:
LDA #5: Load accumulator with the value 5
Dec 1, 2024 CSE, AJCE 41
SIC/XE Architecture
Addressing modes
2. Direct Addressing
The operand is a memory address specified directly in the instruction
flag: n=1, i=1 , x=0, b=0, p=0
target address is taken as the location of the operand
Example:
LDA BUFFER: Load accumulator with the value at a memory location ‘BUFFER’
Dec 1, 2024 CSE, AJCE 42
SIC/XE Architecture
Addressing modes
3. Indirect Addressing
flag: n=1, i=0, x=0
Dec 1, 2024 CSE, AJCE 43
SIC/XE Architecture
Addressing modes
4. Indexed Addressing
flag: n=1, i=1, x=1 or n=0,i=0,x=1
Dec 1, 2024 CSE, AJCE 44
SIC/XE Architecture
Addressing modes
5. PC Relative Addressing
The operand is a memory address specified directly in the instruction
flag: n=1, i=1, b=0, p=1 (x=0 or 1)
Dec 1, 2024 CSE, AJCE 45
SIC/XE Architecture
Addressing modes
5. Base Relative Addressing
The operand is a memory address specified directly in the instruction
flag: n=1, i=1, b=1, p=0 (x=0 or 1)
Dec 1, 2024 CSE, AJCE 46
SIC/XE Architecture
Target Address Calculation
Given (X)=000690, (B)=006030, (PC)=003060
Dec 1, 2024 CSE, AJCE 47
Dec 1, 2024 CSE, AJCE 48
Dec 1, 2024 CSE, AJCE 49
Dec 1, 2024 CSE, AJCE 50
Dec 1, 2024 CSE, AJCE 51
Dec 1, 2024 CSE, AJCE 52
Dec 1, 2024 CSE, AJCE 53
Dec 1, 2024 CSE, AJCE 54
Dec 1, 2024 CSE, AJCE 55
SIC/XE Architecture
Instruction set
Load and store registers (LDB, STB, etc.)
Floating-point arithmetic operations (ADDF, SUBF, MULF, DIVF)
Register-to-register arithmetic operations (ADDR, SUBR, MULR, DIVR)
Instructions that take operands from registers
RMO (Register Move)
RMO r1,r2 r2 ← (r1)
Dec 1, 2024 CSE, AJCE 56
SIC/XE Architecture
• Instruction COMP, COMPR
• Compares the value in register A with a word in memory and also between registers
• This sets a condition code, CC to indicate the result (<,=,>)
• Conditional Jump Instructions
• JLT, JEQ, JGT
• Test the setting of CC and jump accordingly
• Instructions for Subroutine linkages
• 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/XE Architecture
Input and Output
SIC/XE supports I/O channels that can be used to perform input and
output operation (data transfer) while the CPU is executing other
instructions
Channel program controls sequence of operation performed by a channel
This allows overlapping of computing and I/O – results in more efficient
system operation
SIO Start an I/O channel number
TIO Test an I/O channel number
HIO Halt an I/O channel number
SIC Programming Examples
• Sample data movement operations
• No memory-to-memory move instructions
SIC/XE Programming Examples
SIC Programming Examples
• Sample arithmetic operations
• (ALPHA+INCR-1) assign to BETA (Fig. 1.3)
• (GAMMA+INCR-1) assign to DELTA
SIC/XE Programming Examples
SIC Programming Examples
• String copy
Increment by one index register Jump to beginning of loop, if CC
X, compare with operand (11) is LT (Less Than)
and update condition code (CC)
SIC/XE Programming Examples
SIC Programming Examples
SIC/XE Programming Examples
SIC Programming Examples
SIC Programming Examples
SIC\XE Programming Examples
• 1. Write a sequence of instructions for SIC to compute ALPHA equal to
the product of BETA and GAMMA.
LDA BETA
MUL GAMMA
STA ALPHA
:
:
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 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
GAMMARESW 1
• 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/XE to divide BETA by GAMMA, setting ALPHA
to the integer portion of the quotient and DELTA to the remainder. Use register-to-
register instructions to make the calculation as efficient as possible.
LDA BETA
LDS GAMMA
DIVR S, A
STA ALPHA
MULR S, A
LDS BETA
SUBR A, S
STS DELTA
:
ALPHA RESW 1
BETA RESW 1
GAMMA RESW 1
DELTA RESW 1
• Write a sequence of instructions for SIC/XE to divide BETA by GAMMA, setting
ALPHA to the value of the quotient, rounded to the nearest integer. Use register-
to-register instructions to make the calculation as efficient as possible.
LDF BETA
DIVF GAMMA
FIX
STA ALPHA
:
ALPHA RESW 1
BETA RESW 1
GAMMA RESW 1
• Write a sequence of instructions for SIC to clear a 20-byte string to all blanks.
LDX ZERO
LOOP LDCH BLANK
STCH STR1,X
TIX TWENTY
JLT LOOP
:
STR1 RESW 20
BLANK BYTE C‘ ‘
ZERO WORD 0
TWENTY WORD 20
ASSEMBLER DIRECTIVES
• Assembler directives are pseudo instructions
• They provide instructions to the assembler itself
• They are not translated into machine operation codes
• START, END, BYTE, WORD, RESW, RESB are some of the assembler directives
• There are four different ways of defining storage for data items in the SIC Assembler language.
• BYTE : Generate character or hexadecimal constant, occupying as many bytes as needed to represent the constant
Eg: CHARZ BYTE C’Z’
• WORD : Generate one-word integer constant
Eg: FIVE WORD 5
• RESB :
• Reserve the indicated number of bytes for a data area
• Eg:BETA RESB 2
• RESW :
• Reserve the indicated number of words for a data area
• Eg: ALPHA RESW 1
• START :
• Specify name and starting address for the program
• Eg:SUM START 4000
• END :
• Indicate the end of the source program, and (optionally) the first executable instruction in the
program.
• Eg:END FIRST
Textbook
System software: an
introduction to systems
programming, Leland L. Beck,
3rd Edition, Addison Wesley,
Longman Inc., 1997.
Dec 1, 2024 CSE, AJCE 80