3.Central Processing
3.Central Processing
The computer's central processing unit (CPU) is the portion of a computer that
retrieves and executes instructions. The control unit controls all CPU operations,
including ALU operations, the movement of data within the CPU, and the exchange
of data and control signals across external interfaces (system bus).
3.1 Processor organization
The ALU does the actual computation or processing of data. The control unit
controls the movement of data and instructions into and out of the processor and
controls the operation of the ALU
Internal Structure of CPU
Figure below depicts is a slightly more detailed view of the processor.
Example − Address of the next program instruction, signals get from the
external devices and error messages, and including different data is saved in
the registers.
If a CPU includes some registers, therefore a common bus can link these
registers. A general organization of seven CPU registers is displayed in the
figure.
The multiplexers of 3-state gates are performed with the buses. The state of 14 binary
selection inputs determines the control word. The 14-bit control word defines a
micro-operation.
Control Word
Control word is defined as a word whose individual bits represent the various
control signal. Therefore, each of the control steps in the control sequence of
an instruction defines a unique combination of 0s and 1s in the CW. The
control words related to an instructions are stored in microprogram memory.
It consists of four fields SELA, SELB and SELD or SELREG contains three
bit each and SELOPR field contains four bits thus the total bits in the control
word are 13-bits.
The three bit of SELA select a source registers of the A input of the
ALU.
The three bits of SELB select a source registers of the B input of the
ALU.
The three bits of SELD or SELREG select a destination register using
the decoder.
The four bits of SELOPR select the operation to be performed by ALU.
Control word for operation R2=R1+R3
Stack Organization
Stack is also known as the Last in First Out (LIFO) list. It is the most important
feature in the CPU. It saves data such that the element stored last is retrieved
first. A stack is a memory unit with an address register. This register
influences the address for the stack, which is known as Stack Pointer (SP).
The stack pointer continually influences the address of the element that is
located at the top of the stack.
It can insert an element into or delete an element from the stack. The insertion
operation is known as push operation and the deletion operation is known as
pop operation. In a computer stack, these operations are simulated by
incrementing or decrementing the SP register.
There are two operations in Stack
Push – Insert an item on the top of the stack.
Pop – Deletes an item on the top of the stack.
a) Register Stack
The element C is at the top of the stack and the stack pointer holds the
address of C that is 3. The top element is popped from the stack through
reading memory word at address 3 and decrementing the stack pointer by
1. Then, B is at the top of the stack and the SP holds the address of B that
is 2. It can insert a new word, the stack is pushed by incrementing the stack
pointer by 1 and inserting a word in that incremented location.
The stack pointer includes 6 bits, because 26 = 64, and the SP cannot
exceed 63 (111111 in binary). After all, if 63 is incremented by 1, therefore
the result is 0(111111 + 1 = 1000000). SP holds only the six least
significant bits. If 000000 is decremented by 1 thus the result is 111111 .
Therefore, when the stack is full, the one-bit register ‘FULL’ is set to 1. If
the stack is null, then the one-bit register ‘EMPTY’ is set to 1. The data
register DR holds the binary information which is composed into or
readout of the stack.
Instruction Format
opcode mode
e.g.
PUSH A TOP = A
PUSH B TOP = B
ADD TOP = A+B
PUSH C TOP = C
PUSH D TOP = D
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
MOV R2, C R2 = C
ADD R2, D R2 = R2 + D
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
Addressing modes
The operands of the instructions can be located either in the main memory or
in the CPU registers. If the operand is placed in the main memory, then the
instruction provides the location address in the operand field. Many methods
are followed to specify the operand address. The different methods/modes for
specifying the operand address in the instructions are known as addressing
modes.
Different types of addressing mode
Data transfer instructions transfer the data between memory and processor
registers, processor registers, and I/O devices, and from one processor register
to another. There are eight commonly used data transfer instructions. Each
instruction is represented by a mnemonic symbol.
Name Mnemonic
Increment INC
Decrement DEC
Add ADD
Subtract SUB
Multiply MUL
Divide DIV
Add with carry ADDC
Subtract with borrow SUBB
Negative(2’s Complement) NEG
The increment instruction adds 1 to the value stored in the register or
memory word.
The decrement instruction subtracts 1 from the contents stored in the
register or memory word.
The add instruction add content of register to the accumulator
The subtract instruction subtracts the content of AC and store the results
in AC.
The Multiply instruction multiply the contents of register with the
contents of the AC and store the result in the accumulator
The divide instruction divides the contents of register with the contents
of the AC and store the quotient in the AC.
Add with Carry instruction add the contents of register and the carry
flag with the contents of the accumulator and store the result in the AC.
Subtract with borrow instruction subtract the contents of register and
the carry flag from the contents of the accumulator and store the result
in the AC
Negative instruction negates a value by finding 2’s complement of its
single operand.
Name Mnemonics
Clear CLR
Complement COM
AND AND
OR OR
Exclusive-OR XOR
Clear Carry CLRC
Set Carry SETC
Complement Carry COMC
Enable interrupt EI
Disable Interrupt DI
Shift instruction
Shifts are operations in which the bits of a word are moved to the left or right.
Shift instructions may specify either logical shifts, arithmetic shifts, or rotate-
type operations.
Name Mnemonic
Logical Shift Right SHR
Logical Shift Left SHL
Arithmetic shift Right SHRA
Arithmetic shift Left SHLA
Rotate Right ROR
Rotate Left ROL
Rotate Right Through Carry RORC
Rotate Left Through Carry ROLC
The conditional branch instruction checks the conditions for branching using
the status bits. Some of the commonly used conditional branch instructions
are shown in the table.
A subroutine call may also have side effects such as modifying data structure
in computer memory reading from or writing to the peripheral device, creating
a file, halting the program or a machine or even delaying the program’s
execution for a specified timeout.
Program interrupt
Interrupt is a signal emitted by hardware or software when a process or
an event needs immediate attention. It alerts the processor to a high-
priority process requiring interruption of the current working process.
In I/O devices one of the bus control lines is dedicated for this purpose
and is called the Interrupt Service Routine (ISR).
When a device raises an interrupt at let’s say process i, the processor
first completes the execution of instruction i. Then it loads the Program
Counter (PC) with the address of the first instruction of the ISR. Before
loading the Program Counter with the address, the address of the
interrupted instruction is moved to a temporary location. Therefore,
after handling the interrupt the processor can continue with process
i+1.
While the processor is handling the interrupts, it must inform the device
that its request has been recognized so that it stops sending the interrupt
request signal. Also, saving the registers so that the interrupted process
can be restored in the future, increases the delay between the time an
interrupt is received and the start of the execution of the ISR. This is
called Interrupt Latency.
Fig: Transfer control via interrupts
Types of interrupt
There are three major types of interrupts that are as follows
1) Hardware interrupts
If the signal for the processor is from external device or hardware is
called hardware interrupts. Example: from keyboard we will press the
key to do some action this pressing of key in keyboard will generate a
signal which is given to the processor to do action, such interrupts are
called hardware interrupts.
There are two types of hardware interrupt
Maskable Interrupt: The hardware interrupts which can be
delayed when a much highest priority interrupt has occurred to
the processor.
Non Maskable Interrupt: The hardware which cannot be
delayed and should process by the processor immediately.
2) Software interrupts
A software interrupt is initiated by executing an instruction. A software
interrupt is a special call instruction that behaves like an interrupt rather
than a subroutine call. It can be used by the programmer to initiate an
interrupt procedure at any desired point in the program.
There are two types of software interrupts i.e. Normal Interrupts and
Exception.
3.5 Reduced Instruction Set Computer (RISC)
RISC (reduced instruction set computer) is a microprocessor that is designed to
perform a smaller number of types of computer instructions so that it can operate at
a higher speed. Since each instruction type that a computer must perform requires
additional transistors and circuitry, a larger list or set of computer instructions tends
to make the microprocessor more complicated and slower in operation.
CISC Characteristics
The CISC Stands for Complex Instruction Set Computer, developed by the
Intel. It has a large collection of complex instructions that range from simple
to very complex and specialized in the assembly language level, which takes
a long time to execute the instructions. So, CISC approaches reducing the
number of instruction on each program and ignoring the number of cycles per
instruction. It emphasizes to build complex instructions directly in the
hardware because the hardware is always faster than software. However,
CISC chips are relatively slower as compared to RISC chips but use little
instruction than RISC. Examples of CISC processors are VAX, AMD, Intel
x86 and the System/360.
Characteristics of CISC:
Complex instruction, hence complex instruction decoding.
Instructions are larger than one-word size.
Instruction may take more than a single clock cycle to get executed.
Less number of general-purpose registers as operation get performed in
memory itself.
Complex Addressing Modes.
More Data types.