Chapter-4
Chapter-4
computer program.
• Instruction set is the complete collection of instructions that are
understood by a CPU.
• Instruction set architecture is the structure of a computer that
a machine language programmer must understand to write a
correct program for that machine.
• It is also the machine description that a hardware designer
must understand to design a correct implementation of the
computer.
• It is the set of the instructions that the Microprocessor/CPU can
execute.
• It has its own structure/formats and elements
Instruction Set Architecture
• Refers to the part of a computer architecture related to programming, which
• The ISA defines how software controls the processor's behavior and utilizes its
features.
"Add").
areas called registers that may contain data to be used in carrying out the
The operand is specified with in the instruction and operand itself is provided in the
instruction rather than its address.
ADD R1, R2, #10, Adds the immediate value 10 to the contents of register R2 and
stores the result in R1.
Move Immediate
Add Immediate
600 900
702 325
800 300
1. Immediate Addressing Mode
Address Memory
Instruction
200 Load to Mode
AC opcode 500
PC 200 500
201
R1 400 202 Next Instruction
• As instruction contains immediate number
500.
AC 399 450
400 700 Effective Address = Nil
Operand = 500
500 800
AC 500
600 900
702 325
800 300
2. Direct Addressing Mode
Address Memory
Load to Mod Instruction
200 AC e
201 opcode Address = 500
PC 200
Next • Instruction contains the address 500.
R1 400 202 Instruction
• So effective address of operand is 500.
• The data stored at 500 is 800.
AC 450
399
700 Effective Address = 500
400
Operand = 800
500 800
AC 800
600 900
702 325
800 300
3. Indirect Addressing Mode
Address Memory
Load to Mod
200
AC e Instruction
201 500
opcode Address = 500
PC 200 Next
202 Instruction
• Instruction contains the address 500.
R1 400 • Address at 500 is 800.
399 450 • So effective address of operand is 800.
AC 700 • The data stored at 800 is 300.
400
Effective Address = 800
500 800 Operand = 300
702 325
800 300
4. Register Addressing Mode
Memory
Address
Load to Mod
200 AC e
Address =
PC 200 500
201
Next
R1 400 202 Instruction • Register R1 contains 400.
• As operand is in register so no any memory
AC location.
450
399
700 Effective Address = Nil
400
Operand = 400
800
500
AC 400
900
600
325
702
300
800
5. Register Indirect Addressing Mode
Address Memory
Load to Mod
200 AC e
201 500
PC 200
Next
202 Instruction
R1 400 • Register R1 contains 400.
• So effective address of operand is 400.
399 450 • The data stored at 400 is 700.
AC
400 700
Effective Address = 400
Operand = 700
500 800
AC 700
600 900
702 325
800 300
Instruction cycle
• The instruction cycle (fetch–decode–execute cycle, or
simply the fetch-execute cycle) is the cycle that the
central processing unit (CPU) follows from boot-up
until the computer has shut down in order to process
instructions.
• A program consisting of sequence of instructions is
executed in the computer by going through a cycle for
each instruction.
1. Fetch: The CPU fetches the next instruction from memory
(usually from RAM) based on the Program Counter (PC).
The Program Counter keeps track of the address of the next
instruction to be executed. The instruction is fetched from the
memory location and placed into the instruction register (IR).
2. Decode: The fetched instruction is decoded to understand
what operation needs to be performed.
The control unit (CU) decodes the instruction to determine
which operation (such as addition, subtraction, move data,
etc.) is required, and which operands (data values) are
involved. It also identifies the address of operands if required.
3. Execute: The CPU performs the operation defined by the
instruction.
The actual execution happens during this phase. This could
involve arithmetic/logic operations (using the Arithmetic Logic
Unit or ALU).The operands are processed, and the result is
stored in a register or memory.
4. Store : The result of the execution is written back to
memory or a register.