0% found this document useful (0 votes)
21 views26 pages

Instruction Sets and Addressing Modes

Uploaded by

regver29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views26 pages

Instruction Sets and Addressing Modes

Uploaded by

regver29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

INSTRUCTION SETS AND

ADDRESSING MODES
INSTRUCTION SET

An instruction set is a set of instructions that a processor can understand and


execute. It defines the operations that the processor can perform, the data types
it can operate on, and the way that instructions are encoded in machine code.
ADDRESSING MODES

Addressing modes are ways of specifying the location of an operand in an


instruction. Operands are the data values that are manipulated by instructions,
and they can be stored in memory, registers.
Instruction sets and addressing modes are closely related. The instruction set
defines the operations that the processor can perform, and the addressing
modes define how the operands for those operations are specified. The choice of
addressing mode can affect the performance of an instruction, and it can also
affect the ease of use of the instruction set.

A well-designed instruction set will provide a variety of addressing modes to


support different types of operands and different programming styles. This will
make it easier for programmers to write efficient code and to take advantage of
the full capabilities of the processor.
CHARACTERISTICS OF INSTRUCTION
SETS
Characteristics of instruction sets in computer architecture are
crucial in determining how a CPU functions and how software
interacts with the hardware.
1.OPCODE 2.OPERAND
An opcode (short for operation code) is the An operand is a data value or memory
portion of a machine language instruction address that is manipulated by an
that specifies the operation to be performed. instruction. Operands are typically specified
It's like a command that tells the processor in the instruction itself, and they can be
what to do with the data. Opcodes are either immediate values or references to
typically represented by binary codes, and data stored in memory or registers.
they are essential for the execution of
instructions.

3.WORD SIZE 4.INSTRUCTION SET


ENCODING
The number of bits that a processor can
operate on at a time. This affects the The way that instructions are represented in
precision of calculations and the size of data binary code. This can affect the size and
that can be stored in memory. complexity of instructions, as well as the
speed at which they can be decoded and
executed.
5.NUMBER OF REGISTERS 6.ADDRESSING MODES
The number of general-purpose registers The different ways that operands can be
that a processor has. Registers are used to specified in instructions. This affects the
store data that is being actively used by the flexibility of the instruction set and the types
program, and they can have a significant of programs that can be written.
impact on performance.

7.ENDIANNESS 8.INSTRUCTION FORMAT


The order in which bytes are stored in The layout of an instruction, including the
memory. This can affect the compatibility of opcode, operands, and any other fields. This
different processors, as well as the way that affects the size and complexity of
data is interpreted. instructions, as well as the way that they are
decoded and executed.
9.INSTRUCTION EXECUTION
SEMANTICS
The way that instructions are executed by the
processor. This can affect the performance of the
processor, as well as the behavior of programs.
OPCODE
In computer architecture, an opcode, short for operation code, is
the portion of a machine language instruction that specifies the
operation to be performed. It's like a command that tells the
processor what to do with the data. Opcodes are typically
represented by binary codes, and they are essential for the
execution of instructions.
PURPOSE OF OPCODES
Opcodes serve several crucial purposes in computer architecture:

• Instruction Identification: Opcodes uniquely identify the specific


operation to be performed, allowing the processor to decode and
execute the instruction correctly.

• Operation Control: Opcodes dictate the action to be taken, such as


arithmetic operations (addition, subtraction, multiplication, division),
logical operations (AND, OR, NOT), data manipulation (loading,
storing), and control flow (branching, jumping).
• Operand Specificity: Opcodes can indicate the number and type of
operands required for the operation. For instance, an addition
opcode might require two operands (numbers to be added), while
a memory load opcode might require a single operand (memory
address to load from).

• Instruction Format: Opcodes can define the structure of the


instruction, indicating how operands are encoded and where they
are located within the instruction.
TYPE OF OPCODES
Opcodes can be categorized based on the type of operation they
represent:
• Arithmetic Opcodes: Perform arithmetic operations on numeric
data, such as adding, subtracting, multiplying, and dividing.

• Logical Opcodes: Perform logical operations on binary data, such


as AND, OR, NOT, and XOR.
• Data Transfer Opcodes: Move data between registers, memory,
and input/output devices.

• Control Flow Opcodes: Change the flow of execution, such as


branching, jumping, and calling subroutines.

• System Opcodes: Perform privileged operations related to system


management, such as accessing system resources or handling
interrupts.
SUMMARY
• Opcodes are the "commands" that tell a processor what to do with
data.
• They are represented by binary codes and are essential for
instruction execution.
• Different opcodes represent different operations, such as
arithmetic, logical, or data transfer operations.
• The choice of opcode can affect the performance of an instruction.
• Opcodes are a fundamental part of machine language and play a
critical role in computer architecture.
OPERAND

In computer architecture, an operand is a data value or memory


address that is manipulated by an instruction. It is the "raw material"
that the processor uses to perform operations. Operands can be
literals, variables, or expressions.
PURPOSE OF OPERANDS
Operands serve several crucial purposes in computer architecture:

• Providing Input Data: Operands provide the data that is


manipulated by instructions. They are the essential ingredients for
performing arithmetic operations, logical operations, data transfers,
and other actions.

• Specifying Memory Locations: Operands can specify memory


locations where data is stored or retrieved. This allows the
processor to access and manipulate data stored in memory.
• Controlling Instruction Behavior: Operands can influence the
behavior of instructions. For instance, the value of an operand can
determine whether a conditional branch is taken or not.
TYPE OF OPERANDS
Operands can be categorized into two main types:

• Immediate Operands: These are values that are directly encoded


in the instruction itself. They are often used for constants or small
values that do not need to be stored in memory.

• Memory Operands: These are addresses that refer to data stored


in memory. The processor uses these addresses to fetch or store
data from memory during instruction execution.
ADDRESSING MODES
Addressing modes determine how operands are specified in
instructions. They define the rules for locating operands in memory or
registers. Common addressing modes include:

1. Immediate Addressing: The operand is a constant value or


immediate data, which is part of the instruction itself.
example: MOV R1, 42
(moves the value 42 into register R1).
2. Register Addressing: The operand is in a register, and the
instruction specifies the register's name or number.
example: ADD R1, R2, R3
(adds the value in register R2 to the value in register R3 and stores the result in R1).

3. Direct Addressing: The instruction contains a memory address that


points directly to the location of the operand in memory.
example: MOV R1, [100]
(load the value stored at memory address 100 into register R1).

4. Indirect Addressing: The instruction uses a register or memory


location as a pointer to access the operand's memory location.
example: MOV R1, [R2]
(load the value stored at the memory address pointed to by register R2 into register R1).
5. Indexed Addressing: An index or displacement is added to a base
address to calculate the memory address of the operand.
example: LOAD R1, [R2 + 4]
(loads the value at the memory location calculated by adding 4 to the value in register R2 into
register R1).

6. Relative Addressing: The instruction specifies a memory address


relative to the current program counter or instruction pointer.
example: JUMP label
(jumps to a label located a certain number of instructions away from the current instruction).

7. Base-Indexed Addressing: Combines a base address with an index


to access memory.
example: LOAD R1, [R2 + R3]
(loads the value at the memory location calculated by adding the values in registers R2 and R3
into register R1).
SUMMARY
• Operands are the data values that instructions operate on.
• They can be literals, variables, or expressions.
• Operands are specified in instructions using various addressing
modes.
• The type and number of operands required depend on the specific
instruction.
• Operands are essential for instruction execution and play a crucial
role in computer architecture.
EXAMPLES of opcodes and operands in computer architecture:

Example 1: Addition Example 2: Subtraction

Instruction: ADD A, B Instruction: SUB R1, R2, R3

Opcode: ADD Opcode: SUB

Operands: A, B Operands: R1, R2, R3

Description: The ADD instruction Description: The SUB instruction


adds the values of operands A and subtracts the value of operand
B and stores the result in register R3 from the value of operand R2
A. and stores the result in register
R1.
Example 3: Multiplication Example 4: Division

Instruction: MUL AX, BX Instruction: DIV DX, CX

Opcode: MUL Opcode: DIV

Operands: AX, BX Operands: DX, CX

Description: The MUL instruction Description: The DIV instruction


multiplies the values of operands divides the value of operand DX by
AX and BX and stores the result in the value of operand CX and stores
register AX. the quotient in register AX and the
remainder in register DX.
Example 5: Load Example 6: Store

Instruction: LOAD R4, 100 Instruction: STORE R5, 200

Opcode: LOAD Opcode: STORE

Operands: R4, 100 Operands: R5, 200

Description: The LOAD instruction Description: The STORE instruction


loads the value from memory stores the value of register R5 into
address 100 into register R4. memory address 200.
Example 7: Jump Example 8: Conditional Branch

Instruction: JUMP 300 Instruction: BEQ R1, R2, 400

Opcode: JUMP Opcode: BEQ

Operand: 300 Operands: R1, R2, 400

Description: The JUMP instruction Description: The BEQ instruction


transfers the program counter to compares the values of operands R1
the instruction at memory and R2. If they are equal, the
address 300. program counter is transferred to
the instruction at memory address
400. Otherwise, the program
continues to the next instruction.

You might also like