Chapter-4
Chapter-4
Instruction Set Architecture
• Refers to the part of a computer architecture related to programming, which includes
the native commands and operations a processor can execute.
• The ISA def in es how software controls the processor's behavior and utilizes its
features.
• A t t h e l o w e s t l e v e l , e a c h i n s t r u c t i o n i s a s e q u e n c e o f
0s and 1s that describes a physical operation the computer is to perform (such as "
Add").
• Depending on the particular instruction type, the specif ication of special storage areas
called registers that may contain data to be used in carrying out the instruction, or the
location in computer memory of data.
Instruction Set Architecture (ISA)
Instruction set is the boundary where the computer designer and
computer programmer see the same computer from different
viewpoints.
From the designer, point of view, the computer instruction set
provides a functional description of a processor, that is :
(i) detailed list of the instructions that a processor is capable of
processing.
(ii) describes of the types/locations/access methods for
operands.
The common goal of computer designer is to build the hardware
for implementing the machine's instructions for CPU.
Cont….
From the programmer's point of view, the user must
understand machine or assembly language for low-level
programming.
Moreover, the user must be aware of the register set,
instruction types and the function that each instruction
performs.
However, our main focus is the programmer's viewpoint
with the design of instruction set.
Instruction Types
Refers to the categories of instructions in an Instruction Set Architecture (ISA),
which determine the kinds of operations a processor can perform.
These are generally classif ie d based on the function they serve within the
computer's operations.
Data transfer: These instructions transfer data from one location in the computer
to another location without changing the data contents.
These instructions are used to move data between memory, registers, and I/O
devices.
Examples:
LOAD: Transfer data from memory to a register.
STORE: Transfer data from a register to memory.
MOV: Move data between registers.
PUSH / POP: Push data to or pop data from a stack.
IN / OUT: Transfer data between I/O devices and registers.
The most common transfer are between:
Resister to register.
Memory to register.
Register to memory.
Register to I/O part and vice versa.
Instruction Types
Arithmetic Instructions
Perform mathematical operations on numerical data and Carry out computations such
as addition, subtraction, multiplication, and division.
Examples:
ADD: Add two values.
SUB: Subtract one value from another.
MUL: Multiply two values.
DIV: Divide one value by another.
INC / DEC: Increment or decrement a value by 1.
Logical Instructions
• Perform bitwise operations on data and Manipulate individual bits or test conditions.
Examples:
AND: Perform a bitwise AND operation.
OR: Perform a bitwise OR operation.
XOR: Perform a bitwise XOR operation.
NOT: Perform a bitwise NOT operation (complement).
TEST: Test specific bits for conditions.
Instruction Types
Control Flow Instructions
Change the sequence of program execution and alter
the normal f lo w of execution based on conditions or
explicit jumps.
Examples:
Unconditional Jumps:
• JMP: Jump to a specified address.
Conditional Branches:
• BEQ: Branch if equal.
• BNE: Branch if not equal.
• BLT: Branch if less than.
• BGT: Branch if greater than.
Function/Procedure Control:
• CALL: Call a subroutine.
• RET: Return from a subroutine.
Instruction format
Describe the structure and layout of an instruction in a
computer's Instruction Set Architecture (ISA).
They def in e how information such as operation codes
(opcodes), operands, addressing modes, and other control
d at a is org anized in t he b inar y rep resent at ion of an
instruction.
Some operation codes deal with more than one operand; the
locations of these operands may be specif ie d using any of
the many addressing schemes.
The bits of the instruction are divided into groups called
fields.
1. An operation code f ield that specif ies the operation to be
performed.
2. An address f ield that designates a memory address or a
processor registers.
3. A mode f ie ld that specif ie s the way the operand or the
effective address is determined.
Instruction format
In order to execute the instruction CPU needs to know three
things.
Operation code (opcode): specif ies the type of action to be
performed
Example: add, sub, mul, div
Opera nds a re the da ta on which the opera tion 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.
Operand can be place either in one of the processor register or
in memory.
Operands residing in memory are specif ied with their memory
address
Addressing mode: The way in which the operand is taken from
register or memory.
Instruction format
Mode Operation code Address/data
Addressing mode opcode operands
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 Mod
AC e opcode 500
PC 200
201 500
702
325
800
300
2. Direct Addressing Mode
Address Memory
200 Load to Mod Instruction
AC e
201 opcode Address = 500
PC 200
Next • Instruction contains the address 500.
202 Instruction
R1 400 • 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
702 325
800 300
4. Register Addressing Mode
Memory
Address
Load to Mod
200
AC e
PC 200 Address =
201 500
R1 400 202 Next
Instruction • Register R1 contains 400.
• A s ope ra n d is in re gist e r so n o a n y
AC memory location.
399 450
400 700 Effective Address = Nil
Operand = 400
500 800
AC 400
600 900
702 325
800 300
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.
AC 399 450 • The data stored at 400 is 700.
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 fetc h- exec ute c yc le) is the c yc le that the c entral
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 identif ie s 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.
If the instruction requires storing the result, the value is written back to a
specific memory location or a CPU register.