Sei sulla pagina 1di 15

UNIT-2

CPU Organization

Introduction
The CPU can be considered the heart of computing system, includes three main components Control Unit (CU) ALU Various Registers

CU

Main Memory

I/P Device

Key Board Mouse

ALU Secondary Memory Registers O/P Device

Display Printer

Data comes through the Buses. There are three types of buses.
Address Bus(Unidirectional) :- Used to identify a memory location or an I/O Device. Data Bus(Bidirectional) :- Used to send/receive data to or from memory and I/O device. Control Bus :- Used to transfer control signals send by CPU to communicate with memory and I/O device and return status signal from the device.

CPU Organization
CPU fetch instruction from memory Decode execute Store in registers Store in main memory(if required)

Addressing Technique
Definition: ways to specify an operand. Address of operand is called Effective Address(EA). Address(A): Refers to main memory. Register(R): Refers to a register. Program Counter(PC): It hold the instruction to be execute next. 1. Immediate Addressing:
Operation A

2.

Direct Addressing:
Operation A Operand

3. Indirect Addressing:
Operation A

main memory

Address Operand

4. Register Addressing:
Operation R

Registers

Operand

5. Register Indirect Addressing:


Registers Main Memory

Operation

A Address Operand

6. Displacement Addressing: EA = A + (R)


EA=Effective address A=Address R=Displacement

There are three types of displacement addressing:


Base Register Indexing PC Relative i. Base Register:

Operation B

Main memory

Registers

ii. Indexing:
OP I B D
Base Registers Index Register Main Memory

iii. PC Relative:
PC

OP

Offset

Operand

PC=Program Counter Which holds the address of next instruction. Here the hardware uses the address in PC as base address and the instruction specifies its operand by giving its offset relative to the value in PC. Stack Addressing : The stack is a reserved block of locations where items are pushed or poped only from
one end, that is to the top of stack. Associated with the stack is a pointer SP whose value is the address of the top of the stack. V(k-1)

Value

V(k)
SP A

V(k)
Value

SP

V(k-1)

V1
Bottom of stack

Value

Bottom of stack

PUSH: Initially the situation for a PUSH A operation. When the computer executes Push, it first increment the SP register and then copies the value in A into the memory location pointed by SP.

V(k)

Value

V(k) V(k-1)

V(k)

V(k-1) SP

V(k)
SP A V1 A Bottom of stack Value A V(k-1) SP

V(k-1)

V(k-1)

Value

POP: When the computer executes the POP A operation , it first copies the value from memory into A and then decrements SP.

Auto Increment and Auto Decrement Addressing: Some Computers provide special addressing
mode that automatically increment or decrement the indicated index register. Auto Increment and Auto Decrement addressing help the programmer implement stack in memory and to sequentially access the elements in linear structures, among other uses.

The Auto Increment addressing mode increments the register address before using it i.e. pre-increment and the auto decrement addressing mode decrements the address after using it i.e. post-decrement.

A programmer can use auto increment addressing to sequentially access the characters in a string or the elements in a vector list. For example when a calling program passes parameters to a called procedure using a parameter list, it usually sends the address of the parameter list to the called sub-routine in a

register, called the linkage register. The called sub-routine can then reference the parameters
sequentially by using auto increment addressing and specifying the linkage register.

Instruction Format
Operation Operand 1 Operand n

3. One Address Machine: In the early machines, when the memory was expensive and slow, a special set
of registers was used to provide an input operand as well as to receive the result from the ALU. Because of this, these registers are called accumulators.

Operation LOAD STORE ADD SUB MUL addr addr addr addr addr

Register

Example: A=B+C*D-E+F+A LOAD MUL ADD SUB ADD ADD STORE C D B E F A A // accumulator = C // // accumulator = C*D // // accumulator = C*D+B // // accumulator = C*D+B-E // // accumulator = C*D+B-E+F // // accumulator = C*D+B-E+F+A // // Store the accumulator contents in A //

4. Zero Address Machine:

Also known as Stack Machine, locations of both operands are assumed to be at default location. These machines use the stack as the source of input operands and the result goes back into the stack.

PUSH POP ADD SUB

Addr Addr

MUL

Example: A=B+C*D-E+F+A PUSH E //<E>// PUSH C //<C,E>// PUSH D //<D,C,E>// MUL //<C*D,E>// PUSH B //<B,C*D,E>// ADD //<B+C*D,E>// SUB //<B+C*D-E>// PUSH F //<F,B+C*D-E>//

ADD PUSH A ADD POP A

//<F+B+C*D-E>// //<A,F+B+C*D-E>// //<A+F+B+C*D-E>// //<A=B+C*D-E+F+A>//

Potrebbero piacerti anche