LD and CO Module 3
LD and CO Module 3
21IST34
Module 3
Prepared by
MOHAN D N
Assistant Professor
Department of ISE ,NCET
Bengaluru
Functional Units
Functional Units
Arithmet
Input ic
and
logic
Memory
Output Control
I/O Processo
r
Instructions/machine instructions
Govern the transfer of information within a
computer as well as between the computer and
its I/O devices
Specify the arithmetic and logic
operations to be performed
Program
Data
Used as operands by the instructions
Source program
Encoded in binary code – 0 and
1
Memory Unit
Store programs and data
Two classes of storage
Primary storage
Fast
Programs must be stored in memory while they are being
executed
Large number of semiconductor storage cells
Processed in words
Address
RAM and memory access time
Memory hierarchy – cache, main memory
Secondary storage – larger and cheaper
Arithmetic and Logic Unit (ALU)
Data
PC Address Register #
Register A
Instructions Bank Address
L
Register #
Instruction Data Memory
Memory U
Register #
Data
overwritten?
Connection Between the Processor
and the Memory
Registers
Instruction
register (IR)
Program counter (PC)
General-purpose register (R –
0
Rn-1)
Memory address register (MAR)
Memory data register (MDR)
Typical Operating Steps
Programs reside in the memory through
input devices
PC is set to point to the first instruction
The contents of PC are transferred to
MAR
A Read signal is sent to the memory
The first instruction is read out and
loaded into MDR
The contents of MDR are transferred
to IR
Decode and execute the instruction
Typical Operating Steps (Cont’)
bus
Speed Issue
Different devices have
different transfer/operate
speed.
If the speed of bus is bounded by the
Bu
s
Cost
Memory management
Processor Clock
Clock, clock cycle, and clock rate
The execution of each instruction is
N S
T
R
Pipeline and Superscalar Operation
pipelining
S is close to 1 even though the number of
basic steps per instruction may be
considerably larger
It is much easier to implement efficient
pipelining in processor with simple
instruction sets
Reduced Instruction Set Computers
(RISC)
Compiler
A compiler translates a high-level language
program into a sequence of machine
instructions.
To reduce N, we need a suitable machine
instruction set and a compiler that makes
good use of it.
Goal – reduce N×S
A compiler may not be designed for a
specific processor; however, a high-quality
compiler is usually designed for, and with, a
specific processor.
Performance Measurement
T is difficult to compute.
Measure computer performance using benchmark programs.
System Performance Evaluation Corporation (SPEC) selects
and publishes representative application programs for
different application domains, together with test results for
many commercially available computers.
Compile and run (no simulation)
Reference computer
SP E C rating ( SP E C i )
n
i1
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
second
consists of word
many millions of
•
storage cells, •
•
each of which
can store 1 bit.
i th
Data is usually word
accessed in n- •
bit groups. n is •
•
called word
length. last
word
Figure Memory
Memory Location, Addresses, and
Operation
32-bit
word length
32
example bits
b1 b0
•
•
•
b31 b30
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k
k k k k k k
2 - 2 -4 2 -3 2- 2 - 1 2 - 2- 2 - 2 2-3 2 -4
4 2 4 1
Sequencing
“Must-Perform” Operations
Data transfers between the memory
and the processor registers
Arithmetic and logic operations on
data
Program sequencing and control
I/O transfers
Register Transfer Notation
Identifya location by a symbolic
name standing for its hardware
binary address (LOC, R0,…)
Contents of a location are denoted by
[R2]
CPU Organization
Single Accumulator
Result usually goes to the Accumulator
Accumulator has to be saved to
memory quite often
General Register
Registers hold operands thus reduce
memory traffic
Register bookkeeping
Stack
Operands and result are always in the
stack
Instruction Formats
Three-Address Instructions
ADD R1, R2, R3 R1 ←
R2 + R3
Two-Address Instructions
ADD R1, R2 R1 ← R1 + R2
One-Address
ADD M Instructions AC ← AC +
Zero-Address M[AR]
Instructions TOS ← TOS + (TOS –
ADD 1)
RISC
LotsInstructions
of registers. Memory is restricted to Load
& Store
Branching 4
i+
Add NUM3,R0
8 •
•
•
Add NUMn,R0
i + 4n -
4 Move R0,SUM
i + 4n
•
•
•
SUM
NUM
1
NUM •
•
2 •
NUMn
Branching LOOP
Determine address of
"Next" number and
Progra "Next"
add number to R0
m
loop Decrement R1
Branch>0 LOOP
Branch target
Move
R0,SUM
Conditional
branch •
•
•
SUM
N
n
NUM
Figure Using a loop to add n 1
2.10. numbers.
NUM
•
2 •
•
NUMn
Condition Codes
Condition code flags
Condition code register / status
register
N (negative)
Z (zero)
V (overflow)
C (carry)
different flags
Conditional Branch Instructions
Example: A: 11110000
A: 1 1 1 1 0 0 +(−B): 1 1 1 0 1 1 0
00 0
11011100
B: 0 0 0 1 0 1
00 C=1 Z=0
S=1
V=0
Status Bits
Cn-1 A B
Cn ALU
F
V Z S C
Fn-1
Zero Check
Addressing
Modes
Generating Memory Addresses
How to specify the address of branch
target?
Can we give the memory operand
d AC is implied in “ADD
M[AR]” in “One-
Address” instr.
TOS is implied in “ADD” in “Zero-Address”
instr.
Immediate
The use of a constant in R1, 5”, i.e. R1
“MOV 5 ←
Register
Indicate which register holds the
operand
Addressing Modes
Register Indirect
Indicate the register that holds the
register that
number holds the
of the R1
operand
MOV R1, (R2)
Autoincrement R2 = 3
/
Autodecrement R3 = 5
Access & update in 1 instr.
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 1
Addr PC = 2 2
100
AR = 100
101
102 1 1 0
Could be Positive or 103 A
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
(2’s Complement) 103 A
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 Immediate #Value Operand = Value
ways in
which the Register Ri EA = Ri
location of Absolute LOC EA = LOC
an operand (Direct)
is specified
in an Indirect (Ri ) EA = [Ri ]
instruction (LOC) EA = [LOC]
are referred Index X(R i) EA = [Ri ] + X
to as
addressing Basewith index (Ri ,Rj ) EA = [Ri ] + [Rj ]
modes.
Base with index X(R i,Rj ) EA = [Ri ] + [Rj ]
and offset
+ X
Relative X(PC) EA = [PC] +
X
Autoincreme (Ri )
+ EA = [Ri ] ;
nt Increment
Autodecreme (Ri Ri
nt )
Decrement R
Indexing and Arrays
Index mode – the effective address of the
operand is generated by adding a constant
value to the contents of a register.
Index register
X(Ri): EA = X + [Ri]
The constant X may be given either as an
explicit number or as a symbolic name
representing a numerical value.
If X is shorter than a word, sign-extension
is needed.
Indexing and Arrays
In general, the Index mode facilitates
access to an operand whose location
is defined relative to a reference point
within the data structure in which the
operand appears.
Several variations:
n – is passed by value
(actual value is
passed)
NUM1 – passed by
reference. address is
passed ( not the
actual entries ofFigur
the2.26. Program of Figure 2.16 written as a subroutine; parameters passed on
list but the address
e of
the stack. www.bookspar.com | Website for
students |
first element is VTU NOTES