cpu & its execution of instruction

22

Upload: baabtracom-first-coding-school-in-india

Post on 22-May-2015

2.772 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Cpu & its execution of instruction
Page 2: Cpu & its execution of instruction

CPU & ITS EXECUTION OF INSTRUCTION

Rajishma [email protected]/ Rajishma

T Nairtwitter.com/usernamein.linkedin.com/in/profilename9020217968

Page 3: Cpu & its execution of instruction

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 4: Cpu & its execution of instruction

CPU

• Cpu or central processing unit is the brain of every computer.

• Structure of a cpu:

Page 5: Cpu & its execution of instruction

• ALU– The arithmatic/logic unit contains electronic circuitry that

executes all arithmatic and logical operations.

• CONTROL UNIT– The control unit of the CPU contains cicuitry 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.

Page 6: Cpu & its execution of instruction

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.

Page 7: Cpu & its execution of instruction

Registers

• General purpose registers:– A general purpose register is a memory cell.– Each general purpose register has a unique name– 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..

Page 8: Cpu & its execution of instruction

• 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 regster is used to access data and instructions from memory during

the execution of an instruction.

Page 9: Cpu & its execution of instruction

• 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.

Page 10: Cpu & its execution of instruction

• 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.

Page 11: Cpu & its execution of instruction

• 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

Page 12: Cpu & its execution of instruction

Types of instruction

• Cpu executes following 3 types of instructions• 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

Page 13: Cpu & its execution of instruction

• 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.

Page 14: Cpu & its execution of instruction

Instruction execution cycle

• Fetch the instruction• Decode the instruction• Execute the instruction• Store the instruction

Page 15: Cpu & its execution of instruction

fetch1. 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.

Page 16: Cpu & its execution of instruction

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

Page 17: Cpu & its execution of instruction

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

Page 18: Cpu & its execution of instruction

• Execute contd• If the instruction is a store instruction then:

– Copy address part of the instruction (to store in) in the IR into MAR.– Copy data in accumulator to MDR.– Copy data in MDR into memory address held in MAR.

• If the instruction is an add instruction then:– Copy address part of the instruction (of number to add) in the IR

into MAR.– Copy number from memory address held in MAR into MDR.– Add number in MDR to number in accumulator (accumulator will

now hold the result).

Page 19: Cpu & its execution of instruction

• If the instruction is an output (from memory) instruction then:– Copy address part of part of the instruction (of data to output) in IR

into MAR.– Output contents of MDR.

Page 20: Cpu & its execution of instruction

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

Page 21: Cpu & its execution of instruction

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Page 22: Cpu & its execution of instruction

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: [email protected]