Kalinga University Department of Computer Science
Kalinga University Department of Computer Science
UNIT-I
Computer organization refers to the operational units and their interconnections that realize
the architectural specifications. Examples of architectural attributes include the instruction
set, the number of bits used to represent various data types (e.g., numbers, characters), I/O
mechanisms, and techniques for addressing memory. Organizational attributes include those
hardware details transparent to the programmer, such as control signals; interfaces between
the computer and peripherals; and the memory technology used.
1
• Function: The operation of each individual component as part of the structure
Function
Both the structure and functioning of a computer are, in essence, simple. Figure 1.1 depicts
the basic functions that a computer can perform. In general terms, there are only four:
• Data processing
• Data storage
• Data movement
• Control
2
The computer, of course, must be able to process data. The data may take a wide variety of
forms, and the range of processing requirements is broad. However, we shall see that there
are only a few fundamental methods or types of data processing. It is also essential that a
computer store data. Even if the computer is processing data on the fly (i.e., data come in
and get processed, and the results go out immediately), the computer must temporarily store
at least those pieces of data that are being worked on at any given moment. Thus, there is at
least a short-term data storage function. Equally important, the computer performs a long-
term data storage function. Files of data are stored on the computer for subsequent retrieval
and update. The computer must be able to move data between itself and the outside world.
The computer’s operating environment consists of devices that serve as either sources or
3
destinations of data. When data are received from or delivered to a device that is directly
connected to the computer, the process is known as input–output (I/O), and the device is
referred to as a peripheral. When data are moved over longer distances, to or from a remote
device, the process is known as data communications. Finally, there must be control of these
three functions. Ultimately, this control is exercised by the individual(s) who provides the
computer with instructions. Within the computer, a control unit manages the computer’s
resources and orchestrates the performance of its functional parts in response to those
instructions. At this general level of discussion, the number of possible operations that can be
performed is few. Figure 1.2 depicts the four possible types of operations. The computer can
function as a data movement device (Figure 1.2a), simply transferring data from one
peripheral or communications line to another. It can also function as a data storage device
(Figure 1.2b), with data transferred from the external environment to computer storage (read)
and vice versa (write). The final two diagrams show operations involving data processing, on
data either in storage (Figure 1.2c) or route between storage and the external environment
(Figure 1.2d).
Structure
Figure 1.3 is the simplest possible depiction of a computer. The computer interacts in some
fashion with its external environment. In general, all of its linkages to the external
environment can be classified as peripheral devices or communication lines. We will have
something to say about both types of linkages.
4
But of greater concern in this book is the internal structure of the computer itself, which is
shown in Figure 1.4. There are four main structural components:
• Central processing unit (CPU): Controls the operation of the computer and performs its
data processing functions; often simply referred to as processor.
• Main memory: Stores data.
• I/O: Moves data between the computer and its external environment.
5
• System interconnection: Some mechanism that provides for communication among CPU,
main memory, and I/O. A common example of system interconnection is by means of a
system bus, consisting of a number of conducting wires to which all the other components
attach.
There may be one or more of each of the aforementioned components. Traditionally, there
has been just a single processor. In recent years, there has been increasing use of multiple
processors in a single computer. Some design issues relating to multiple processors crop up
and are discussed as the text proceeds; Part Five focuses on such computers. Each of these
components will be examined in some detail in Part Two. However, for our purposes, the
most interesting and in some ways the most complex component is the CPU. Its major
structural components are as follows:
• Control unit: Controls the operation of the CPU and hence the computer
• Arithmetic and logic unit (ALU): Performs the computer’s data processing functions
• Registers: Provides storage internal to the CPU
• CPU interconnection: Some mechanism that provides for communication among the
control unit, ALU, and registers
Each of these components will be examined in some detail in Part Three, where we will see
that complexity is added by the use of parallel and pipelined organizational techniques.
Finally, there are several approaches to the implementation of the control unit; one common
approach is a microprogrammed implementation. In essence, a microprogrammed control
unit operates by executing microinstructions that define the functionality of the control unit.
A computer organization describes the functions and design of the various units of a
digital system.
6
A general-purpose computer system is the best-known example of a digital system.
Other examples include telephone switching exchanges, digital voltmeters, digital
counters, electronic calculators and digital displays.
Computer architecture deals with the specification of the instruction set and the
hardware units that implement the instructions.
Computer hardware consists of electronic circuits, displays, magnetic and optic
storage media and also the communication facilities.
Functional units are a part of a CPU that performs the operations and calculations
called for by the computer program.
Functional units of a computer system are parts of the CPU (Central Processing Unit)
that performs the operations and calculations called for by the computer program. A
computer consists of five main components namely, Input unit, Central Processing
Unit, Memory unit Arithmetic & logical unit, Control unit and an Output unit.
Input unit
o Input units are used by the computer to read the data. The most commonly used input
devices are keyboards, mouse, joysticks, trackballs, microphones, etc.
7
Memory unit
o The Memory unit can be referred to as the storage area in which programs are kept
which are running, and that contains data needed by the running programs.
o The Memory unit can be categorized in two ways namely, primary memory and
secondary memory.
o It enables a processor to access running execution applications and services that are
temporarily stored in a specific memory location.
o Primary storage is the fastest memory that operates at electronic speeds. Primary
memory contains a large number of semiconductor storage cells, capable of storing a
bit of information. The word length of a computer is between 16-64 bits.
o It is also known as the volatile form of memory, means when the computer is shut
down, anything contained in RAM is lost.
o Cache memory is also a kind of memory which is used to fetch the data very soon.
They are highly coupled with the processor.
o The most common examples of primary memory are RAM and ROM.
o Secondary memory is used when a large amount of data and programs have to be
stored for a long-term basis.
o It is also known as the Non-volatile memory form of memory, means the data is
stored permanently irrespective of shut down.
o The most common examples of secondary memory are magnetic disks, magnetic
tapes, and optical disks.
8
Arithmetic & logical unit
o Most of all the arithmetic and logical operations of a computer are executed in the
ALU (Arithmetic and Logical Unit) of the processor. It performs arithmetic
operations like addition, subtraction, multiplication, division and also the logical
operations like AND, OR, NOT operations.
Control unit
o The control unit is also known as the nerve center of a computer system.
Output Unit
o The primary function of the output unit is to send the processed results to the user.
Output devices display information in a way that the user can understand.
o Output devices are pieces of equipment that are used to generate information or any
other response processed by the computer. These devices display information that has
been held or generated within a computer.
The basic computer has 16-bit instruction register (IR) which can denote either memory
reference or register reference or input-output instruction.
9
1. Memory Reference – These instructions refer to memory address as an operand. The
other operand is always accumulator. Specifies 12-bit address, 3-bit opcode (other
than 111) and 1-bit addressing mode for direct and indirect addressing.
Example –
IR register contains = 0001XXXXXXXXXXXX, i.e. ADD after fetching and
decoding of instruction we find out that it is a memory reference instruction for ADD
operation.
Hence, DR ← M[AR]
AC ← AC + DR, SC ← 0
Example –
IR register contains = 0111001000000000, i.e. CMA after fetch and decode cycle we
find out that it is a register reference instruction for complement accumulator.
Hence, AC ← ~AC
10
Example –
IR register contains = 1111100000000000, i.e. INP after fetch and decode cycle we
find out that it is an input/output instruction for inputing character. Hence, INPUT
character from peripheral device.
/li>
The set of instructions incorporated in16 bit IR register are:
1. Arithmetic, logical and shift instructions (and, add, complement, circulate left, right,
etc)
2. To move information to and from memory (store the accumulator, load the
accumulator)
3. Program control instructions with status conditions (branch, skip)
4. Input output instructions (input character, output character)
11
1. Fixed Program Computers – Their function is very specific and they couldn’t be
programmed, e.g. Calculators.
2. Stored Program Computers – These can be programmed to carry out many different
tasks, applications are stored on them, hence the name.
The modern computers are based on a stored-program concept introduced by John Von
Neumann. In this stored-program concept, programs and data are stored in a separate storage
unit called memories and are treated the same. This novel idea meant that a computer built
with this architecture would be much easier to reprogram.
12
A control unit (CU) handles all processor control signals. It directs all input and
output flow, fetches code for instructions and controlling how data moves around the
system.
Arithmetic and Logic Unit (ALU) –
The arithmetic logic unit is that part of the CPU that handles all the calculations the
CPU may need, e.g. Addition, Subtraction, Comparisons. It performs Logical
Operations, Bit Shifting Operations, and Arithmetic Operation.
13
Input/Output Devices – Program or data is read into main memory from the input
device or secondary storage under the control of CPU input instruction. Output
devices are used to output the information from a computer. If some results are
evaluated by computer and it is stored in the computer, then with the help of output
devices, we can present it to the user.
Buses – Data is transmitted from one part of a computer to another, connecting all
major internal components to the CPU and memory, by the means of Buses. Types:
1. Data Bus: It carries data among the memory unit, the I/O devices, and the
processor.
2. Address Bus: It carries the address of data (not the actual data) between
memory and processor.
3. Control Bus: It carries control commands from the CPU (and status signals
from other devices) in order to control and coordinate all the activities within
the computer.
Bus structures
A bus transfers electrical signals from one place to another. An actual bus appears as an
endless amount of etched copper circuits on the motherboard's surface. The bus is connected
to the CPU through the Bus Interface Unit.
Data travels between the CPU and memory along the data bus. The location (address) of that
data is carried along the address bus. A clock signal which keeps everything in synch travels
along the control bus.
14
The clock acts like a traffic light for all the PC's components; the "green light" goes on with
each clock tick. A PC's clock can "tick" anywhere from 20 to 65 million times per second,
which makes it seem like a computer is really fast. But since each task (such as saving a file)
is made up of several programmed instructions, and each of those instructions takes several
clock cycles to carry out, a person sometimes has to sit and wait for the computer to catch up.
Addressing Modes
Addressing Modes– The term addressing modes refers to the way in which the operand of an
instruction is specified. The addressing mode specifies a rule for interpreting or modifying
the address field of the instruction before the operand is actually executed.
Addressing modes for 8086 instructions are divided into two categories:
1) Addressing modes for data
2) Addressing modes for branch
The 8086 memory addressing modes provide flexible access to memory, allowing you to
easily access variables, arrays, records, pointers, and other complex data types. The key to
good assembly language programming is the proper use of memory addressing modes.
15
Immediate addressing mode (symbol #):In this mode data is present in address field
of instruction .Designed like one address instruction format.
Note: Limitation in the immediate mode is that the range of constants are restricted by
size of address field.
Example: MOV AL, 35H (move the data 35H into AL register)
Register mode: In register addressing the operand is placed in one of 8 bit or 16 bit
general purpose registers. The data is in the register that is specified by the
instruction.
Here one register reference is required to access the data.
The 8086 CPUs let you access memory indirectly through a register using the register
indirect addressing modes.
MOV AX, [BX](move the contents of memory location s
addressed by the register BX to the register AX)
Auto Indexed (increment mode): Effective address of the operand is the contents of
a register specified in the instruction. After accessing the operand, the contents of this
register are automatically incremented to point to the next consecutive memory
location.(R1)+.
Here one register reference,one memory reference and one ALU operation is
required to access the data.
Example:
16
Add R1, (R2)+ // OR
R1 = R1 +M[R2]
R2 = R2 + d
Useful for stepping through arrays in a loop. R2 – start of array d – size of an
element
Auto indexed ( decrement mode): Effective address of the operand is the contents of
a register specified in the instruction. Before accessing the operand, the contents of
this register are automatically decremented to point to the previous consecutive
memory location. –(R1)
Here one register reference,one memory reference and one ALU operation is
required to access the data.
Example:
Add R1,-(R2) //OR
R2 = R2-d
R1 = R1 + M[R2]
Auto decrement mode is same as auto increment mode. Both can also be used to
implement a stack as push and pop . Auto increment and Auto decrement modes are
useful for implementing “Last-In-First-Out” data structures.
17
instruction.
Here two memory reference is required to access the data.
Indexed addressing mode: The operand’s offset is the sum of the content of an index
register SI or DI and an 8 bit or 16 bit displacement.
The computers which use Stack-based CPU Organization are based on a data structure
called stack. The stack is a list of data words. It uses Last In First Out (LIFO) access
method which is the most popular access method in most of the CPU. A register is used to
store the address of the topmost element of the stack which is known as Stack pointer (SP).
In this organisation, ALU operations are performed on stack data. It means both the operands
are always required on the stack. After manipulation, the result is placed in the stack.
The main two operations that are performed on the operators of the stack are Push and Pop.
These two operations are performed from one end only.
1. Push –
This operation results in inserting one operand at the top of the stack and it decrease
the stack pointer register. The format of the PUSH instruction is:
PUSH
18
It inserts the data word at specified address to the top of the stack. It can be
implemented as:
//decrement SP by 1
SP <-- SP - 1
//increment SP by 1
SP <-- SP + 1
Operation type instruction does not need the address field in this CPU organization.
This is because the operation is performed on the two operands that are on the top of
the stack. For example:
br>
SUB
This instruction contains the opcode only with no address field. It pops the two top
data from the stack, subtracting the data, and pushing the result into the stack at the
top.
PDP-11, Intel’s 8085 and HP 3000 are some of the examples of the stack organized
computers.
The advantages of Stack based CPU organization –
o Efficient computation of complex arithmetic expressions.
o Execution of instructions is fast because operand data are stored in
consecutive memory locations.
o Length of instruction is short as they do not have address field.
The disadvantages of Stack based CPU organization –
o The size of the program increases.
Note:Stack based CPU organisation uses zero address instruction.
19
Memory location and addresses
Memories are made up of registers. Each register in the memory is one storage location.
Storage location is also called as memory location. Memory locations are identified
using Address. The total number of bit a memory can store is its capacity.
A storage element is called a Cell. Each register is made up of storage element in which one
bit of data is stored. The data in a memory are stored and retrieved by the process
called writing and reading respectively
A word is a group of bits where a memory unit stores binary information. A word with group
of 8 bits is called a byte. A memory unit consists of data lines, address selection lines, and
control lines that specify the direction of transfer. Data lines provide the information to be
stored in memory. The control inputs specify the direction transfer. The k-address lines
specify the word chosen.
Address field which contain the location of operand, i.e., register or memory location.
Instruction Execution
It contains a special register — the instruction register — whose bit pattern determines what
the central processor unit can do. Once that action has been completed, the bit pattern within
the instruction register may be modified, and also the central processor unit can perform the
operation nominative by this next bit pattern.
21
Since directions are simply bit patterns, they will be kept in memory. The instruction pointer
register continuously has the memory address of (points to) the next instruction to be
executed. So as for the management unit to execute this instruction, it’s derived into the
instruction register. The case is as follows:
2. The memory address wherever the first instruction is found is copied to the instruction
pointer.
3. The CPU sends the address within the instruction pointer to memory on the address
bus.
5. Memory responds by sending a copy of the state of the bits at that memory location
on the data bus that the CPU then copies into its instruction register.
6. The instruction pointer is automatically incremented to contain the address of the next
instruction in memory.
8. Go to step 3
9. Steps 3, 4, and 5 are called an instruction fetch. Notice that steps 3 – 8 constitute a
cycle, the instruction execution cycle.
Machine language is the low level programming language. Machine language can only be
represented by 0s and 1s. In earlier when we have to create a picture or show data on the
screen of the computer then it is very difficult to draw using only binary digits(0s and 1s).
For example: To write 120 in the computer system its representation is 1111000. So it is
very difficult to learn. To overcome this problem the assembly language is invented.
Assembly language is the more than low level and less than high-level language so it is
intermediary language. Assembly languages use numbers, symbols, and abbreviations
instead of 0s and 1s.For example: For addition, subtraction and multiplications it uses
symbols likes Add, sub and Mul, etc.
22
Machine Language Assembly Language
Machine language is only understand by the Assembly language is only understand by human
computers. beings not by the computers.
In machine language data only represented with the In assembly language data can be represented with
help of binary format(0s and 1s), hexadecimal and the help of mnemonics such as Mov, Add, Sub,
octadecimal. End etc.
Machine language is very difficult to understand by Assembly language is easy to understand by the
the human beings. human being as compare to machine language.
Modifications and error fixing cannot be done in Modifications and error fixing can be done in
machine language. assembly language.
Machine language is very difficult to memorize so it Easy to memorize the assembly language because
is not possible to learn the machine language. some alphabets and mnemonics are used.
Execution is fast in machine language because all Execution is slow as compared to machine
data is already present in binary format. language.
Language Processors –
Compilers, interpreters, translate programs written in high-level languages into machine
code that a computer understands. And assemblers translate programs written in low-level
or assembly language into machine code. In the compilation process, there are several
stages. To help programmers write error-free code, tools are available.
23
called source code. These source code cannot be executed directly by the computer and
must be converted into machine language to be executed. Hence, a special translator system
software is used to translate the program written in a high-level language into machine code
is called Language Processor and the program after translated into machine code (object
program/object code).
The language processor that reads the complete source program written in high-level
language as a whole in one go and translates it into an equivalent program in machine
language is called a Compiler. Example: C, C++, C#, Java.
In a compiler, the source code is translated to object code successfully if it is free of errors.
The compiler specifies the errors at the end of the compilation with line numbers when
there are any errors in the source code. The errors must be removed before the compiler can
successfully recompile the source code again
2. Assembler :
The Assembler is used to translate the program written in Assembly language into machine
code. The source program is an input of an assembler that contains assembly language
instructions. The output generated by the assembler is the object code or machine code
understandable by the computer. Assembler is basically the 1st interface that is able to
communicate humans with the machine. We need an Assembler to fill the gap between
human and machine so that they can communicate with each other. code written in
assembly language is some sort of mnemonics(instructions) like ADD, MUL, MUX, SUB,
DIV, MOV and so on. and the assembler is basically able to convert these mnemonics in
Binary code. Here, these mnemonics also depend upon the architecture of the machine.
24
For example, the architecture of intel 8085 and intel 8086 are different.
3. Interpreter :
The translation of a single statement of the source program into machine code is done by a
language processor and executes immediately before moving on to the next line is called an
interpreter. If there is an error in the statement, the interpreter terminates its translating
process at that statement and displays an error message. The interpreter moves on to the
next line for execution only after the removal of the error. An Interpreter directly executes
instructions written in a programming or scripting language without previously converting
them to an object code or machine code. Example: Perl, Python and Matlab.
The compiler takes a large amount of time to An interpreter takes less amount of
analyze the entire source code but the overall time to analyze the source code but
25
Compiler Interpreter
BIOS
BIOS stands for Basic Input/Output System. BIOS is the first program to run when the
computer starts. It is a ROM chip (EEPROM chip) found on motherboards and is used for
hardware initialization during the booting process. It is pre-installed in the computer
system. When BIOS boots up the computer system, it checks if all of the components are in
place and working and then it loads the operating system into the computer’s RAM from
the hard disk of the system.
Nowadays BIOS is written on flash memory, to ease the process of rewriting the BIOS
chip, whenever needed.
26
History of BIOS
BIOS was first introduced in 1975, in CP/M Operating System. Control Program for
Microcomputers, was developed for Intel 8080/85-based microcomputers by Gary Kildall
of Digital Research, Inc. The system had a simple boot loader in its ROM.
IBM classified the system-bios in two categories when PS/2 machines were introduced:
CBIOS: CBIOS stands for Compatibility BIOS. The real-mode portion
provided backward compatibility with current operating systems, thus was
named CBIOS.
ABIOS: The ABIOS stands for Advanced BIOS. It provided new interfaces
specically the one suited for multitasking OS.
Functions of BIOS
POST: Power on Self Test is the process performed by BIOS immediately after
the computer system starts to check any hardware related issues. if any error is
found in this process, the system alerts through flashing LEDs, audible beeps, or
error messages on the monitor, all of which are technically referred to as POST
codes, beep codes, and on-screen POST error messages, respectively.
27
It is because the BIOS and CMOS, setup configure the system’s crucial
information like the password, date, and time.
Bootdevice selection: One of the CMOS’s most important role is, it can alter the
device boot process. This is important for system restoration because the CMOS
may need to change boot priority from the hard drive to the optical drive or flash
drive to launch the operating system installer or adjust which hard drive to load
the operating system from.
Flowchart of BIOS
Features of BIOS
Every BIOS implementation is specifically designed for a particular type of
motherboard model or particular computer.
Originally, BIOS firmware was stored in the ROM memory but nowadays it is
stored in Flash memory so that it can be rewritten without removing the chip
from the motherboard.
The other reason for doing this is that it allows easy updates of BIOS firmware,
so new features can be added and bugs can be fixed.
The latest advancement of BIOS is UEFI(Unified Extensible Firmware
Interface).
Advantages
The computer system will gain better compatibility.
The booting time of system decreases.
The overall performance of system improves
Disadvantage
The disadvantag is that it is a time consuming process. BIOS often boots in 16-
bit real mode (not 32-bit nor 64-bit protected mode), and because of the type of
chip used, it is not always the fastest.
28
If something goes wrong during the process, the motherboard might get affected.
Solving this will not be an easy process.
29