Module 1
Module 1
Module 1 (Introduction)
Introduction
The computer system components can be hardware and software. A program is a collection of
instructions that can be executed by a computer to perform a specific task. Software is a
collection of programs, procedures, routines associated with the operation of the computer
system.
Software can be classified as: Application Software and System Software. Application
software performs specific task for the end user as per the requirement. eg: , Photoshop, Ms-
Office, etc.
System Software consists of variety of program that supports the operation of a computer. This
software makes it possible for the user to focus on an application or other problem to be solved,
without needing to know the details of how the machine works internally.
[Just for general understanding.(During the programming course, you had used different
system software’s, you wrote programs in high level language like c++, using the text editor to
create and modify the program. You translated these programs into machine language programs
using compiler. The resulting machine language program was loaded into memory and prepared
for execution by a loader and linker. You may have used a debugger to help to detect errors in
the program. Later when using assembly language you may come across macro instructions to
read and write data, or to perform higher level functions. There you have used assembler which
probably includes a macro processor to translate these programs into machine language. The
translated programs were prepared for execution by linker and loader may test with debugger.)]
The central theme is to understand the relationship between machine architecture and the system
software. The design of an assembler, operating system etc. is greatly influenced by the
architecture of the machine on which it is to run.
1. Operating System
2. Device Drivers
3. Text Editor
4. Macro-processor
5. Language Translators
a. Assembler
b. Compiler
c. Interpreter
6. Loader
7. Linker
8. Debugger
(**marked in red should be studied in this semester in each module)
Operating System
Operating system provides a basis for application programs and acts as an intermediary between
a user of a computer and the computer hardware by performing all the basic tasks like file
management, memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers.
1. Memory Management
Main memory provides a fast storage that can be accessed directly by the CPU. For a
program to be executed, it must in the main memory. An Operating System does the
following activities for memory management −
• Keeps tracks of primary memory, i.e., what part of it are in use by whom, what
parts are not in use?
• In multiprogramming, the OS decides which process will get memory when and
how much.
• De-allocates the memory when a process no longer needs it or has been terminated.
2. Process Management
In multiprogramming environment, the OS decides which process gets the processor when
and for how much time. This function is called process scheduling. An Operating System
does the following activities for processor management −
• Keeps tracks of processor and status of process. The program responsible for this
task is known as traffic controller.
3. Device Management
An Operating System manages device communication via their respective drivers. It does
the following activities for device management −
• Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
• Decides which process gets the device when and for how much time.
• De-allocates devices.
4. File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions.
• Keeps track of information, location, uses, status etc. The collective facilities are
often known as file system.
Following are some of the important activities that an Operating System performs −
2. Control over system performance − Recording delays between request for a service
and response from the system.
3. Job accounting − Keeping track of time and resources used by various jobs and users.
4. Error detecting aids − Production of dumps, traces, error messages, and other
debugging and error detecting aids.
Operating systems are there from the very first computer generation and they keep evolving
with time.
The users of a batch operating system do not interact with the computer directly. Each
user prepares his job on an off-line device like punch cards and submits it to the
computer operator. To speed up processing, jobs with similar needs are batched together
and run as a group. The programmers leave their programs with the operator and the
operator then sorts the programs with similar requirements into batches.
• CPU is often idle, because the speed of the mechanical I/O devices is slower than
the CPU.
Multiple jobs are executed by the CPU by switching between them, but the switches
occur so frequently. Thus, the user can receive an immediate response. For example, in a
transaction processing, the processor executes each user program in a short burst or
quantum of computation. That is, if n users are present, then each user can get a time
quantum. When the user submits the command, the response time is in few seconds at
most. The operating system perform CPU scheduling and multi-programming. Computer
systems that were designed primarily as batch systems have been modified to time-
sharing systems.
• Problem of reliability.
The processors communicate with one another through various communication lines
(such as high-speed buses or telephone lines). These are referred as loosely coupled
systems or distributed systems. Processors in a distributed system may vary in size and
function. These processors are referred as sites, nodes, computers, and so on.
• With resource sharing facility, a user at one site may be able to use the resources
available at another.
• Speedup the exchange of data with one another via electronic mail.
• If one site fails in a distributed system, the remaining sites can potentially continue
operating.
Network Operating System runs on a server and provides the server the capability to
manage data, users, groups, security, applications, and other networking functions. The
primary purpose of the network operating system is to allow shared file and printer
access among multiple computers in a network, typically a local area network (LAN), a
private network or to other networks.
• Upgrades to new technologies and hardware can be easily integrated into the
system.
• Remote access to servers is possible from different locations and types of systems.
A real-time system is defined as a data processing system in which the time interval
required to process and respond to inputs is so small that it controls the environment. The
time taken by the system to respond to an input and display of required updated
information is termed as the response time. So in this method, the response time is very
less as compared to online processing.
Real-time systems are used when there are rigid time requirements on the operation of a
processor or the flow of data and real-time systems can be used as a control device in a
dedicated application. A real-time operating system must have well-defined, fixed time
constraints, otherwise the system will fail. For example, Scientific experiments, medical
imaging systems, industrial control systems, weapon systems, robots, air traffic control
systems, etc.
Hard real-time systems guarantee that critical tasks complete on time. In hard
real-time systems, secondary storage is limited or missing and the data is
stored in ROM. In these systems, virtual memory is almost never found.
Soft real-time systems are less restrictive. A critical real-time task gets
priority over other tasks and retains the priority until it completes. Soft real-
time systems have limited utility than hard real-time systems. For example,
multimedia, virtual reality, Advanced Scientific Projects likes undersea
exploration and planetary rovers, etc.
Device Drivers
A device driver is glue between OS and its I/O devices. Device Drivers act as translators which
converts generic requests received from the operating system into commands that specific
peripheral controllers can understand.
The application software makes system calls to the operating system requesting services. The
operating system analyses these requests and when, necessary, issues requests to the appropriate
device driver. The device driver in turn analyses the request from the operating system and when
necessary, issues commands to the hardware interface to perform the operations needed to
service the request.
Although the process may seem unnecessarily complex, the existence of device drivers actually
simplifies the operating system considerably. Without device drivers operating system would be
responsible for talking directly to the hardware. This would require the operating system’s
designer to include support for all of the devices that users might want to connect to their
computer. It would also mean that adding support for a new device would mean modifying the
operating system itself.
By separating the device driver’s functions from the operating system itself, the designer of the
operating system can concern himself with issues that relate to the operation of the system as a
whole. Furthermore, details related to individual hardware devices can be ignored and generic
requests for I/O operations can be issued by the operating system to the device driver.
The device driver writer, on the other hand, does not have to worry about the many issues related
to general I/O management, as these are handled by the operating system. All the device driver
writer has to do is to take detailed device-independent requests from the operating system and to
manipulate the hardware in order to fulfill the request.
Finally, the operating system can be written without any knowledge of the specific devices that
will be connected. And the device driver writer can connect any I/O device to the system without
having to modify the operating system. The operating system views all hard disks through the
same interface, and the device driver writer can connect almost any type of disk to the system by
providing a device driver so that the operating system is happy.
The result is a clean separation of responsibilities and the ability to add device drivers for new
devices without changing the operating system. Device drivers provide the operating system with
a standard interface to non-standard I/O devices.
Text Editors
A text editor is a piece of computer software for editing plain text. Text editors are often
provided with the operating system or software development packages, and are used to change
configuration files and programming language source codes. Text editors are considered as the
primary interface to the computer for all types of “knowledge workers” as they compose,
organize, study and manipulate computer-based information.
The fundamental functions in editing are travelling, editing, viewing and display. Travelling
implies movement of the editing context to a new position within the text. This may be done
explicitly by the user (eg: the line number command of a line editor) or may be implied in a user
command (eg: the search command of a stream editor). Viewing implies formatting the text in a
manner desired by the user. This is an abstract view, independent of the physical characteristics
of an I/O device. The display component maps this view into the physical characteristics of the
display device being used. This determines where a particular view may appear on the user’s
screen. The separation of viewing and display functions give rise to interesting possibilities like
multiple windows on the same screen, concurrent edit operations using the same display
terminal, etc. A simple text editor may choose to combine the viewing and display functions.
▪ Line Editors
The scope of edit operations in a line editor is limited to a line of text. The line is
designated positionally, eg: by specifying its serial number in the text, or contextually, eg:
by specifying a context which uniquely identifies it. The primary advantage of line editors
is their simplicity.
▪ Stream Editors
Stream editors view the entire text as a stream of characters. This permit edits operations to
cross line boundaries. Stream editors typically support character, line and context oriented
commands based on the current editing context indicated by the position of a text pointer.
The pointer can be manipulated using positioning and search commands
• Line and Stream editors typically maintain multiple representations of text. One
representation (the display form) shows the text as a sequence of lines. The editor
maintains an internal form which is used to perform the edit operations. This form
contains end-of-line characters and other edit characters. The editor ensures that these
representations are compatible at every moment.
▪ Screen Editors
A line or stream editors does not display the text in the manner it would appear if printed.
A screen editor uses the what-you-see-is-what-you-get principle in editor design. The
editor displays a screen full of text at a time. The user can move the cursor over the screen,
position it at the point where he desires to perform some editing and proceed with the
editing directly. Thus it is possible to see the effect of an edit operation on the screen. This
is very useful while formatting the text to produce printed documents.
▪ Word Processor
Word Processors are basically document editors with additional features to produce well
formatted hard copy output. Essential features of word processors are commands for
moving sections of text from one place to another, merging of text, and searching and
replacement of words. Many word processors support a spell-check option. With the advent
of personal computer, word processors have seen widespread use amongst authors, office
personnel and computer professionals. WordStar is a popular editor of this class.
▪ Structure Editors
A structure editor incorporates an awareness of the structure of a document. This is useful
in browsing through a document, eg: if a programmer wishes to edit a specific function in a
program file. The structure is specified by the user while creating or modifying the
document. Editing requirements are specified using the structure. A special class of
structure editors, called syntax-directed editors, is used in programming environments.
• Contemporary editors support a combination of line, string and screen editing
functions. The Vi editors of Unix and the editors in desktop publishing systems are
typical examples.
Macro Processor
To relieve programmers of the need to repeat identical parts of their program, operating systems
provide a macro processing facility, which permits the programmer to define an abbreviation for
a part of his program and to use the abbreviation in his program. Macro instructions (Macros) are
single-line abbreviations for a group of instructions. The macro processor treats the identical
parts of the program defined by the abbreviation as a macro definition and saves the definition.
The macro processor substitutes the definition for all occurrences of the abbreviation (macro
call) in the program
In addition to help programmers abbreviate their programs, macro facilities have been used as
general text handlers and for specializing operating systems to individual computer installations.
In specializing operating systems (systems generation), entire operating system is written as a
series of macro definitions. To specialize the operating system, a series of macro calls are
written. These are processed by the macro processor by substituting the appropriate definitions,
thereby producing all the programs for an operating system.
• Macros differ from subroutines in one fundamental respect. Use of a macro name in
the mnemonic field of an assembly statement leads to its expansion, whereas use of a
subroutine name in a call instruction leads to its execution.
Language Translators
Computers are basically machines that follow very specific and primitive instructions. Language
translators translate the source program written in either high-level language or low-level
language into machine understood object program. Various language translators are:
2. Compiler
A compiler is a computer program which helps you transform source code written in a
high-level language into low-level machine language. It translates the code written in one
programming language to some other language without changing the meaning of the
code. The compiler also makes the end code efficient which is optimized for execution
time and memory space.
Characteristics of a Compiler
• Machine Dependent
Each compiler has its own machine language. Compilers are machine
dependent – means that you cannot use a compiler in CRAY, to translate a
program that could be understood by the IBM-360.
• Language Dependent
Phases of a Compiler
The compiling process includes basic translation mechanisms and error detection. Compiler
process goes through lexical, syntax, and semantic analysis at the front end, and code generation
and optimization at a back-end. (Just study the diagram…you will study the explanation as
• Incremental compiler
• Cross Compiler
• Load & Go Compiler
• Threaded Code compiler
• Stage Compiler
• Just-in-time Compiler
• Parallelizing Compiler
1. The compiler generates assembly code and some compilers can also directly generate
executable code whereas, the assembler generates reloadable machine code.
2. The compiler takes as input the preprocessed code generated by preprocessor. On the
other hands, the assembler takes assembly code as input.
3. The compilation takes place in two phases that are analysis phase and synthesis phase.
In analysis phase, the input goes through lexical analyzer, syntax analyzer, semantic
analyzer whereas; the synthesis analysis takes place via intermediate code generator,
code optimizer, code generator. On the other hands, assembler passes the input
through two phases. The first phase detects the identifiers and allots addresses to them in
the second phase the assembly code is translated to binary code.
4. The assembly code generated by the compiler is a mnemonic version of machine code.
However, the reloadable machine code generated by assembler is a binary reloadable
code.
3. Interpreter
Interpreter is a type of language translator that does not necessarily have an output interface
and hence its language processing activities are closely bound with the program execution. Use
of interpreter is motivated by two reasons – efficiency in certain environments and simplicity.
It is simpler to develop an interpreter than to develop a compiler because interpretation does
not involve code generation. This makes interpretation more attractive in situations where
programs or commands are not executed repeatedly. Hence interpretation is a popular choice
for commands to an operating system or an editor. User interfaces of many software packages
prefer interpretation.
▪ Symbol Table: The symbol table holds the information concerning entities in the source
program.
▪ Data Store: The data store contains values of the data items declared in the program
being interpreted.
▪ Data Manipulation Routine: This set contains a routine for every legal data
manipulation action in the source language.
Types of Interpreter
▪ Pure Interpreter
Pure Interpreters do not change the source code and retains the source form
throughout the interpretation process. This requires more overhead and the process
becomes a bit complex.
Data
Source
Code Interpreter Output
▪ Impure Interpreter
The source code is subjected to initial preprocessing before the code is eventually
interpreted. The actual analysis overhead is now reduced
Intermediate
Code
Source Code Preprocessor Interpreter Output
1. The compiler takes a program as a whole and translates it, but interpreter translates a
program statement by statement.
3. A compiler is comparatively faster than Interpreter as the compiler take the whole
program at one go whereas interpreters compile each line of code after the other.
4. The compiler requires more memory than interpreter because of the generation of object
code.
5. Compiler presents all errors concurrently, and it’s difficult to detect the errors in contrast
interpreter display errors of each statement one by one, and it’s easier to detect errors.
6. In compiler when an error occurs in the program, it stops its translation and after
removing error whole program is translated again. On the contrary, when an error takes
place in the interpreter, it prevents its translation and after removing the error, translation
resumes.
7. In a compiler, the process requires two steps in which firstly source code is translated to
target program then executed. While in Interpreter It’s a one-step process in which
Source code is compiled and executed at the same time.
8. The compiler is used in programming languages like C, C++, C#, Scala, etc. On the other
Interpreter is employed in languages like PHP, Ruby, Python, etc.
The Assembler generates the object code of a source program and hands it over to the linker. The
linker takes this object code and generates the executable code for the program, and hand it over
to the Loader.The high-level language, programs have some built-in libraries and header files.
The source program may contain some library functions whose definitions are stored in the built-
in libraries. The linker links these function to the built-in libraries. In case the built-in libraries
are not found it informs to the compiler, and the compiler then generates the error. Sometimes
the large programs are divided into the subprograms which are called modules. Now when these
modules are compiled and assembled, the object modules of the source program are generated.
The linker has the responsibility of combining/linking all the object modules to generate a single
executable file of the source program. Two types of linkers:
• Absolute loading
• Relocatable loading
• Dynamic run-time loading
Absolute loading: This approach loads the executable file of a program into a same main
memory location each time. But it has some disadvantages like a programmer must be aware of
the assignment strategy for loading the modules to main memory. In case, the program is to be
modified involving some insertion and deletion in the program, then all the addresses of the
program have to be altered.
Relocatable loading: In this approach, the compiler or assembler does not produce actual main
memory address. It produces the relative addresses.
Dynamic Run-Time loading: In this approach, the absolute address for a program is generated
when an instruction of an executable module is actually executed. It is very flexible, the loadable
module/executable module can be loaded into any region of main memory. The executing
program can be interrupted in between and can be swapped out to the disk and back to main
memory this time at a different main memory address.
Key Differences between Linker and Loader
1. The linker generates the executable file of a program whereas, the loader loads the
executable file obtained from the linker into main memory for execution.
2. The linker intakes the object module of a program generated by the assembler. However,
the loader intakes the executable module generated by the linker.
3. The linker combines all object module of a program to generate executable modules it
also links the library function in the object module to built-in libraries of the high-
level programming language. On the other hands, loader allocates space to an
executable module in main memory.
4. The linker can be classified as linkage editor and dynamic linker whereas loader can be
classified as absolute loader, relocatable loader and dynamic run-time loader.
A debugger is a software program used to test and find bugs(errors) in other programs. The tool
is known as debugging tool.
▪ Full Simulation
▪ Partial Simulation
There are two types of debuggers:
▪ CorDBG (command-line debugger)
▪ DbgCLR (graphic debugger)
One characteristic in which most system software differs from application software is
machine dependency. But most system software is machine-dependent.
• Compilers must generate machine language code, taking into account such
hardware characteristics as the number and type of registers and the machine
instructions available.
• Operating systems are directly concerned with the management of nearly all of
the resources of a computing system.
• The general design and logic of an assembler is basically same on most of the
computers.
• Some of the code optimization techniques used by compilers (but some are
machine dependent)
There are a series of questions that we ask if we wish to program the machine.
1. MEMORY
What are the memory’s basic unit, size and addressing scheme?
2. REGISTERS
How many registers are there? What are their size, function and interrelationship?
3. DATA
What types of data can be handled by the computer? Can it handle characters, numbers,
and logical data? How is this data stored?
4. INSTRUCTIONS
What are the classes of instructions on the machine? Are there arithematic instructions,
logical instructions, symbol-manipulation instructions? What are their formats? How are
they stored in memory?
5. SPECIAL FEATURES
What is the interrupt structure of the machine? What sort of protection mechanism is
available to the user?
SIC is a hypothetical model particularly designed to include the hardware features which are
most often found on real time machines. The hardware components in such a system are basic to
all real machines thereby eliminating irrelevant complexities. Since the design is very simple, the
software concepts are clearly separated from implementation details. In many ways SIC is
similar to microcomputer. Like many other products, SIC comes in two versions:
The two versions have been designed to be upward compatible – ie, an object program for the
standard SIC machine will also execute properly on SIC/XE system.
Memory
Memory consists of 8-bit bytes. Any 3 consecutive bytes form a word (24 bits).All addresses on
SIC is byte addresses. Words are addressed by the location of their lowest numbered byte. There
are a total of 215 (32768) bytes in the computer memory.
Registers
There are 5 registers and all of them have special uses. Each register is 24- bits in length.
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. There is no floating-point
hardware on the standard version of SIC.
Instruction Format
All machine instructions on standard version of SIC are 24-bit format. The following is the
representation of instruction format.
Addressing Modes
There are two addressing modes available, indicated by the setting of the x bit in the instruction.
In direct addressing mode the flag bit x=0. Here the target address is specified by the actual
address in the instruction itself. In indexed addressing mode the flag bit x=1. Here the target
address is computed by adding the actual address specified in the instruction and the contents of
the Index Register. The table following describes how the target address is calculated from the
address given in instruction. Parentheses are used to indicate the contents of a register or a
memory location. For example, (X) represents the contents of register X.
Instruction Set
– All arithmetic operations involve register A and a word in memory with result
being left in the register
• Instruction COMP
– Input and output are performed by transferring 1 byte at a time to or from the
rightmost 8-bits of register A
– TD (Test Device): this instruction tests whether the addressed device is ready to
send or receive a byte of data. Condition code is set to indicate the result of this
test.
– A program needing to transfer data must wait until the device is ready, then
execute RD and WD.
– RD (Read Data)
– WD(Write Data)
– This sequence must be repeated for each byte of data to be read or written.
Assembler directives are known as Pseudo instruction. They tell the assembler to establish start
address for your program, to reserve space for variables, to include additional source files.
START, END, BYTE, WORD, RESW, RESB are some of the assembler directives.
Explanation
• Similar to LDA and STA we have for X register we have (LDX and STX), for L register
we have (LDL and STL).
• In the example, Firstly, 3-byte word is moved by loading into register A and then storing
the register at the desired location
• Secondly, a single byte of data is moved using the instructions LDCH (Load Character)
and STCH (Store Character)
• These instructions operate by loading or storing the rightmost 8-bit byte of register A; the
other bits in register A are not affected.
• WORD reserves one word of storage, which is initialized to a value defined in the
operand field of the statement.
• Here in this example the WORD statement defines a data word labeled FIVE whose
value is initialized to 5
• RESW reserves one or more words of storage for use by the program
• In this example one word storage labeled ALPHA will be used to hold a value generated
by the program.
• The statements BYTE, RESB perform similar storage definition functions for the data
items that are characters instead of words.
• In this example, CHARZ is a 1-byte data item whose data item whose value is initialized
to the character “Z”
Explanation
• All arithmetic operations are performed using register A. With the result being left in
register A.
• LDA ALPHA
// Here we do not know the content of ALPHA. So we can write as ALPHA itself. Now
value of A register = ALPHA
• ADD INCR
// Add operation is performed with the contents of A register and the content in INCR and
the result is stored in A register. Now, A= (ALPHA +INCR)
• SUB ONE
// Next the content in the A register is subtracted by 1 here we have given the one word
constant with a value 1 and result is stored in A register. Now, A= (ALPHA +INCR – 1)
• STA BETA
// Now we are moving the result from A register to BETA because if we use the A register
for the next instruction the content get over- written. So after performing this instruction
BETA = (ALPHA+INCR-1)
• LDA GAMMA
//Again we are loading the content in the GAMMA to A register. Now, A= GAMMA
• ADD INCR
//Add operation is performed with the contents of A register and the content in INCR and the
result is stored in A register. Now, A= (GAMMA+INCR)
• SUB ONE
// Next the content in the A register is subtracted by 1 here we have given the one word
constant with a value 1 and result is stored in A register. Now, A= (GAMMA +INCR – 1)
• STA DELTA
// Now we are moving the result from A register to DELTA because if we use the A register
for the next instruction the content get over- written. So after performing this instruction
DELTA = (GAMMA+INCR-1)
• So finally we can say that, the sequence of instructions stores the value as :
Explanation
• This program fragment reads 1-byte of data from device F1 and copies it to device 05
• The operand for the RD is a byte in memory that contains the hexadecimal code for the
input device (here it is F1)
• Executing RD instruction transfers 1 byte of data from this device into the rightmost byte
of A register
• If the input device is character oriented (if keyboard), the value placed in register A is
ASCII code for the character that was read
• Before RD can be executed, input device must be ready to transmit the data.
• For example, if the input device is a keyboard, the operator must have typed a character.
• When TD is executed, the status of the addressed device is tested and condition code is
set to indicate the result of this test.
• If the device is ready to transmit data, the condition code is set to “less than”.
• The program must execute the TD instruction and then check the condition code by using
a conditional jump
• If condition code is “equal”(device not ready), the program jumps back to the TD
instruction.
• The two instruction loop will continue until the device becomes ready, then RD will be
executed.
• The program uses TD to check whether the output device (here, 05) is ready to receive a
byte of data.
• Then the byte to be written is loaded into the rightmost byte of register A, and WD
instruction is used to transmit it to the device.
Explanation
• The index register (X) is initialized to zero before the loop begins
• During the first execution of loop, the target address for the LDCH instruction will be the
address of the first byte of STR1
• Similarly, the STCH instruction will copy the character being copied into the first byte of
STR2.
• It compares new value in the X register with the operand (here 11)
• The JLT instruction jumps if the condition code is set to “less than”
• Thus, the JLT causes a jump back to the beginning of the loop if the new value in register
X is less than 11
• During the second execution of the loop, register x will contain the value 1
• Thus the target address for the LDCH instruction will be the second byte of STR1 and the
target address for the STCH instruction will be the second byte of STR2.
• The TIX instruction will again add 1 to the value in register X, and the loop will continue
in this way until all 11 bytes have been copied from STR1 to STR2.
• Notice that after the TIX instruction is executed, the value in register X is equal to the
number of bytes that have already been copied.
Explanation
• These instructions can be used to read a 100-byte record from an input device into
memory.
• This subroutine is called from the main program by using JSUB (Jump to Subroutine)
instruction.
• At the end of the subroutine there is an RSUB (Return from Subroutine) instruction,
which returns control to the instruction that follows the JSUB.
• Each execution of this loop reads 1 byte of data from the input device, using the same
concept used in input –output operations(ref. program: 3)
• The bytes of data that are read are stored in a 100-byte buffer area labelled RECORD.
• The indexing and looping techniques that are used in storing characters in this buffer are
essentially the same as those illustrated ( in program: 4)
Memory
Memory consists of 8-bit bytes. Any 3 consecutive bytes form a word (24 bits).All addresses on
SIC/XE is byte addresses. Words are addressed by the location of their lowest numbered byte.
The maximum memory available on a SIC/XE system is 1 Megabyte (220 bytes). This increase
leads to a change in instruction formats and addressing modes.
Registers
There are 9 registers and all of them have special uses. Each register is 24- bits in length, except
floating point accumulator (F) which is 48- bit length.
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. There is no floating-point
hardware on the standard version of SIC.
• A value of zero is represented by setting all bits (including sign, exponent and fraction) as 0
• Exponent (e) part is an unsigned binary number between 0 and 2047 →(211=2048)
Instruction Format
In SIC, there is only 1 format (24-bit). But in SIC/XE, as the memory size is large, this
instruction format is not enough to address the whole memory There are two possible options:
SIC/XE provides some instructions that do not reference memory at all (as in format 1 &2)
• In format 2, 8 bits for opcode and 2 registers each having 4bits eg: COMPR A,S
• In format 3, 6 bits for opcode, 6bits of flags specifies the addressing modes, and 12 bit
displacement. Eg: LDA #3
• In format 4, 6 bits for opcode, 6 bits of flags specifies the addressing modes and 20 bits of
address. Eg: JSUB READ
Addressing Modes
n i x b p e
• n → indirect
• i → immediate
• x → indexed
• b → base relative
• e bit :
Already, we have a chart indicates the format to be used with each machine instruction( I
have given the pdf of the appendix of the text in your lms )
• Relative Addressing
If b = 0, p = 0 TA = disp
• Displacement field (disp): It is an 8-bit or 16-bit immediate value given in the instruction
• In Format 3 instruction:
o For base relative addressing, the displacement field (disp) is interpreted as 12-bit
unsigned integer.
o For program counter relative addressing, the displacement field(disp) is
interpreted as 12-bit signed interger, with negative values in 2’s complement
representation
• Both the relative addressing can also be combined indexed addressing by using the x bit
flag field
• x bit : indexed addressing
o If x =1, TA can be calculated by adding the content of the X register also with the
already calculated the TA for the relative addressing
• In Format 4 instruction the bits b and p are normally set to 0 → then the target address is
taken from the address field of the instruction. This is known as Direct Addressing
• i and n bits: specify how target address is used.
Instruction Set
Explanation
• Shows two data movement operations
• Here value 5 is loaded into register A using immediate addressing
• The operand field for this instruction contains the flag #(which specifies the immediate
addressing) and the data value to be loaded.
• The character “Z” is placed into register A by using immediate addressing to load the
value 90, which is the decimal value of the ASCII code that is used internally to represent
the character “Z”
Explanation
• Arithmetic operations performed on SIC/XE architecture
• The value of INCR is loaded into S register initially.
• The register-to-register instruction ADDR is used to add this value to register A when it
is needed.
• This avoids having to fetch INCR from memory each time it is used in calculation, which
may make the program more efficient.
• Immediate Addressing is used for the constant 1 in the subtracting operations
• So finally we can say that, the sequence of instructions stores the value as :
• BETA = (ALPHA + INCR - 1)
• DELTA = (GAMMA + INCR -1)
MOVECH
Explanation
• Here the example shows the same loop as in SIC architecture: a loop that copies one 11
byte character string to another.
• The main difference is that the instruction TIXR is used in place of TIX.
• TIXR works exactly like TIX, except that the value used for comparison is taken from
another register (here taken in T register), not from memory.
• This makes the loop more efficient, because the value does not have to be fetched from
memory each time the loop is executed.
Explanation
• The variables ALPHA, BETA and GAMMA are arrays of 100 words each.
• In this case the task of the loop is to add together the corresponding elements of ALPHA
and BETA, storing the results in the elements of GAMMA.
• The general principle of looping and indexing is same as the previous example.
• However the value in the index register must be incremented by 3 for each iteration of
this loop, because each iteration processes a 3-byte (ie., one word) element of the arrays.
• The TIX instruction always add 1 to register x, so it is not suitable for this program
fragment.
• Instead, we use arithmetic and comparison instructions to handle the index value. In this
example, the index value is kept permanently in register X. The amount by which to
increment the index value (3) is kept in register S, and the register –to - register ADDR
instruction is used to add this increment to register X.
• Similarly, the value 300 is kept in register T, and the instruction COMPR is used to
compare registers X and T in order to decide when to terminate the loop.
RLOOP
Explanation
• The program shows the same READ subroutine in SIC architecture: to read a 100-byte
record from an input device into memory. Main difference is the use of immediate
addressing and TIXR instruction.