Unit2 Cpu
Unit2 Cpu
Unit-2
Central Processing
Unit
General Register Organization-A set of flip-
flops forms a register. A register is a unique high-speed
storage area in the CPU. They include combinational
circuits that implement data processing. The information
is always defined in a register before processing. The
registers speed up the implementation of programs.
Memory stack-
A stack can be implemented by a random access memory
attached to a cpu. A contiguous block of the location is
reserved in main memory(or virtual memory)fot the
stack.most of the time, the block is partially field with
stack element and the remainder is available for the stack
growth.
Stack Base:
Contains the address of the bottom location in the
reserved block. If an attempt is made to POP operation
when the stack is empty, an error is reported.
Stack limit:
Contains the address of the other end of the reserved
block.if an attempt is made to PUSH Operation when the
block is fully utilzed for the stack, an error is reported.
Instruction formats-
An instrcution set is a collection of all the instruction a
CPU can execute. Each instruction consists of several
elements. An instrcution element is a unit of information
required by the CPU for execution.
Opcode Reference to Opcode Reference to
operands
1)Three-Address Instruction:-
Machines with three-address instruction formats can
format as of use each address field to specify either a
processor register or a memory operand. Such an
instruction contains three address fields, each providing
the address of one of the three operands- X, Y, and Z. The
operation field of the instruction specifies that addition is
to be performed. This three address instruction can be
represented symbolically as:
ADD X. Y. Z
The general form of three-address instruction is as below:
ADD A , B
Operation-Code , Source ,
Destination
MOV R1 ,A R1 M[A]
ADD R1 ,B R1 R1 + M[B]
MOV R2 ,C R2 M[C]
MUL R1 , R2 R1 R1 * R2
LOAD A AC M[A]
LOAD C AC M[C]
ADD D AC AC + M[D]
STORE X M[X] AC
Zero-Address Instruction-
Zero-address instructions are those in which locations of
all operands are defined implicitly. The execution of these
instructions is the fastest as the speed with which a given
task is carried out depends on the time it takes to transfer
instructions from memory into the processor, and to
access the operand. These instructions are generally used
for stacks.
PUSH A TOS A
PUSH B TOS B
ADD TOS (A+B)
PUSH C TOS C
PUSH D TOS D
ADD TOS (C+D)
MUL TOS (C+D)*(A+B)
POP X M[X] TOS
Addressing Modes:
1- Microprocessor executes the instructions stored in
memory (RAM).
2- It executes one instruction at a time.
3- Each of the instruction contains operations and
operands.
4- Operation specifies the type of action to be
performed.
For example: ADD, SUB, MOV, INC, LOAD, STORE
5- Operands are the data on which the operation is to be
performed.
MOV B, A Here MOV is operation and (B & A) are
operands.
ADD B Here ADD is operation and (B) is operand.
6- Operand can be place either in one of the processor
register or in memory.
7- There are different ways to get the operands.
8- The way in which the operand is taken from register
or memory is named as addressing mode.
9. Autoincrement or Autodecrement
Addressing Mode -
It is similar to register indirect addressing mode.
Here the register is incremented or decremented before or
after its value is used.