SlideShare a Scribd company logo
1 of 131
Download to read offline
Computer Architecture and Organization 
Unit I
Architecture & Organization 
 Architecture is those attributes visible to the programmer 
 Instruction set, number of bits used for data representation, I/O 
mechanisms, addressing techniques. 
 Organization is how features are implemented (Transparent to the 
programmer) 
 Control signals, interfaces, memory technology.
Architecture & Organization Conti... 
 All Intel x86 family share the same basic architecture 
 The IBM System/370 family share the same basic architecture(1970) 
 Organization differs between different versions
Structure & Function 
 A computer is a complex system: contemporary computers contains 
millions of elementary electronic components. 
 The hierarchical nature of complex system is essential for both their 
design and description. 
 The designer need only deal with a particular level of the system at a time. 
at each level, the system consists of a set of components and their 
interrelationships.
Structure & Function 
At each level, the designer is concerned with 
structure and function . 
 Structure is the way in which components relate to 
each other
Functions 
 All computer functions are: 
 Data processing: (must be able to process data) 
 Data storage: (short time and long term Ex: files) 
 Data movement: (when data are received from or delivered to a device 
that directly connected to the computer ,the process known as input-output 
(I/O) and the device is referred to as a peripheral. 
 Control: ( above 3 functions and manages the resources) 
 Function is the operation of individual components as part of the structure
Functional View
Operations (a) Data movement
Operations (a) Data movement conti… 
 Simple transferring data from one peripheral or communications line to 
another. 
 when data are moved over longer distance ,to or from a remote device, the 
process is known as data communication. 
 the computer must be able to move data between itself and the outside 
world.
Operations (b) Storage
Operations (b) Storage conti…. 
 Data transferred from the External environment to computer storage (read) 
and vice versa (write). 
 Short-term storage used to store data temporarily. 
 long-term storage used to store data permanently (files of data are stored 
on the computer for subsequent retrieval and update.
Operation (c) Processing from/to storage
Operation (d) 
Processing from storage to I/O
Structure - Top Level 
Computer 
Computer 
Main 
Memory 
Systems 
Interconnection 
Input 
Output 
Peripherals 
Communication 
lines 
Central 
Processing 
Unit
Structure…. 
• Four main structural components: 
- central processing unit(CPU): 
controls the operation of the computer 
and perform its data processing functions: 
often simply referred to as processor. 
- Main memory: stores data 
- I/O: moves data between computer and 
its external environment. 
- system interconnections: some 
mechanism that provides for 
communication among CPU,mainmemory, 
and I/O.
Structure - The CPU 
Computer Arithmetic 
and 
Login Unit 
Internal CPU 
Interconnection 
Control 
Unit 
Registers 
CPU 
I/O 
System 
Bus 
Memory 
CPU
Structure - The CPU( components) 
• Four main components: 
- control unit : controls the operation of 
CPU and hence the computer. 
- Arithmetic and logic unit(ALU): perform 
the computer’s data processing function 
(addition ,subtraction etc) 
- Registers: provides storage internal to 
the CPU. 
- CPU interconnection: some mechanism 
that provides for communication among 
the control unit,ALU, and registers.
Structure - The Control Unit 
CPU 
Control Unit 
Registers and 
Decoders 
Control 
Memory 
Sequencing 
Login 
Control 
Unit 
ALU 
Internal 
Bus 
Registers 
Control Unit
First-Generation Computers 
• Late 1940s and 1950s 
• Stored-program computers 
• Programmed in machine level language 
• Examples: IAS, ENIAC, EDVAC, UNIVAC, 
Mark I, IBM 701 
• UNIVAC ( Universal Automatic computer ) 
• ENIAC (Electronic numerical integrator 
and computer) 
• EDVAC ( Electronic Discrete Variable 
computer)
ENIAC - background 
• Electronic Numerical Integrator And 
Computer 
• Eckert and Mauchly 
• University of Pennsylvania 
• Trajectory tables for weapons 
• Started 1943 
• Finished 1946 
—Too late for war effort 
• Used until 1955.
ENIAC – details: 
• Decimal (not binary) 
• 20 accumulators of 10 digits 
• Programmed manually by switches 
• 18,000 vacuum tubes 
• 30 tons 
• 15,000 square feet 
• 140 kW power consumption 
• 5,000 additions per second
von Neumann/Turing 
• Stored Program concept 
• Main memory storing programs and data 
• ALU operating on binary data 
• Control unit interpreting instructions from 
memory and executing 
• Input and output equipment operated by 
control unit 
• Princeton Institute for Advanced Studies 
—IAS 
• Completed 1952
John von Neumann (1903-1957)
Structure of von Neumann machine
IAS Computer Machine Language 
• 40-bit word, two machine instructions per 
word. 
Left instruction Right instruction 
7 8 bit 0 
8-bit opcode 12-bit memory address 
19 20 27 28 39 
(operand)
IAS - details 
• 1000 x 40 bit words 
—Binary number 
—2 x 20 bit instructions 
• Set of registers (storage in CPU) 
—Memory Buffer Register 
—Memory Address Register 
—Instruction Register 
—Instruction Buffer Register 
—Program Counter 
—Accumulator 
—Multiplier Quotient
Structure of IAS – 
detail
Registers 
• Memory buffer Register(MBR): 
contains a word to be stored in memory ,or is used to receive a 
word from memory. 
• Memory Address Register (MAR): 
specifies address in memory or the word to be written from or 
read into the MBR. 
• Instruction Register(IR): 
contains the 8 bit opcode instruction being executed. 
• Instruction Buffer Register (IBR): 
employed to hold temporarily the right hand instruction from a 
word in memory. 
• Program Counter (PC): 
contains the address of the next instruction-pair to be fetched 
from memory. 
• Multiplier Quotient ( MQ): (for multiply and divide instruction) 
used to store the remainder.
IAS Instructions 
• The IAS computer had a total of 21 instructions 
and grouped as follows: 
― Data Transfer: Move data between memory and ALU 
registers or between ALU Registers. 
― Unconditional branch: 
Normally, the control unit executes instruction in 
sequence from memory .This sequence can be 
changed by a branch instruction. 
Conditional Branch: depends on condition. 
― Arithmetic: Operations performed by the ALU. 
― Address modify: 
Address to be computed in the ALU and then 
inserted into instructions stored in memory.
Data Transfer Instructions 
Instruction 
Type 
Opcode SYBOLIC Description 
Data transfer 
00001010 LOAD MQ AC‹― MQ 
00001001 LOAD MQ M(X) MQ‹― Memory (X) 
00100001 STOR M(X) Memory(X) ‹― AC 
00000001 LOAD M(X) AC ‹― Memory(X) 
00000010 LOAD –M(X) AC ‹― -M(X) 
00000011 LOAD IM(X) AC ‹― Absolute of 
M(X)
Unconditional Branch 
Instruction 
Type 
Opcode Symbolic Description 
Unconditional 
Branch 
00001101 JUMP M(X,0:19) Take next 
instruction from 
left half of M(x) 
00001110 JUMP 
M(X,20:39) 
Take the 
instruction from 
right half of 
M(x)
Conditional Branch 
Instruction 
Type 
Opcode Symbolic Description 
Conditional 
Branch 
00001111 JUMP+M(X,0:19 
) 
If no in AC is 
+ve take the 
next instruction 
from left half of 
M(X) 
00010000 JUMP+M(X,20:3 
9) 
If no in the AC 
is +ve take next 
instruction from 
right half of 
M(X)
Arithmetic 
Instruction 
Type 
Opcode Symbolic Description 
Arithmetic 
00000101 ADD M(X) AC+M(X) 
AC ‹― result 
00000110 SUB M(X) AC-M(X) 
AC ‹― Result 
00001011 MUL M(X) Multiply M(X) by 
MQ 
AC ‹― MSB 
MQ ‹― LSB 
00001100 DIV Divide AC by MQ 
MQ ‹― quotient 
AC ‹― 
REMAINDER 
00010100 LSH Left shit 1 Bit 
position(Multiply) 
00010101 RSH Shift Right bit one 
position (DIVIDE)
Von Neumann Bottleneck 
• Von Neumann architecture uses the same 
memory for instructions (program) and 
data. 
• The time spent in memory accesses can 
limit the performance. This phenomenon 
is sometimes referred to as von Neumann 
bottleneck. 
• To avoid the bottleneck, later 
architectures restrict most operands to 
registers.
Second Generation Computers 
• 1955 to 1964 
• Transistor replaced vacuum tubes. 
• Magnetic core memories. 
• Floating-point arithmetic. 
• Assembly level languages 
• Example: IBM 7094 
DEC – 1957 (Digital Equipment 
corporation) 
—Produced PDP-1 ( Programmed data 
processor)
Transistors 
• Replaced vacuum tubes 
• Smaller 
• Cheaper 
• Less heat dissipation 
• Solid State device 
• Made from Silicon (Sand) 
• Invented 1947 at Bell Labs 
• William Shockley et al.
Third Generation Computers 
• Beyond 1965 
• Integrated circuit (IC) technology. 
• Semiconductor memories. 
• Memory hierarchy, virtual memories and 
caches. 
• Time-sharing. 
• Parallel processing and pipelining. 
• Microprogramming. 
• Examples: IBM 360 and 370, CYBER, 
ILLIAC IV, DEC PDP and VAX, Amdahl 470
The Now Generation 
• Personal computers 
• Laptops and Palmtops 
• Networking and wireless 
• And the future! 
– Nanotechnology 
– Optical computing 
– Quantum computing 
– Molecular computing
Program Concept 
• Hardwired systems are inflexible 
• General purpose hardware can do 
different tasks, given correct control 
signals 
• Instead of re-wiring, supply a new set of 
control signals
What is a program? 
• A sequence of steps 
• For each step, an arithmetic or logical 
operation is done 
• For each operation, a different set of 
control signals is needed
Function of Control Unit 
• For each operation a unique code is 
provided 
—e.g. ADD, MOVE 
• A hardware segment accepts the code and 
issues the control signals 
• We have a computer!
Data processor model 
• You can think of a computer as a data processor. 
• Is it a specific-purpose machine or a general-purpose 
machine?
Programmable data processor model 
• A program is a set of instructions that tells the computer 
what to do with data. 
• A program is a set of instructions written in a computer 
language. 
• The output data depend on the combination of two factors: 
the input data and the program.
Same program, different data
Same data, 
different 
programs
Components 
• The Control Unit and the Arithmetic and 
Logic Unit constitute the Central 
Processing Unit 
• Data and instructions need to get into the 
system and results out 
—Input/output 
• Temporary storage of code and results is 
needed 
—Main memory
Computer Components: 
Top Level View
Instruction Cycle 
• Two steps: 
—Fetch 
—Execute
Fetch Cycle 
• Program Counter (PC) holds address of 
next instruction to fetch 
• Processor fetches instruction from 
memory location pointed to by PC 
• Increment PC 
—Unless told otherwise 
• Instruction loaded into Instruction 
Register (IR) 
• Processor interprets instruction and 
performs required actions
Execute Cycle 
• Processor-memory 
—data transfer between CPU and main memory 
• Processor I/O 
—Data transfer between CPU and I/O module 
• Data processing 
—Some arithmetic or logical operation on data 
• Control 
—Alteration of sequence of operations 
—e.g. jump 
• Combination of above
Example of Program Execution
Explanation 
• Step 1: 
The PC contains the 300, the address of 
the first instruction. This instruction (the 
value 1940 in Hex) is loaded into the IR 
and PC Incremented. 
• step 2: 
The first 4 bits( First Hex digit) in IR 
indicate that AC is to be loaded.the 
remaining 12 bits (3 Hex digits) specify 
the address (940) from which data are to 
be loaded.
Explanation 
• Step 3: 
The next instruction (5941) is fectched 
frunited way that you have everything om 
location 301 and the pc incremented. 
• Step 4: 
The old contents of the AC and the 
contents of location 941 are added and 
the result is stored in the AC. 
• Step 5: 
The next instruction (2941) is fetched 
from location 302 and PC is incremented.
Explanation 
• Step 6: 
The contents of the AC are stored in 
location 941.
Example: (PDP-11 Instruction Expressed 
Symbolically) 
• ADD B,A 
stores the sum of contents of the 
memory location B and A into memory 
location A. 
A single instruction cycle with the following 
steps occurs 
— Fetch the ADD instruction. 
— Read the content of memory location A 
into the processor. 
— Read the content of memory location B 
into the processor.
Conti…….. 
• Add the Two values 
• Write the result from the processor to 
memory location A.
Instruction Cycle State Diagram
Explanation 
• IAC : 
Determine the Address of the next 
instruction to be executed .(if each 
instruction is 16 bits long and memory is 
organized into 16 bit words, then add 1 to 
the previous address.if,instead,memory is 
organized as individually addressable 8-bit 
bytes, then add 2 to the previous address. 
• Instruction fetch (IF): 
Read instruction from its memory 
location into the processor.
Explanation conti…… 
• Instruction operation decoding (IOD): 
Analyze instruction to determine type of 
operation to be performed and operands 
to be used. 
• Operand address calculation (OAC): 
if the operation involves reference to an 
operand in memory or available via I/O 
,then determine the address of operand.
• Operand Fetch (OF): 
Fetch the operand from memory or ead it 
from I/O. 
• Data Operation ( DO): 
Perform the operation indicated in the 
instruction . 
• Operand Store (OS): 
write the result into memory or put to 
I/O. (Example PDP-11 ADD A,B results in 
the following sequence of 
states:IAC,IF,IOD,OAC,OF,OAC,OF,DO,OA 
C,OS.
Interrupts 
• Mechanism by which other modules (e.g. 
I/O) may interrupt normal sequence of 
processing 
• Program 
—e.g. overflow, division by zero 
• Timer 
—Generated by internal processor timer 
—Used in pre-emptive multi-tasking 
• I/O 
—from I/O controller 
• Hardware failure 
—e.g. memory parity error
Interrupts conti…… 
• primarily as a way to improve processing 
efficiency. 
• For Example, most external devices are 
much slower than the processor.
Interrupt Cycle 
• Added to instruction cycle 
• Processor checks for interrupt 
—Indicated by an interrupt signal 
• If no interrupt, fetch next instruction 
• If interrupt pending: 
—Suspend execution of current program 
—Save context 
—Set PC to start address of interrupt handler 
routine 
—Process interrupt 
—Restore context and continue interrupted 
program
Transfer of Control via Interrupts
Instruction Cycle with Interrupts
Instruction Cycle (with Interrupts) - 
State Diagram
Multiple Interrupts 
• Disable interrupts 
—Processor will ignore further interrupts while 
processing one interrupt 
—Interrupts remain pending and are checked 
after first interrupt has been processed 
—Interrupts handled in sequence as they occur 
• Define priorities 
—Low priority interrupts can be interrupted by 
higher priority interrupts 
—When higher priority interrupt has been 
processed, processor returns to previous 
interrupt
Multiple Interrupts - Sequential
Multiple Interrupts – Nested
Time Sequence of Multiple Interrupts
What is an Instruction Set? 
• The complete collection of instructions 
that are understood by a CPU. 
• each instruction must contains the 
information required by the CPU for 
execution. 
• Machine Code 
• Binary 
• Usually represented by assembly codes
Elements of an Instruction 
• Operation code (Op code) 
— specifies the operation to be performed (ADD,SUB etc) 
• Source Operand reference 
— may involve one or more source operands (input for 
the operation) 
• Result Operand reference 
—Put the answer here 
• Next Instruction Reference ( Main or virtual or 
secondary memory) 
—When you have done that, do this... 
Tells the CPU where to fetch the next instruction after 
the execution of this instruction complete.
Instruction Cycle State Diagram
Instruction Representation 
• In machine code each instruction has a 
unique bit pattern. 
• In computer ,each instruction is 
represented by a sequence of bits. 
(Difficult for programmer and reader) 
• For human consumption (well, 
programmers anyway) a symbolic 
representation is used 
—e.g. ADD, SUB, LOAD 
• Operands can also be represented in this 
way 
—ADD A,B
Mnemonics (opcode)….. 
• Opcodes are represented by abbreviations 
called mnemonics. 
• Examples: 
— ADD Addition 
— SUB Subtract 
— MPY Multiply 
— DIV Divide 
— LOAD Load data from memory 
— STOR store data to memory
Simple Instruction Format
Example 
• X=X+Y (X location 513 and Y 
location 514 ). 
• 3 machine instruction are required. 
— Load a register with the contents of memory 
location 513. 
— Add the contents of memory location 514 to 
the register. 
— Store the content of the register in memory 
location 513.
Instruction Types 
• Data processing (Arithmetic and logic 
instructions). 
• Data storage (main memory instructions) 
• Data movement (I/O Instructions) 
• Program flow control (Test and Branch 
Instructions).
Types of Operation 
• Data Transfer 
• Arithmetic 
• Logical 
• Conversion 
• I/O 
• System Control 
• Transfer of Control
Data Transfer 
• Specify 
—Source 
—Destination 
—Amount of data 
• May be different instructions for different 
movements 
—e.g. IBM 370 
• Or one instruction and different addresses 
—e.g. VAX
DATA Transfer Instructions: 
Type Operation Name Description 
Data Transfer 
MOVE Transfer word or block from source to destination 
Store Transfer word from processor to memory 
Load(fetch) Transfer word from memory to processor 
Exchange Swap contents of source and destination 
Clear(reset) Transfer word of 0s to destination 
Set Transfer word Transfer of 1s destination 
Push Transfer word from source to top stack 
Pop Transfer word from top of stack to destination
Arithmetic Instructions: 
Type Operation Name Description 
Arithmetic 
Add Computes sum of two operands 
Subtract Difference bw 2 operands 
Multiply Product of 2 operands 
Divide Compute quotient of 2 operands 
Absolute Replace operand by its absolute value 
Negate Change sign of operand 
Increment Add 1 to operand 
Decrement Subtract 1 from operand
Arithmetic 
• Add, Subtract, Multiply, Divide 
• Signed Integer 
• Floating point ? 
• May include 
—Increment (a++) 
—Decrement (a--) 
—Negate (-a)
Logical Instructions 
Type Operation Name Description 
Logical 
AND,OR,NOT,Ex-OR Logical operation bitwise 
Test Test specified condition 
Compare Compares 2 operands 
Set control variable Protection purpose, Interrupt handling ,timer 
control 
Shift Left (Right) shift operand 
Rotate Left (right) shift operand
Logical 
• Bitwise operations 
• AND, OR, NOT
Shift and Rotate Operations
Examples of shift and rotate operations 
Input Operation Result 
10100110 Logical right 
shift ( 3 bits) 
00010100 
10100110 Logical left 
shift( 3 bits) 
00110000 
10100110 Arithmetic right 
shift ( 3 bits) 
11110100 
10100110 Arithmetic left 
shift ( 3 bits) 
10110000 
10100110 Right rotate 
(3bits) 
11010100 
10100110 Left rotate 00110101
Transfer of control 
Type Operation Name Description 
Transfer of control 
Jump Unconditional Unconditional transfer 
Jump Test specified condition 
Jump to subroutine Jump to specified address 
Return Replace the content of PC 
Execute Execute instructions 
Skip Increment PC to skip next Instruction 
Skip condti Test conditon for skip 
Halt Stop program execution 
Wait (hold) Stop program execution and resume when condition 
satisfied 
No operation No operation performed but program execution 
continued
Transfer of Control 
• Branch 
—e.g. branch to x if result is zero 
• Skip 
—e.g. increment and skip if zero 
—ISZ Register1 
—Branch xxxx 
—ADD A 
• Subroutine call 
—c.f. interrupt call
Input and output: 
• 
Type Operation 
Name 
Description 
Input (read) Transfer data from specified I/O port to destination 
Output (write) Transfer data from specified from source to I/O port or device 
Start I/O Transfer instruction to I/O processor to initiate I/O operation 
Test I/O Transfer status information from I/O system to specified 
destination
Input/Output 
• May be specific instructions 
• May be done using data movement 
instructions (memory mapped) 
• May be done by a separate controller 
(DMA)
conversion 
Type Operation name Description 
Conversion 
Translate Translate values in a 
section of memory based 
on a table of 
correspondence 
Convert Convert the contents of 
word a from one form to 
another.
Conversion 
• E.g. Binary to Decimal
Systems Control 
• Privileged instructions 
• CPU needs to be in specific state 
—Ring 0 on 80386+ 
—Kernel mode 
• For operating systems use
Number of Addresses (a) 
• 3 addresses 
—Operand 1, Operand 2, Result 
—a = b + c; 
—May be a forth - next instruction (usually 
implicit) 
—Not common 
—Needs very long words to hold everything
Number of Addresses (b) 
• 2 addresses 
—One address doubles as operand and result 
—a = a + b 
—Reduces length of instruction 
—Requires some extra work 
– Temporary storage to hold some results
Number of Addresses (c) 
• 1 address 
—Implicit second address 
—Usually a register (accumulator) 
—Common on early machines
Number of Addresses (d) 
• 0 (zero) addresses 
—All addresses implicit 
—Uses a stack 
—e.g. push a 
— push b 
— add 
— pop c 
—c = a + b
Example: Y=(A-B)%(C+D*E) 
Instruction comment 
SUB Y,A,B Y‹— A-B 
MPY T,D,E T‹— D*E 
ADD T,T,C T ‹— T+C 
DIV Y,Y,T Y ‹— Y%T
Two-Address Instructions:Y=(A-B)%(C+D*E) 
Instruction Comment 
MOVE Y,A Y ‹— A 
SUB Y,B Y ‹— Y-B 
MOVE T,D T ‹— D 
MPY T,E T ‹— T*E 
ADD T,C T ‹— T+C 
DIV Y,T Y ‹— Y%T
1 Address Instructions:Y=(A-B)%(C+D*E) 
Instruction comment 
LOAD D AC ‹— D 
MPY E AC ‹— AC*E 
ADD C AC ‹— AC+C 
STOR Y Y ‹— AC 
LOAD A AC ‹— A 
SUB B AC ‹— AC-B 
DIV Y AC ‹— AC%Y 
STOR Y Y ‹— AC
Assignment 
• compare one-two-three address 
instructions for the following expression 
X=(A+B*C)/(D-E*F)
How Many Addresses 
• More addresses 
—More complex (powerful?) instructions 
—More registers 
– Inter-register operations are quicker 
—Fewer instructions per program 
• Fewer addresses 
—Less complex (powerful?) instructions 
—More instructions per program 
—Faster fetch/execution of instructions
Instruction Design Decisions (1) 
• Operation repertoire 
—How many ops? 
—What can they do? 
—How complex are they? 
• Data types( The various types of data 
upon which operation to be performed) 
• Instruction formats 
—Length of op code field 
—Number of addresses
Instruction Design Decisions (2) 
• Registers 
—Number of CPU registers available 
—Which operations can be performed on which 
registers? 
• Addressing modes (later…) 
The mode or modes by which the 
address of an operand is specified. 
• RISC v CISC
Types of Operand 
• Addresses 
• Numbers 
—Integer/floating point 
• Characters 
—ASCII etc. 
• Logical Data 
—Bits or flags 
• (Aside: Is there any difference between numbers and 
characters? Ask a C programmer!)
Addressing Modes: 
• An operand reference in an instruction 
either contains the actual value of the 
operand (Immediate) or a reference to 
the address of the operand. 
• The address field or fields in a typical 
instruction format are relatively small. 
• we would like to be able to reference a 
large range of locations in main memory 
or for systems, virtual memory .To 
achieve this objective, a variety of 
addressing modes.
Addressing Modes 
• Immediate 
• Direct 
• Indirect 
• Register 
• Register Indirect 
• Displacement (Indexed) 
• Stack
Immediate Addressing 
• Operand is part of instruction 
• Operand = address field 
• e.g. ADD 5 
—Add 5 to contents of accumulator 
—5 is operand 
• Advantages: 
― No memory reference to fetch data 
― Fast 
• Disadvantage: 
― Limited range
Immediate Addressing Diagram 
Instruction 
Opcode Operand
Direct Addressing 
• Address field contains address of operand 
• Effective address (EA) = address field (A) 
• e.g. ADD A 
—Add contents of cell A to accumulator 
—Look in memory at address A for operand 
• Advantage: 
― Single memory reference to access data 
― No additional calculations to work out 
effective address 
• Disadvantage: 
― Limited address space
Direct Addressing Diagram 
Instruction 
Opcode Address A 
Memory 
Operand
Indirect Addressing (1) 
• Memory cell pointed to by address field 
contains the address of (pointer to) the 
operand 
• EA = (A) 
—Look in A, find address (A) and look there for 
operand 
• e.g. ADD (A) 
—Add contents of cell pointed to by contents of 
A to accumulator
Indirect Addressing (2) 
• Large address space 
• 2n where n = word length 
• May be nested, multilevel, cascaded 
—e.g. EA = (((A))) 
– Draw the diagram yourself 
• Multiple memory accesses to find 
operand( two memory to fetch the 
operand : one to get its address and 
second to get its value.) 
• Hence slower
Indirect Addressing Diagram 
Instruction 
Opcode Address A 
Memory 
Pointer to operand 
Operand
Register Addressing (1) 
• Operand is held in register named in 
address filed 
• EA = R 
• Limited number of registers 
• Very small address field needed 
• No memory reference are required 
—Shorter instructions 
—Faster instruction fetch
Register Addressing (2) 
• No memory access 
• Very fast execution 
• Very limited address space 
• Multiple registers helps performance 
—Requires good assembly programming or 
compiler writing 
—N.B. C programming 
– register int a; 
• c.f. Direct addressing
Register Addressing Diagram 
Instruction 
Opcode Register Address R 
Registers 
Operand
Register Indirect Addressing 
• C.f. indirect addressing 
• EA = (R) 
• Operand is in memory cell pointed to by 
contents of register R 
• Large address space (2n) 
• One fewer memory access than indirect 
addressing
Register Indirect Addressing Diagram 
Instruction 
Opcode Register Address R 
Memory 
Registers 
Pointer to Operand Operand
Displacement Addressing 
• EA = A + (R) 
• Address field hold two values 
• combination of direct addressing and 
register indirect addressing. 
—A = base value 
—R = register that holds displacement 
—or vice versa
Displacement Addressing Diagram 
Instruction 
OpcodeRegister R 
Memory 
Registers 
Address A 
Pointer to Operand Operand 
+
Relative Addressing 
• A version of displacement addressing 
• R = Program counter, PC 
• EA = A + (PC) 
• i.e. get operand from A cells from current 
location pointed to by PC 
• c.f locality of reference & cache usage
Base-Register Addressing 
• A holds displacement 
• R holds pointer to base address 
• R may be explicit or implicit 
• e.g. segment registers in 80x86
Indexed Addressing 
• A = base 
• R = displacement 
• EA = A + R 
• Good for accessing arrays 
—EA = A + R 
—R++
Stack Addressing 
• Operand is (implicitly) on top of stack 
• e.g. 
—ADD Pop top two items from stack 
and add
Basic addressing modes 
Mode Algorithm Advantage disadvantage 
Immediate Operand=A No memory 
reference 
Limited operand 
magnitude 
Direct EA=A Simple Limited address 
space 
Indirect EA=(A) Large address space Multiple memory 
references 
Register EA=R No memory 
reference 
Limited address 
space 
Register indirect EA=(R) Large address space Extra memory 
refernce 
Displacement EA=A+(R) Flexibility Complexity 
Stack EA=top of stack No memory 
reference 
Limited applicability
Pentium Addressing Modes 
• Virtual or effective address is offset into segment 
—Starting address plus offset gives linear address 
—This goes through page translation if paging enabled 
• 12 addressing modes available 
—Immediate 
—Register operand 
—Displacement 
—Base 
—Base with displacement 
—Scaled index with displacement 
—Base with index and displacement 
—Base scaled index with displacement 
—Relative
Pentium Addressing Mode Calculation
PowerPC Addressing Modes 
• Load/store architecture 
—Indirect 
– Instruction includes 16 bit displacement to be added to 
base register (may be GP register) 
– Can replace base register content with new address 
—Indirect indexed 
– Instruction references base register and index register 
(both may be GP) 
– EA is sum of contents 
• Branch address 
—Absolute 
—Relative 
—Indirect 
• Arithmetic 
—Operands in registers or part of instruction 
—Floating point is register only
Thank you

More Related Content

What's hot

Memory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycleMemory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycle
chantellemallia
 

What's hot (20)

Interrupts in CPU
Interrupts in CPUInterrupts in CPU
Interrupts in CPU
 
Interrupt
InterruptInterrupt
Interrupt
 
Interrupt handling
Interrupt handlingInterrupt handling
Interrupt handling
 
Interrupts ppt
Interrupts pptInterrupts ppt
Interrupts ppt
 
Interrupts
InterruptsInterrupts
Interrupts
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
 
Program control
Program controlProgram control
Program control
 
Fetch execute cycle
Fetch execute cycleFetch execute cycle
Fetch execute cycle
 
CPU & RAM
CPU & RAMCPU & RAM
CPU & RAM
 
Instruction cycle with interrupts
Instruction cycle with interruptsInstruction cycle with interrupts
Instruction cycle with interrupts
 
Computer Organisation (DFT1113)
Computer Organisation (DFT1113)Computer Organisation (DFT1113)
Computer Organisation (DFT1113)
 
Instruction cycle presentation
Instruction   cycle presentationInstruction   cycle presentation
Instruction cycle presentation
 
Modes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationModes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output Organization
 
Counit2 2
Counit2 2Counit2 2
Counit2 2
 
Computer architecture presentation
Computer architecture presentationComputer architecture presentation
Computer architecture presentation
 
Memory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycleMemory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycle
 
Control Unit (CU)
Control Unit (CU)Control Unit (CU)
Control Unit (CU)
 
L3 instruction-execution-steps
L3 instruction-execution-stepsL3 instruction-execution-steps
L3 instruction-execution-steps
 
Interrupts and types of interrupts
Interrupts and types of interruptsInterrupts and types of interrupts
Interrupts and types of interrupts
 
Interrupts
InterruptsInterrupts
Interrupts
 

Viewers also liked

The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++
Anjesh Tuladhar
 
02 Computer Evolution And Performance
02  Computer  Evolution And  Performance02  Computer  Evolution And  Performance
02 Computer Evolution And Performance
Jeanie Delos Arcos
 
02 computer evolution and performance
02 computer evolution and performance02 computer evolution and performance
02 computer evolution and performance
Sher Shah Merkhel
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets Characteristics
Jeanie Delos Arcos
 

Viewers also liked (20)

Computer function-and-interconnection 3
Computer function-and-interconnection 3Computer function-and-interconnection 3
Computer function-and-interconnection 3
 
face recognation
face recognationface recognation
face recognation
 
Compiler Engineering Lab#3
Compiler Engineering Lab#3Compiler Engineering Lab#3
Compiler Engineering Lab#3
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
 
The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++
 
Henz new
Henz newHenz new
Henz new
 
Honey
HoneyHoney
Honey
 
ISM424 RM
ISM424 RMISM424 RM
ISM424 RM
 
Chapter006
Chapter006Chapter006
Chapter006
 
01 Introduction
01 Introduction01 Introduction
01 Introduction
 
02 Computer Evolution And Performance
02  Computer  Evolution And  Performance02  Computer  Evolution And  Performance
02 Computer Evolution And Performance
 
Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Chapter008
Chapter008Chapter008
Chapter008
 
02 computer evolution and performance
02 computer evolution and performance02 computer evolution and performance
02 computer evolution and performance
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
03 Buses
03 Buses03 Buses
03 Buses
 
Powerpoint Exercise 2
Powerpoint Exercise 2Powerpoint Exercise 2
Powerpoint Exercise 2
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets Characteristics
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Chapter005
Chapter005Chapter005
Chapter005
 

Similar to abc

Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptxComputer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
solomonlemma14
 
Operating systems and technologies
Operating systems and technologiesOperating systems and technologies
Operating systems and technologies
Phannida Panyasit
 

Similar to abc (20)

Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
computer system organization basics
computer system organization basicscomputer system organization basics
computer system organization basics
 
Computer basic and cpu
Computer basic and cpuComputer basic and cpu
Computer basic and cpu
 
Coa module1
Coa module1Coa module1
Coa module1
 
CST 20363 Session 4 Computer Logic Design
CST 20363 Session 4 Computer Logic DesignCST 20363 Session 4 Computer Logic Design
CST 20363 Session 4 Computer Logic Design
 
coa-module1-170527034116.pdf
coa-module1-170527034116.pdfcoa-module1-170527034116.pdf
coa-module1-170527034116.pdf
 
Computer Organization and Architecture 10th - William Stallings, Ch01.pdf
Computer Organization and Architecture 10th - William Stallings, Ch01.pdfComputer Organization and Architecture 10th - William Stallings, Ch01.pdf
Computer Organization and Architecture 10th - William Stallings, Ch01.pdf
 
Computer fundamental mba
Computer fundamental mbaComputer fundamental mba
Computer fundamental mba
 
Lec02-CS110 Computational Engineering
Lec02-CS110 Computational EngineeringLec02-CS110 Computational Engineering
Lec02-CS110 Computational Engineering
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
 
Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptxComputer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
Computer_Architecture&O_ECEG_3163_02_computer_evolution_performance.pptx
 
Operating systems and technologies
Operating systems and technologiesOperating systems and technologies
Operating systems and technologies
 
Bca 2nd sem-u-1.2 digital logic circuits, digital component
Bca 2nd sem-u-1.2 digital logic circuits, digital componentBca 2nd sem-u-1.2 digital logic circuits, digital component
Bca 2nd sem-u-1.2 digital logic circuits, digital component
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Unit 1. introduction
Unit 1. introductionUnit 1. introduction
Unit 1. introduction
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Microprocessor fundamentals
Microprocessor fundamentalsMicroprocessor fundamentals
Microprocessor fundamentals
 
B.sc cs-ii -u-1.2 digital logic circuits, digital component
B.sc cs-ii -u-1.2 digital logic circuits, digital componentB.sc cs-ii -u-1.2 digital logic circuits, digital component
B.sc cs-ii -u-1.2 digital logic circuits, digital component
 
125252.ppt
125252.ppt125252.ppt
125252.ppt
 
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.pptINTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

abc

  • 1. Computer Architecture and Organization Unit I
  • 2. Architecture & Organization  Architecture is those attributes visible to the programmer  Instruction set, number of bits used for data representation, I/O mechanisms, addressing techniques.  Organization is how features are implemented (Transparent to the programmer)  Control signals, interfaces, memory technology.
  • 3. Architecture & Organization Conti...  All Intel x86 family share the same basic architecture  The IBM System/370 family share the same basic architecture(1970)  Organization differs between different versions
  • 4. Structure & Function  A computer is a complex system: contemporary computers contains millions of elementary electronic components.  The hierarchical nature of complex system is essential for both their design and description.  The designer need only deal with a particular level of the system at a time. at each level, the system consists of a set of components and their interrelationships.
  • 5. Structure & Function At each level, the designer is concerned with structure and function .  Structure is the way in which components relate to each other
  • 6. Functions  All computer functions are:  Data processing: (must be able to process data)  Data storage: (short time and long term Ex: files)  Data movement: (when data are received from or delivered to a device that directly connected to the computer ,the process known as input-output (I/O) and the device is referred to as a peripheral.  Control: ( above 3 functions and manages the resources)  Function is the operation of individual components as part of the structure
  • 9. Operations (a) Data movement conti…  Simple transferring data from one peripheral or communications line to another.  when data are moved over longer distance ,to or from a remote device, the process is known as data communication.  the computer must be able to move data between itself and the outside world.
  • 11. Operations (b) Storage conti….  Data transferred from the External environment to computer storage (read) and vice versa (write).  Short-term storage used to store data temporarily.  long-term storage used to store data permanently (files of data are stored on the computer for subsequent retrieval and update.
  • 12. Operation (c) Processing from/to storage
  • 13. Operation (d) Processing from storage to I/O
  • 14. Structure - Top Level Computer Computer Main Memory Systems Interconnection Input Output Peripherals Communication lines Central Processing Unit
  • 15. Structure…. • Four main structural components: - central processing unit(CPU): controls the operation of the computer and perform its data processing functions: often simply referred to as processor. - Main memory: stores data - I/O: moves data between computer and its external environment. - system interconnections: some mechanism that provides for communication among CPU,mainmemory, and I/O.
  • 16. Structure - The CPU Computer Arithmetic and Login Unit Internal CPU Interconnection Control Unit Registers CPU I/O System Bus Memory CPU
  • 17. Structure - The CPU( components) • Four main components: - control unit : controls the operation of CPU and hence the computer. - Arithmetic and logic unit(ALU): perform the computer’s data processing function (addition ,subtraction etc) - Registers: provides storage internal to the CPU. - CPU interconnection: some mechanism that provides for communication among the control unit,ALU, and registers.
  • 18. Structure - The Control Unit CPU Control Unit Registers and Decoders Control Memory Sequencing Login Control Unit ALU Internal Bus Registers Control Unit
  • 19. First-Generation Computers • Late 1940s and 1950s • Stored-program computers • Programmed in machine level language • Examples: IAS, ENIAC, EDVAC, UNIVAC, Mark I, IBM 701 • UNIVAC ( Universal Automatic computer ) • ENIAC (Electronic numerical integrator and computer) • EDVAC ( Electronic Discrete Variable computer)
  • 20. ENIAC - background • Electronic Numerical Integrator And Computer • Eckert and Mauchly • University of Pennsylvania • Trajectory tables for weapons • Started 1943 • Finished 1946 —Too late for war effort • Used until 1955.
  • 21. ENIAC – details: • Decimal (not binary) • 20 accumulators of 10 digits • Programmed manually by switches • 18,000 vacuum tubes • 30 tons • 15,000 square feet • 140 kW power consumption • 5,000 additions per second
  • 22. von Neumann/Turing • Stored Program concept • Main memory storing programs and data • ALU operating on binary data • Control unit interpreting instructions from memory and executing • Input and output equipment operated by control unit • Princeton Institute for Advanced Studies —IAS • Completed 1952
  • 23. John von Neumann (1903-1957)
  • 24. Structure of von Neumann machine
  • 25. IAS Computer Machine Language • 40-bit word, two machine instructions per word. Left instruction Right instruction 7 8 bit 0 8-bit opcode 12-bit memory address 19 20 27 28 39 (operand)
  • 26. IAS - details • 1000 x 40 bit words —Binary number —2 x 20 bit instructions • Set of registers (storage in CPU) —Memory Buffer Register —Memory Address Register —Instruction Register —Instruction Buffer Register —Program Counter —Accumulator —Multiplier Quotient
  • 27. Structure of IAS – detail
  • 28. Registers • Memory buffer Register(MBR): contains a word to be stored in memory ,or is used to receive a word from memory. • Memory Address Register (MAR): specifies address in memory or the word to be written from or read into the MBR. • Instruction Register(IR): contains the 8 bit opcode instruction being executed. • Instruction Buffer Register (IBR): employed to hold temporarily the right hand instruction from a word in memory. • Program Counter (PC): contains the address of the next instruction-pair to be fetched from memory. • Multiplier Quotient ( MQ): (for multiply and divide instruction) used to store the remainder.
  • 29. IAS Instructions • The IAS computer had a total of 21 instructions and grouped as follows: ― Data Transfer: Move data between memory and ALU registers or between ALU Registers. ― Unconditional branch: Normally, the control unit executes instruction in sequence from memory .This sequence can be changed by a branch instruction. Conditional Branch: depends on condition. ― Arithmetic: Operations performed by the ALU. ― Address modify: Address to be computed in the ALU and then inserted into instructions stored in memory.
  • 30. Data Transfer Instructions Instruction Type Opcode SYBOLIC Description Data transfer 00001010 LOAD MQ AC‹― MQ 00001001 LOAD MQ M(X) MQ‹― Memory (X) 00100001 STOR M(X) Memory(X) ‹― AC 00000001 LOAD M(X) AC ‹― Memory(X) 00000010 LOAD –M(X) AC ‹― -M(X) 00000011 LOAD IM(X) AC ‹― Absolute of M(X)
  • 31. Unconditional Branch Instruction Type Opcode Symbolic Description Unconditional Branch 00001101 JUMP M(X,0:19) Take next instruction from left half of M(x) 00001110 JUMP M(X,20:39) Take the instruction from right half of M(x)
  • 32. Conditional Branch Instruction Type Opcode Symbolic Description Conditional Branch 00001111 JUMP+M(X,0:19 ) If no in AC is +ve take the next instruction from left half of M(X) 00010000 JUMP+M(X,20:3 9) If no in the AC is +ve take next instruction from right half of M(X)
  • 33. Arithmetic Instruction Type Opcode Symbolic Description Arithmetic 00000101 ADD M(X) AC+M(X) AC ‹― result 00000110 SUB M(X) AC-M(X) AC ‹― Result 00001011 MUL M(X) Multiply M(X) by MQ AC ‹― MSB MQ ‹― LSB 00001100 DIV Divide AC by MQ MQ ‹― quotient AC ‹― REMAINDER 00010100 LSH Left shit 1 Bit position(Multiply) 00010101 RSH Shift Right bit one position (DIVIDE)
  • 34. Von Neumann Bottleneck • Von Neumann architecture uses the same memory for instructions (program) and data. • The time spent in memory accesses can limit the performance. This phenomenon is sometimes referred to as von Neumann bottleneck. • To avoid the bottleneck, later architectures restrict most operands to registers.
  • 35. Second Generation Computers • 1955 to 1964 • Transistor replaced vacuum tubes. • Magnetic core memories. • Floating-point arithmetic. • Assembly level languages • Example: IBM 7094 DEC – 1957 (Digital Equipment corporation) —Produced PDP-1 ( Programmed data processor)
  • 36. Transistors • Replaced vacuum tubes • Smaller • Cheaper • Less heat dissipation • Solid State device • Made from Silicon (Sand) • Invented 1947 at Bell Labs • William Shockley et al.
  • 37. Third Generation Computers • Beyond 1965 • Integrated circuit (IC) technology. • Semiconductor memories. • Memory hierarchy, virtual memories and caches. • Time-sharing. • Parallel processing and pipelining. • Microprogramming. • Examples: IBM 360 and 370, CYBER, ILLIAC IV, DEC PDP and VAX, Amdahl 470
  • 38. The Now Generation • Personal computers • Laptops and Palmtops • Networking and wireless • And the future! – Nanotechnology – Optical computing – Quantum computing – Molecular computing
  • 39. Program Concept • Hardwired systems are inflexible • General purpose hardware can do different tasks, given correct control signals • Instead of re-wiring, supply a new set of control signals
  • 40. What is a program? • A sequence of steps • For each step, an arithmetic or logical operation is done • For each operation, a different set of control signals is needed
  • 41. Function of Control Unit • For each operation a unique code is provided —e.g. ADD, MOVE • A hardware segment accepts the code and issues the control signals • We have a computer!
  • 42. Data processor model • You can think of a computer as a data processor. • Is it a specific-purpose machine or a general-purpose machine?
  • 43. Programmable data processor model • A program is a set of instructions that tells the computer what to do with data. • A program is a set of instructions written in a computer language. • The output data depend on the combination of two factors: the input data and the program.
  • 46. Components • The Control Unit and the Arithmetic and Logic Unit constitute the Central Processing Unit • Data and instructions need to get into the system and results out —Input/output • Temporary storage of code and results is needed —Main memory
  • 48. Instruction Cycle • Two steps: —Fetch —Execute
  • 49. Fetch Cycle • Program Counter (PC) holds address of next instruction to fetch • Processor fetches instruction from memory location pointed to by PC • Increment PC —Unless told otherwise • Instruction loaded into Instruction Register (IR) • Processor interprets instruction and performs required actions
  • 50. Execute Cycle • Processor-memory —data transfer between CPU and main memory • Processor I/O —Data transfer between CPU and I/O module • Data processing —Some arithmetic or logical operation on data • Control —Alteration of sequence of operations —e.g. jump • Combination of above
  • 51. Example of Program Execution
  • 52. Explanation • Step 1: The PC contains the 300, the address of the first instruction. This instruction (the value 1940 in Hex) is loaded into the IR and PC Incremented. • step 2: The first 4 bits( First Hex digit) in IR indicate that AC is to be loaded.the remaining 12 bits (3 Hex digits) specify the address (940) from which data are to be loaded.
  • 53. Explanation • Step 3: The next instruction (5941) is fectched frunited way that you have everything om location 301 and the pc incremented. • Step 4: The old contents of the AC and the contents of location 941 are added and the result is stored in the AC. • Step 5: The next instruction (2941) is fetched from location 302 and PC is incremented.
  • 54. Explanation • Step 6: The contents of the AC are stored in location 941.
  • 55. Example: (PDP-11 Instruction Expressed Symbolically) • ADD B,A stores the sum of contents of the memory location B and A into memory location A. A single instruction cycle with the following steps occurs — Fetch the ADD instruction. — Read the content of memory location A into the processor. — Read the content of memory location B into the processor.
  • 56. Conti…….. • Add the Two values • Write the result from the processor to memory location A.
  • 58. Explanation • IAC : Determine the Address of the next instruction to be executed .(if each instruction is 16 bits long and memory is organized into 16 bit words, then add 1 to the previous address.if,instead,memory is organized as individually addressable 8-bit bytes, then add 2 to the previous address. • Instruction fetch (IF): Read instruction from its memory location into the processor.
  • 59. Explanation conti…… • Instruction operation decoding (IOD): Analyze instruction to determine type of operation to be performed and operands to be used. • Operand address calculation (OAC): if the operation involves reference to an operand in memory or available via I/O ,then determine the address of operand.
  • 60. • Operand Fetch (OF): Fetch the operand from memory or ead it from I/O. • Data Operation ( DO): Perform the operation indicated in the instruction . • Operand Store (OS): write the result into memory or put to I/O. (Example PDP-11 ADD A,B results in the following sequence of states:IAC,IF,IOD,OAC,OF,OAC,OF,DO,OA C,OS.
  • 61. Interrupts • Mechanism by which other modules (e.g. I/O) may interrupt normal sequence of processing • Program —e.g. overflow, division by zero • Timer —Generated by internal processor timer —Used in pre-emptive multi-tasking • I/O —from I/O controller • Hardware failure —e.g. memory parity error
  • 62. Interrupts conti…… • primarily as a way to improve processing efficiency. • For Example, most external devices are much slower than the processor.
  • 63. Interrupt Cycle • Added to instruction cycle • Processor checks for interrupt —Indicated by an interrupt signal • If no interrupt, fetch next instruction • If interrupt pending: —Suspend execution of current program —Save context —Set PC to start address of interrupt handler routine —Process interrupt —Restore context and continue interrupted program
  • 64. Transfer of Control via Interrupts
  • 66. Instruction Cycle (with Interrupts) - State Diagram
  • 67. Multiple Interrupts • Disable interrupts —Processor will ignore further interrupts while processing one interrupt —Interrupts remain pending and are checked after first interrupt has been processed —Interrupts handled in sequence as they occur • Define priorities —Low priority interrupts can be interrupted by higher priority interrupts —When higher priority interrupt has been processed, processor returns to previous interrupt
  • 68. Multiple Interrupts - Sequential
  • 70. Time Sequence of Multiple Interrupts
  • 71. What is an Instruction Set? • The complete collection of instructions that are understood by a CPU. • each instruction must contains the information required by the CPU for execution. • Machine Code • Binary • Usually represented by assembly codes
  • 72. Elements of an Instruction • Operation code (Op code) — specifies the operation to be performed (ADD,SUB etc) • Source Operand reference — may involve one or more source operands (input for the operation) • Result Operand reference —Put the answer here • Next Instruction Reference ( Main or virtual or secondary memory) —When you have done that, do this... Tells the CPU where to fetch the next instruction after the execution of this instruction complete.
  • 74. Instruction Representation • In machine code each instruction has a unique bit pattern. • In computer ,each instruction is represented by a sequence of bits. (Difficult for programmer and reader) • For human consumption (well, programmers anyway) a symbolic representation is used —e.g. ADD, SUB, LOAD • Operands can also be represented in this way —ADD A,B
  • 75. Mnemonics (opcode)….. • Opcodes are represented by abbreviations called mnemonics. • Examples: — ADD Addition — SUB Subtract — MPY Multiply — DIV Divide — LOAD Load data from memory — STOR store data to memory
  • 77. Example • X=X+Y (X location 513 and Y location 514 ). • 3 machine instruction are required. — Load a register with the contents of memory location 513. — Add the contents of memory location 514 to the register. — Store the content of the register in memory location 513.
  • 78. Instruction Types • Data processing (Arithmetic and logic instructions). • Data storage (main memory instructions) • Data movement (I/O Instructions) • Program flow control (Test and Branch Instructions).
  • 79. Types of Operation • Data Transfer • Arithmetic • Logical • Conversion • I/O • System Control • Transfer of Control
  • 80. Data Transfer • Specify —Source —Destination —Amount of data • May be different instructions for different movements —e.g. IBM 370 • Or one instruction and different addresses —e.g. VAX
  • 81. DATA Transfer Instructions: Type Operation Name Description Data Transfer MOVE Transfer word or block from source to destination Store Transfer word from processor to memory Load(fetch) Transfer word from memory to processor Exchange Swap contents of source and destination Clear(reset) Transfer word of 0s to destination Set Transfer word Transfer of 1s destination Push Transfer word from source to top stack Pop Transfer word from top of stack to destination
  • 82. Arithmetic Instructions: Type Operation Name Description Arithmetic Add Computes sum of two operands Subtract Difference bw 2 operands Multiply Product of 2 operands Divide Compute quotient of 2 operands Absolute Replace operand by its absolute value Negate Change sign of operand Increment Add 1 to operand Decrement Subtract 1 from operand
  • 83. Arithmetic • Add, Subtract, Multiply, Divide • Signed Integer • Floating point ? • May include —Increment (a++) —Decrement (a--) —Negate (-a)
  • 84. Logical Instructions Type Operation Name Description Logical AND,OR,NOT,Ex-OR Logical operation bitwise Test Test specified condition Compare Compares 2 operands Set control variable Protection purpose, Interrupt handling ,timer control Shift Left (Right) shift operand Rotate Left (right) shift operand
  • 85. Logical • Bitwise operations • AND, OR, NOT
  • 86. Shift and Rotate Operations
  • 87. Examples of shift and rotate operations Input Operation Result 10100110 Logical right shift ( 3 bits) 00010100 10100110 Logical left shift( 3 bits) 00110000 10100110 Arithmetic right shift ( 3 bits) 11110100 10100110 Arithmetic left shift ( 3 bits) 10110000 10100110 Right rotate (3bits) 11010100 10100110 Left rotate 00110101
  • 88. Transfer of control Type Operation Name Description Transfer of control Jump Unconditional Unconditional transfer Jump Test specified condition Jump to subroutine Jump to specified address Return Replace the content of PC Execute Execute instructions Skip Increment PC to skip next Instruction Skip condti Test conditon for skip Halt Stop program execution Wait (hold) Stop program execution and resume when condition satisfied No operation No operation performed but program execution continued
  • 89. Transfer of Control • Branch —e.g. branch to x if result is zero • Skip —e.g. increment and skip if zero —ISZ Register1 —Branch xxxx —ADD A • Subroutine call —c.f. interrupt call
  • 90. Input and output: • Type Operation Name Description Input (read) Transfer data from specified I/O port to destination Output (write) Transfer data from specified from source to I/O port or device Start I/O Transfer instruction to I/O processor to initiate I/O operation Test I/O Transfer status information from I/O system to specified destination
  • 91. Input/Output • May be specific instructions • May be done using data movement instructions (memory mapped) • May be done by a separate controller (DMA)
  • 92. conversion Type Operation name Description Conversion Translate Translate values in a section of memory based on a table of correspondence Convert Convert the contents of word a from one form to another.
  • 93. Conversion • E.g. Binary to Decimal
  • 94. Systems Control • Privileged instructions • CPU needs to be in specific state —Ring 0 on 80386+ —Kernel mode • For operating systems use
  • 95. Number of Addresses (a) • 3 addresses —Operand 1, Operand 2, Result —a = b + c; —May be a forth - next instruction (usually implicit) —Not common —Needs very long words to hold everything
  • 96. Number of Addresses (b) • 2 addresses —One address doubles as operand and result —a = a + b —Reduces length of instruction —Requires some extra work – Temporary storage to hold some results
  • 97. Number of Addresses (c) • 1 address —Implicit second address —Usually a register (accumulator) —Common on early machines
  • 98. Number of Addresses (d) • 0 (zero) addresses —All addresses implicit —Uses a stack —e.g. push a — push b — add — pop c —c = a + b
  • 99. Example: Y=(A-B)%(C+D*E) Instruction comment SUB Y,A,B Y‹— A-B MPY T,D,E T‹— D*E ADD T,T,C T ‹— T+C DIV Y,Y,T Y ‹— Y%T
  • 100. Two-Address Instructions:Y=(A-B)%(C+D*E) Instruction Comment MOVE Y,A Y ‹— A SUB Y,B Y ‹— Y-B MOVE T,D T ‹— D MPY T,E T ‹— T*E ADD T,C T ‹— T+C DIV Y,T Y ‹— Y%T
  • 101. 1 Address Instructions:Y=(A-B)%(C+D*E) Instruction comment LOAD D AC ‹— D MPY E AC ‹— AC*E ADD C AC ‹— AC+C STOR Y Y ‹— AC LOAD A AC ‹— A SUB B AC ‹— AC-B DIV Y AC ‹— AC%Y STOR Y Y ‹— AC
  • 102. Assignment • compare one-two-three address instructions for the following expression X=(A+B*C)/(D-E*F)
  • 103. How Many Addresses • More addresses —More complex (powerful?) instructions —More registers – Inter-register operations are quicker —Fewer instructions per program • Fewer addresses —Less complex (powerful?) instructions —More instructions per program —Faster fetch/execution of instructions
  • 104. Instruction Design Decisions (1) • Operation repertoire —How many ops? —What can they do? —How complex are they? • Data types( The various types of data upon which operation to be performed) • Instruction formats —Length of op code field —Number of addresses
  • 105. Instruction Design Decisions (2) • Registers —Number of CPU registers available —Which operations can be performed on which registers? • Addressing modes (later…) The mode or modes by which the address of an operand is specified. • RISC v CISC
  • 106. Types of Operand • Addresses • Numbers —Integer/floating point • Characters —ASCII etc. • Logical Data —Bits or flags • (Aside: Is there any difference between numbers and characters? Ask a C programmer!)
  • 107. Addressing Modes: • An operand reference in an instruction either contains the actual value of the operand (Immediate) or a reference to the address of the operand. • The address field or fields in a typical instruction format are relatively small. • we would like to be able to reference a large range of locations in main memory or for systems, virtual memory .To achieve this objective, a variety of addressing modes.
  • 108. Addressing Modes • Immediate • Direct • Indirect • Register • Register Indirect • Displacement (Indexed) • Stack
  • 109. Immediate Addressing • Operand is part of instruction • Operand = address field • e.g. ADD 5 —Add 5 to contents of accumulator —5 is operand • Advantages: ― No memory reference to fetch data ― Fast • Disadvantage: ― Limited range
  • 110. Immediate Addressing Diagram Instruction Opcode Operand
  • 111. Direct Addressing • Address field contains address of operand • Effective address (EA) = address field (A) • e.g. ADD A —Add contents of cell A to accumulator —Look in memory at address A for operand • Advantage: ― Single memory reference to access data ― No additional calculations to work out effective address • Disadvantage: ― Limited address space
  • 112. Direct Addressing Diagram Instruction Opcode Address A Memory Operand
  • 113. Indirect Addressing (1) • Memory cell pointed to by address field contains the address of (pointer to) the operand • EA = (A) —Look in A, find address (A) and look there for operand • e.g. ADD (A) —Add contents of cell pointed to by contents of A to accumulator
  • 114. Indirect Addressing (2) • Large address space • 2n where n = word length • May be nested, multilevel, cascaded —e.g. EA = (((A))) – Draw the diagram yourself • Multiple memory accesses to find operand( two memory to fetch the operand : one to get its address and second to get its value.) • Hence slower
  • 115. Indirect Addressing Diagram Instruction Opcode Address A Memory Pointer to operand Operand
  • 116. Register Addressing (1) • Operand is held in register named in address filed • EA = R • Limited number of registers • Very small address field needed • No memory reference are required —Shorter instructions —Faster instruction fetch
  • 117. Register Addressing (2) • No memory access • Very fast execution • Very limited address space • Multiple registers helps performance —Requires good assembly programming or compiler writing —N.B. C programming – register int a; • c.f. Direct addressing
  • 118. Register Addressing Diagram Instruction Opcode Register Address R Registers Operand
  • 119. Register Indirect Addressing • C.f. indirect addressing • EA = (R) • Operand is in memory cell pointed to by contents of register R • Large address space (2n) • One fewer memory access than indirect addressing
  • 120. Register Indirect Addressing Diagram Instruction Opcode Register Address R Memory Registers Pointer to Operand Operand
  • 121. Displacement Addressing • EA = A + (R) • Address field hold two values • combination of direct addressing and register indirect addressing. —A = base value —R = register that holds displacement —or vice versa
  • 122. Displacement Addressing Diagram Instruction OpcodeRegister R Memory Registers Address A Pointer to Operand Operand +
  • 123. Relative Addressing • A version of displacement addressing • R = Program counter, PC • EA = A + (PC) • i.e. get operand from A cells from current location pointed to by PC • c.f locality of reference & cache usage
  • 124. Base-Register Addressing • A holds displacement • R holds pointer to base address • R may be explicit or implicit • e.g. segment registers in 80x86
  • 125. Indexed Addressing • A = base • R = displacement • EA = A + R • Good for accessing arrays —EA = A + R —R++
  • 126. Stack Addressing • Operand is (implicitly) on top of stack • e.g. —ADD Pop top two items from stack and add
  • 127. Basic addressing modes Mode Algorithm Advantage disadvantage Immediate Operand=A No memory reference Limited operand magnitude Direct EA=A Simple Limited address space Indirect EA=(A) Large address space Multiple memory references Register EA=R No memory reference Limited address space Register indirect EA=(R) Large address space Extra memory refernce Displacement EA=A+(R) Flexibility Complexity Stack EA=top of stack No memory reference Limited applicability
  • 128. Pentium Addressing Modes • Virtual or effective address is offset into segment —Starting address plus offset gives linear address —This goes through page translation if paging enabled • 12 addressing modes available —Immediate —Register operand —Displacement —Base —Base with displacement —Scaled index with displacement —Base with index and displacement —Base scaled index with displacement —Relative
  • 129. Pentium Addressing Mode Calculation
  • 130. PowerPC Addressing Modes • Load/store architecture —Indirect – Instruction includes 16 bit displacement to be added to base register (may be GP register) – Can replace base register content with new address —Indirect indexed – Instruction references base register and index register (both may be GP) – EA is sum of contents • Branch address —Absolute —Relative —Indirect • Arithmetic —Operands in registers or part of instruction —Floating point is register only