MODULE 3
MODULE 3
Organization
Module 3
Basic Structure of
Computers
Functional Units
Functional Units
Arithmetic
Input and
logic
Memory
Output Control
I/O Processor
Memory unit:
• Its function into store programs and data. It is basically to two
types
1. Primary memory
2. Secondary memory
Cont..
1. Primary memory: -
Is the one exclusively associated with the processor and
operates at the electronics speeds programs must be stored
in this memory while they are being executed.
The memory contains a large number of semiconductors
storage cells.
Number of bits in each word is called word length of the
computer.
Programs must reside in the memory during execution.
Instructions and data can be written into the memory or read
out under the control of processor
Cont..
To provide easy access to a word in memory, a distinct
address is associated with each word location. Addresses are
numbers that identify memory location
2. Secondary memory: -
• Is used where large amounts of data & programs have to be
stored, particularly information that is accessed
infrequently.
• Examples: - Magnetic disks & tapes, optical disks (ie CD-
ROM‘s), floppies etc.,
Cont..
Arithmetic logic unit (ALU):-
• Most of the computer operators are executed in ALU of the
processor like addition, subtraction, division, multiplication,
etc. the operands are brought into the ALU from memory and
stored in high speed storage elements called register.
• Then according to the instructions the operation is performed
in the required sequence.
• The control and the ALU are many times faster than other
devices connected to a computer system.
• This enables a single processor to control a number of
external devices such as key boards, displays, magnetic and
optical disks, sensors and other mechanical controllers
Cont..
Control unit:-
• It effectively is the nerve center that sends signals to other
units and senses their states.
• The actual timing signals that govern the transfer of data
between input unit, processor, memory and output unit are
generated by the control unit.
• Operations of a computer:
Accept information in the form of programs and data through
an input unit and store it in the memory
Fetch the information stored in the memory, under program
control, into an ALU, where the information is processed
Output the processed information through an output unit
Control all activities inside the machine through a control unit
Basic Operational Concepts
Basic Operational Concepts
• Activity in a computer is governed by instructions.
• To perform a task, an appropriate program consisting of a
list of instructions is stored in the memory.
• Individual instructions are brought from the memory into
the processor, which executes the specified operations.
• Data to be used as operands are also stored in the
memory.
Cont..
Example:
• Add LOCA, R0
• This instruction adds the operand at memory
location LOCA, to operand in register R0 & places
the sum into register.
• This instruction requires the performance of several
steps,
1. First the instruction is fetched from the memory into
the processor.
2. The operand at LOCA is fetched and added to the
contents of R0
Cont..
3. Finally the resulting sum is stored in the register R0
N S
T
R
This is often referred to as the basic performance equation.
i 1
Ex:
If the SPEC rating = 50 , means that the computer under test is 50 times as fast
as the ultra sparc 10.
This is repeated for all the programs in the SPEC suit, and the geometric mean
of the result is computed.
Since actual execution time is measured the SPEC rating is a measure of the
combined effect of all factors affecting performance, including the compiler, the
OS, the processor, the memory of comp being tested.
Multiprocessors and Multicomputers
• Multiprocessor computer
Execute a number of different application tasks in parallel
Execute subtasks of a single large task in parallel
All processors have access to all of the memory – shared-memory
multiprocessor
Cost – processors, memory units, complex interconnection networks
• Multicomputers
Each computer only have access to its own memory
Exchange message via a communication network – message-passing
multicomputers
Chapter 2. Machine
Instructions and
Programs
Memory Locations,
Addresses, and
Operations
Memory Location, Addresses, and
Operation
n bits
first word
• Memory consists of
second word
many millions of
storage cells, each
•
of which can store 1 •
bit. •
last word
b31 b30 b1 b0
•
•
•
Sign bit: b31= 0 for positive numbers
b31= 1 for negative numbers
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 -4 2 -4 2 -3 2- 2 2 - 1 2 - 4 2- 1 2 - 2 2 -3 2 -4
i
Assumptions:
Begin execution here Move A,R0
i+4
3-instruction
program
- One memory operand
Add B,R0
segment per instruction
i+8 Move R0,C
- 32-bit word length
- Memory is byte
addressable
A - Full memory address
can be directly specified
in a single-word instruction
B Data for
the program
Two-phase procedure
-Instruction fetch
C -Instruction execute
Branching i+4
i+8
Add
Add
NUM2,R0
NUM3,R0
•
•
•
i + 4n - 4 Add NUMn,R0
i + 4n Move R0,SUM
•
•
•
SUM
NUM1
NUM2
•
•
•
NUMn
Branching LOOP
Clear R0
Determine address of
"Next" number and add
Program "Next" number to R0
loop
Decrement R1
Branch>0 LOOP
Branch target
Move R0,SUM
Conditional branch
•
•
•
SUM
N n
NUM1
•
•
•
NUMn
Condition Codes
• CONDITIONAL CODE FLAGS: The processor keeps track of
information about the results of various operations for use by
subsequent conditional branch instructions
– N –Negative 1 if results are Negative
– 0 if results are Positive
– Z –Zero 1 if results are Zero
– 0 if results are Non zero
– V –Overflow 1 if arithmetic overflow occurs
– 0 non overflow occurs
– C –Carry 1 if carry and from MSB bit
– 0 if there is no carry from MSB bit
Status Bits
Cn-1
A B
Cn ALU
F
V Z S C
Fn-1
Zero Check
Addressing Modes
Generating Memory Addresses
• Immediate
– The use of a constant in “MOV #5, R1”, i.e. R1 ← 5
• Register
– Indicate which register holds the operand
Addressing Modes
• Register Indirect
– Indicate the register that holds the number of the
register that holds the operand R1
MOV (R2), R1
R2 = 3
• Autoincrement / Autodecrement
– Access & update in 1 instr. R3 = 5
• Direct Address
– Use the given address to access a memory location
Addressing Modes
• Indirect Address
– Indicate the memory location that holds the
address of the memory location that holds the
data
AR = 101
100
101 0 1 0 4
102
103
104 1 1 0 A
Addressing Modes
• Relative Address
0
– EA = PC + Relative Addr 1
PC = 2 2
100
AR = 100
101
102 1 1 0 A
Could be Positive or 103
Negative 104
(2’s Complement)
Addressing Modes
• Indexed
– EA = Index Register + Relative Addr
Useful with XR = 2
“Autoincrement” or
“Autodecrement”
+
100
AR = 100
101
Could be Positive or
Negative 102 1 1 0 A
(2’s Complement) 103
104
Addressing Modes
• Base Register
– EA = Base Register + Relative Addr
Could be Positive or AR = 2
Negative
(2’s Complement)
+
100 0 0 0 5
BR = 100
101 0 0 1 2
102 0 0 0 A
Usually points to 103 0 1 0 7
the beginning of 104 0 0 5 9
an array
Addressing Modes
Name Assembler syntax Addressingfunction
• The different
ways in which Immediate #Value Op erand = Value
the location of
an operand is Register Ri EA = Ri
specified in an Absolute(Direct) LOC EA = LOC
instruction are
referred to as Indirect (Ri ) EA = [Ri ]
addressing (LOC) EA = [LOC]
modes.
Index X(R i) EA = [Ri ] + X
Figure 2.16. The Autoincrement addressing mode used in the program of Figure 2.12.