Professional Documents
Culture Documents
Computer Organization: UNIT-4
Computer Organization: UNIT-4
Computer Organization: UNIT-4
UNIT-4
Basic Structure of Computers
What is a computer?
A computer is an electronic device that manipulates
information, or data. It has the ability to store, retrieve,
and process data
HISTORY OF COMPUTERS
First Generation: Vacuum Tubes
ENIAC: The ENIAC (Electronic Numerical Integrator And
Computer), designed and constructed at the University of
Pennsylvania, was the world’s first general-purpose
electronic digital computer.
The project was a response to U.S needs during World War II.
THE VON NEUMANN MACHINE :The task of
entering and altering programs for the ENIAC was
extremely tedious.
a computer could get its instructions by reading them from
memory This idea is known as the stored-program
concept. The first publication of the idea was in a 1945
proposal by von Neumann for a new computer, the
EDVAC (Electronic Discrete Variable Computer)
In 1946, von Neumann and his colleagues began the
design of a new stored-program computer, referred to as
the IAS computer,
The IAS machine was the first electronic computer to be
built at the Institute for Advanced Study in Princeton,
New Jersey.
A main memory, which stores both data and instruction
An arithmetic and logic unit (ALU) capable of operating
on binary data
A control unit, which interprets the instructions in
memory and causes them to be executed
Input and output (I/O) equipment operated by the control
unit
Generations of Computers
Generation in computer terminology is a change in
technology a computer is/was being used
generation includes both hardware and software, which
together make up an entire computer system.
There are five computer generations known till date
First Generation
The period of first generation: 1946-1959. Vacuum tube
based.
Some computers of this generation were: • ENIAC •
EDVAC • UNIVAC
Second Generation The period of second generation: 1959-
1965. Transistor based.
In this generation, assembly language and high-level
programming languages like FORTRAN, COBOL were used.
Some computers of this generation were: • IBM 1620 • IBM
7094 • CDC 1604 • CDC 3600
Third Generation The period of third generation: 1965-1971.
Integrated Circuit based.
High-level languages (FORTRAN-II TO IV, COBOL, PASCAL
PL/1, BASIC, ALGOL-68 etc.) were used during this generation.
Some computers of this generation were: • IBM-360 series •
Honeywell-6000 series • PDP (Personal Data Processor)
Fourth Generation The period of fourth generation: 1971-1980. VLSI
microprocessor based
All the high-level languages like C, C++, DBASE etc., were used in this
generation.
Some computers of this generation were: • DEC 10 • STAR 1000 • PDP
11 • CRAY-1(Super Computer) • CRAY-X-MP(Super Computer)
Fifth Generation The period of fifth generation: 1980-onwards. ULSI
microprocessor based
This generation is based on parallel processing hardware and AI
(Artificial Intelligence) software.
All the high-level languages like C and C++, Java, .Net etc., are used in
this generation.
Some computer types of this generation are: • Desktop • Laptop •
Notebook • Ultrabook • Chromebook
The different types of computers are
1. Personal computers: - This is the most common type
found in homes, schools, Business offices etc., It is the most
common type of desk top computers with processing and
storage units along with various input and output devices.
2. Note book computers: - These are compact and portable
versions of PC
3. Work stations: - These have high resolution input/output
(I/O) graphics capability, but with same dimensions as that
of desktop computer. These are used in engineering
applications of interactive design work.
4. Enterprise systems: - These are used for business data
processing in medium to large corporations that require
much more computing power and storage capacity than
work stations. Internet associated with servers have
become a dominant worldwide source of all types of
information.
5. Super computers: -These are used for large scale
numerical calculations required in the applications like
weather forecasting etc.,
Digital Computer
Digital computers use the binary number system, which
has two digits: 0 and 1. A binary digit is called a bit.
Information is represented in digital computers in groups
of bits.
All the content that is written in English will be converted
to binary language and thus computers and humans
communicate with each other.
Some of the basic examples of digital devices are Personal
computers, Desktops, Laptops, Smartphones, and
Mobiles.
Review of Data Representation
Data refers to the symbols that represent people, events,
things, and ideas. Data can be a name, a number, the
colors in a photograph, or the notes in a musical
composition
Data Representation refers to the form in which data is
stored, processed, and transmitted.
Devices such as smartphones, iPods, and computers store
data in digital formats that can be handled by electronic
circuitry
Digitization is the process of converting information, such as
text, numbers, photo, or music, into digital data that can be
manipulated by electronic devices.
The 0s and 1s used to represent digital data are referred to as
binary digits — from this term we get the word bit that stands
for binary digit. • A bit is a 0 or 1 used in the digital
representation of data
Numeric data consists of numbers that can be used in
arithmetic operations.
Digital devices represent numeric data using the binary
number system, also called base 2.
The binary number system only has two digits: 0 and 1
Digital devices employ several types of codes to represent
character data, including ASCII, Unicode, and their variants
ASCII (American Standard Code for Information Interchange,
pronounced “ASK ee”) requires seven bits for each character.
• The ASCII code for an uppercase A is 1000001
Extended ASCII is a superset of ASCII that uses eight bits for
each character.
For example, Extended ASCII represents the uppercase letter
A as 01000001.
Using eight bits instead of seven bits allows Extended ASCII
to provide codes for 256 characters
Unicode (pronounced “YOU ni code”) uses sixteen bits
and provides codes or 65,000 characters. • This is a bonus
for representing the alphabets of multiple languages
UTF-8 is a variable-length coding scheme that uses seven
bits for common ASCII characters but uses sixteen-bit
Unicode as necessary
Each octal digit corresponds to three binary digits
Each hexadecimal digit corresponds to four binary digits
Rather than specifying numbers in binary form, refer to them in octal
or hexadecimal and reduce the number of digits by 1/3 or ¼,
respectively
Fraction Exponent
+0.6132789 +04
Indirect Address
It is sometimes convenient to use the address bits of an instruction code not as an
address but as the actual operand.
When the second part of an instruction code specifies an operand, the instruction is said
to have an immediate operand.
When the second part specifies the address of an operand, the
instruction is said to have a direct address.
a third possibility called indirect address, where the bits in the second part of the
instruction designate an address of a memory word in which the address of the operand
is found.
One bit of the instruction code can be used to distinguish between a direct and an
indirect address.
It consists of a 3-bit operation code, a 12-bit address, and an indirect address
mode bit designated by I. The mode bit is 0 for a direct address and 1 for an
indirect address.
A direct address instruction . It is placed in address 22 in memory. The I bit is 0,
so
the instruction is recognized as a direct address instruction.
The opcode specifies an ADD instruction, and the address part is the binary
equivalent of 457. The control finds the operand in memory at address 457 and
adds it to the content of AC.
The instruction in address 35 has a mode bit I = 1. Therefore, it is recognized as
an indirect address instruction. The address part is the binary equivalent of 300.
The control goes to address 300 to find the address of the operand. The address
of the operand in this case is 1350.
The operand found in address 1350 is then added to the content of AC. The
indirect address instruction needs two references to memory to fetch an operand.
The first reference is needed to read the address of the
operand the second is for the operand itself.
We define the effective address to be the address of the
operand in a computation-type instruction or the target
address in a branch-type instruction
Thus the effective address in the instruction is 457 and in
the instruction is 1350.
Computer Instructions
The basic computer has three instruction code formats, Each format has 16
bits A memory-reference instruction uses 12 bits to specify an address and
one bit to specify the addressing mode I. I is equal to 0 for direct address
and to 1 for indirect address
The register reference instructions are recognized by the operation code 11l
with a 0 in the leftmost bit (bit 15) of the instruction.
A register-reference instruction specifies an operation on or a test of the AC
register. An operand from memory is not needed; therefore, the other 12
bits are used to specify the operation or test to be executed.
Similarly, an input-output instruction does not need a reference to memory
and is recognized by the operation code I l l with a 1 in the leftmost bit of
the instruction. The remaining 12 bits are used to specify the type of input-
output operation or test performed.
The type of instruction is recognized by the computer control
from the four bits in positions 12 through 15 of the instruction.
If the three opcode bits in positions 12 though 14 are not equal
to 1l l , the instruction is a memory-reference type and the bit in
position 15 is taken as the addressing mode I.
If the 3-bit opcode is equal to 1ll, control then inspects the bit in
position 15. If this bit is 0, the instruction is a register-reference
type. If the bit i s 1, the instruction is an input output type.
Note that the bit in position 15 of the instruction code is
designated by the symbol I but is not used as a mode bit when
the operation code is equal to 111.
A memory-reference instruction has an address part of 12
bits. The address part is denoted by three
x's and stand for the three hexadecimal digits
corresponding to the 12-bit address.
The last bit of the instruction is designated by the symbol I.
When I = 0, the last four bits of an instruction have a
hexadecimal digit equivalent from 0 to 6 since
the last bit is 0.
When I = I, the hexadecimal digit equivalent of the last
four bits of the instruction ranges from 8 to E since the last
bit is I.
Register-reference instructions use 16 bits to specify an
operation. The leftmost four bits are always 0111, which is
equivalent to hexadecimal 7.
The other three hexadecimal digits give the binary
equivalent of the remaining 12 bits.
The input-output instructions also use all 16 bits to specify
an operation. The last four bits are always 1111,
equivalent to hexadecimal F.
Instruction Set Completeness
The set of instructions are said to be complete if the
computer includes a sufficient number of instructions in
each of the following categories:
1. Arithmetic, logical, and shift instructions
2. Instructions for moving information to and from
memory and processor registers
3. Program control instructions together with instructions
that check status conditions
4. Input and output Instructions
Instruction Cycle
In the basic computer each instruction cycle consists of the
following phases:
1. Fetch an instruction from memory.
2. Decode the instruction.
3. Read the effective address from memory if the instruction
has an indirect address.
4. Execute the instruction.
Upon the completion of step 4, the control goes back to step 1
to fetch, decode, and execute the next instruction. This process
continues indefinitely unless a HALT instruction is
encountered.
Fetch
& Decode
PC is loaded with the address of the first instruction in the program.
The micro-operations for fetch and decode phases are as follows:
PUSH X will push the word at address X to the top of thestack. The stack
pointer is updated automatically.
Operation-type instructions do not need an address field in stack-organized
computers. This is because the operation is performed on the two items that
are on top of the stack.
The instruction ADD in a stack computer consists of an operation code only
with no address field.
This operation has the effect of popping the two top numbers from the stack,
adding the numbers, and pushing the sum into the stack.
There is no need to specify operands with an address field since all operands
are implied to be inthe stack.
To illustrate the influence of the number of addresses on
computer programs, we will evaluate the arithmetic statement
X = (A + B) • (C + D) using zero, one, two, or three address
instructions.
We will use the symbols
ADD, SUB, MUL, and DIV for the four arithmetic operations;
MOV for the transfer-type operation; and LOAD and STORE
for transfers to and from memory and AC register.
We will assume that the operands are in memory addresses A,
B, C, and D, and the result must be stored in memory
at address X.
Three-Address Instructions
Computers with three-address instruction formats can use each address
field to specify either a processor register or a memory operand. The
program in assembly language that evaluates
X = (A + B) • (C + D)
MOL X , R1 , R2 M[X] R1 • R 2
It is assumed that the computer has two processor registers, R1 and R2. The
symbol M [A] denotes the operand at memory address symbolized by A
Two-Address Instructions
Two-address instructions are the most common in commercial
computers. Here again each address field can specify either a
processor register or a memory word.
The program to evaluate X = (A + B) • (C + D)
MO V R1 , A R1 M [ A ]
ADD R1 , B R1 R1 + M [ B ]
MO V R2 , C R2 M [ C ]
ADD R2 , D R2 R2 + M [ D ]
MUL R1 , R2 R1 R1 • R 2
MOV X , R1 M[ X ]R1
The MOV instruction moves or transfers the operands to and from
memory and processor registers.
One-Address Instructions
One-address instructions use an implied accumulator (AC) register for all data manipulation.
For multiplication and division there is a need for a second
register. However, here we will neglect the second register and assume that
the AC contains the result of all operations.
The program to evaluate X = (A + B) • (C + D) is
LOAD A A C M[AJ
ADD B A C AC + M[B]
STORE T M[T] AC
LOAD C AC M [ C ]
ADD D AC AC+M[ D ]
MUL T AC AC• M[T]
STORE X M [ X ] A C
All operations are done between the AC register and a memory operand.
T is the address of a temporary memory location required for storing the
intermediate result.
Zero-Address Instructions
A stack-organized computer does not use an address field for the
instructions ADD and MUL. The PUSH and POP instructions,
however, need an address field to specify the operand that
communicates with the stack.
The following program shows how X = (A + B) • (C + D) will be
written for a stack organized computer. (TOS stands for top of
stack.)
To evaluate arithmetic expressions in a stack computer, it
is necessary to convert the expression into reverse Polish
notation. The name "zero-address“ is given to this type of
computer because of the absence of an address field in
the computational instructions
RISC Instruction
The instruction set of a typical RISC processor is restricted to
the use of load and store instructions when communicating
between memory and CPU.
All other instructions are executed within the registers of the
CPU without referring to memory.
A program for a RISC type CPU consists of LOAD and
STORE instructions that have one memory and one register
address, and computational-type instructions that have three
addresses with all three specifying processor registers.
The following is a program to evaluate X = (A + B) * (C + D)
Addressing Modes
The addressing mode specifies a rule for interpreting or
modifying the address field of the instruction before the operand
is actually referenced.
Computers use addressing mode techniques for the purpose of
accommodating one or both of the following provisions:
1. To give programming versatility to the user by providing such
facilities as pointers to memory, counters for loop control, indexing
of data, and program relocation.
2. To reduce the number of bits in the addressing field of the
instruction.
There are basic 10 addressing modes supported by the computer.
1. Implied Mode
2. Immediate Mode
3. Register Mode
4. Register Indirect Mode
5. Auto increment or Auto decrement Mode
6. Direct Address Mode
7. Indirect Address Mode
8. Relative Address Mode
9. Indexed Addressing Mode
10. Base Register Addressing Mode
Implied Mode
Operands are specified implicitly in the definition of the
instruction.
For example, the instruction “complement accumulator
(CMA)” is an implied-mode instruction because the
operand in the accumulator register is implied in the
definition of the instruction.
In fact, all register reference instructions that use an
accumulator and zero address instructions are implied
mode instructions
Immediate Mode
Operand is specified in the instruction itself.
In other words, an immediate-mode instruction has an
operand field rather than an address field.
The operand field contains the actual operand to be used
in conjunction with the operation specified in the
instruction.
Immediate mode of instructions is useful for initializing
register to constant value.
E.g. MOV R1, 05H
instruction copies immediate number 05H to R1 register.
Register Mode
Operands are in registers that reside within the CPU.
The particular register is selected from a register field in
the instruction.
E.g. MOV AX, BX
move value from BX to AX register
Register Indirect Mode
In this mode the instruction specifies a register in the CPU
whose contents give the address of the operand in memory.
Before using a register indirect mode instruction, the
programmer must ensure that the memory address of the
operand is placed in the processor register with a previous
instruction.
The advantage of this mode is that address field of the
instruction uses fewer bits to select a register than would
have been required to specify a memory address directly.
E.g. MOV [R1], R2
value of R2 is moved to the memory location specified in R1
Autoincrement or Autodecrement Mode
This is similar to the register indirect mode expect that the
register is incremented or decremented after (or before) its
value is used to access memory.
When the address stored in the register refers to a table of
data in memory, it is necessary to increment or decrement
the register after every access to the table. This can be
achieved by using the increment or decrement instruction.
Direct Address Mode
In this mode the effective address is equal to the address
part of the instruction.
The operand resides in memory and its address is given
directly by the address field of the instruction.
E.g. ADD 457
Indirect Address Mode
In this mode the address field of the instruction gives the
address where the effective address is stored in memory.
Control fetches the instruction from memory and uses its
address part to access memory again to read the effective
address.
The effective address in this mode is obtained from the
following computational:
Effective address = address part of instruction + content of
CPU register
Relative Address Mode
In this mode the content of the program counter is added
to the address part of the instruction in order to obtain the
effective address.
The address part of the instruction is usually a signed
number which can be either positive or negative.
Effective address = address part of instruction + content of
PC
Indexed Addressing Mode
In this mode the content of an index register is added to
the address part of the instruction to obtain the effective
address.
The indexed register is a special CPU register that contain
an index value.
The address field of the instruction defines the beginning
address of a data array in memory.
Each operand in the array is stored in memory relative to
the begging address.
Effective address = address part of instruction + content of
index register
Base Register Addressing Mode
In this mode the content of a base register is added to the
address part of the instruction to obtain the effective
address.
A base register is assumed to hold a base address and the
address field of the instruction gives a displacement
relative to this base address.
The base register addressing mode is used in computers to
facilitate the relocation of programs in memory.
Effective address = address part of instruction + content of
base register
Numerical Example
The two-word instruction at address 200 and 201 is a "load
to AC" instruction with an address field equal to 500.
The first word of the instruction specifies the operation
code and mode, and the second word specifies the address
part.
PC has the value 200 for fetching this instruction. The
content of processor register R 1 is 400, and the content of
an index register XR is 100. AC receives the operand after
the instruction is executed.
In the direct address mode the effective address is the
address part of the instruction 500 and the operand to be
loaded into AC is 800. In the immediate mode the second
word of the instruction is taken as the operand rather than
an address, so 500 is loaded into AC
In the indirect mode the effective address
is stored in memory at address 500. Therefore, the
effective address is 800 and
the operand is 300.
In the relative mode the effective address is 500 + 202 =
702 and the operand is 325. (Note that the value in PC after the fetch
phase and during the execute phase is 202.) In the index mode the
effective address is XR + 500 = 100 + 500 = 600 and the operand is 900.
In the register mode the operand is in R 1 and 400 is loaded into AC .
(There is no effective address in this case.)
In the register indirect mode the effective address is 400, equal to
the content of R 1 and the operand loaded into AC is 700.
The autoincrement mode is the same as the register indirect mode except
that R 1 is incremented to 401 after the execution of the instruction.
The autodecrement mode decrements R1 to 399 prior to the execution of
the instruction. The operand loaded into AC is now 450.
Reduced Instruction Set Computer (RISC)
Characteristics of RISC are as follows:
Relatively few instructions
Relatively few addressing modes
Memory access limited to load and store instructions
All operations done within the registers of the CPU
Fixed-length, easily decoded instruction format
Single-cycle instruction execution
Hardwired rather than microprogrammed control
A relatively large number of registers in the processor unit
Use of overlapped register windows to speed-up procedure call and return
Efficient instruction pipeline
Compiler support for efficient translation of high-level language programs
into machine language programs
Complex Instruction Set Computer (CISC)
Characteristics of CISC are as follows:
A larger number of instructions – typically from 100 to 250
instructions
Some instructions that perform specialized tasks and are used
infrequently
A large variety of addressing modes – typically from 5 to 20
different modes
Variable-length instruction formats
Instructions that manipulate operands in memory
Overlapped Register Window
A characteristic of some RISC processors is their use of
overlapped register windows to provide the passing of
parameters and avoid the need for saving and restoring
register values.
Each procedure call results in the allocation of a new
window consisting of a set of registers from the register
file for use by the new procedure.
Windows for adjacent procedures have overlapping
registers that are shared to provide the passing of
parameters and results.
number of global registers = G
number of local registers in each window = L
number of registers common to two windows = C
number of windows = W