2. CPU and its execution of instructions
DHEERAJAPREMDAS
dheerajapk@gmail.com
DheerajaPremdas
LinkedInProfile
3. CPU
• Cup or central processing unit is the brain of every computer.
• Structure of a cpu:
4. • ALU
-The arithmetic/logic unit contains electronic circuitry that
executes all arithmetic and logical operations
• CONTROL UNIT
-The control unit of the CPU contains circuitry that uses electrical
signals to direct the entire computer system to carry out, or
execute, stored program instructions.
– The control unit must communicate with both the
arithmetic/logic unit and memory.
5. System bus
• Control bus
-The control bus is used by the CPU to direct and monitor the actions of the
other functional areas of the computer
• Address bus
-The address bus consists of all the signals necessary to define any of the
possible memory address locations within the computer
-The control bus is used by the CPU to direct and monitor the actions of the
other functional areas of the computer.
• Data Bus
- The bidirectional data bus, sometimes called the memory bus, handles the
transfer of all data and instructions between functional areas of the computer.
6. Registers
• General purpose registers:
– A general purpose register is a memory cell.
– Each general purpose register has a unique
– It is used to store intermediate result of complex computation
• Accumulator :
– This Register is used for storing the Results those are produced by the
System..
7. • Instruction register:
– Instruction register Contains the current instruction being executed by
the CPU.
– The CPU will perform the operation indicated by the instruction code
contained in the instruction register.
• MAR(memory address register):
– This register holds the memory addresses of data and instructions.
– This register is used to access data and instructions from memory during
the execution of an instruction.
8. • MDR(Memory data register):
- It is the register that contains the data to be stored in the computer storage
or data after a fetch from the computer storage.
– It acts like a buffer and holds anything that is copied from the memory
ready for the processor to use it,
• Index register:
– A hardware element which holds a number that can be added to (or, in
some cases, subtracted from) the address portion of a computer instruction
to form an effective address.
– An index register in a computer's CPU is a processor register used for
modifying operand addresses during the run of a program.
9. Data register:
– A register used in microcomputers to temporarily store data being
transmitted to or from a peripheral device
• Program counter:
– This register contains the address of the next instruction
– The value in the program counter will be increased after the cpu finishes
executing one instruction.
10. • Process status register:
• – This register contains the various information about the cpu.
• – For ex: the result of a comparison operation.
• – When the CPU compares 2 numbers a and b the outcome of the
comparison is stored in the PSR The outcome of a compare operation will
allow the CPU to determine the following fact between a and b
• Equal
• Not equal
• Greater than
• Greater than or equal
• Less than
• Less than or equal
11. Types of instruction
Cpu executes following 3 types of instructions
1. Arithmatic and logic operation
• Eg: +,-,and,or
• The result of an arithmatic operation is often stored in general purpose
registers.
• Memory transfer instruction
• Transfer the content from some specific memory location to a specific
register(memory cell) in the cpu and vice versa
12. 2.Branch instructions
• – A branch instruction will cause the cpu to branch or jump to the
specified location in memory.
• – after the jump has occurred the cpu will continue to execute the
instructions in sequence until another branch or jump instruction is
encountered
• – There are two types of branch instructions:
• A unconditional branch instruction always cause the cpu to jump to
the target location.
• A conditional branch instruction will only cause the cpu to jump to
the target location when the specified condition is met.
13. Instruction execution cycle
• Fetch the instruction
• Decode the instruction
• Execute the instruction
• Store the instruction
14. Fetch
• 1. Load the address of next instruction in the PC into the MAR.
– So that the control unit can fetch the instruction from the right
part of the memory.
2. Copy the instruction/data that is in the memory address given by the MAR
into the MDR.
– MDR is used whenever anything is to go from the CPU to main
memory, or vice versa.
3. Increment the PC by 1.
– So that it contains the address of the next instruction, assuming
that the instructions are in consecutive locations.
4. Load the instruction/data that is now in the MDR into the IR. –
Thus the next instruction is copied from memory -> MDR -> IR.
15. Decode
• 1. Contents of IR split into operation code and address if
present e.g. store, add or jump instructions.
• 2. Decode the instruction that is in the IR
16. Execute
• If the instruction is a jump instruction then
– Load the address part of the instruction in the IR into
the PC.
• If the instruction is an input / load (directly) instruction then
take data input and place in accumulator.
• If the instruction is a load (from memory) instruction.
– Copy address part of the instruction (to load from) in
the IR into MAR.
– Copy data from memory address held in MAR to MDR.
– Copy data in MDR into accumulator
17. Store the output
• Result of calculations in cpu stored in main memory
or sent to output devices.
• program Counter could be updated to a new address
18. Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course
@ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed
to make a quick, good software professional out of anybody who holds a passion for coding.
19. Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
20. Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
Contact Us