< Instruction Format >

In computer architecture, an instruction format defines the layout and structure of an instruction that the processor can understand and execute. The format depends on the addressing mode used, as the addressing mode determines how the operand of the instruction is accessed (i.e., where the data for the operation is located). Different addressing modes specify how the operand is determined and can involve various fields in the instruction, such as the opcode, operand address, and immediate values.

< 1. Immediate Addressing Mode >

In this mode, the operand is directly specified as part of the instruction. The operand is a constant value or immediate data that is used in the operation.
Instruction Format:

  • Opcode: The operation to be performed (e.g., ADD, SUB).
  • Immediate Operand: The constant value (immediate data) used by the instruction.
  • Opcode | Operand (Immediate Data)
  • MOV R1, #5 (Move the immediate value 5 into register R1)

< 2. Direct Addressing Mode >

In this mode, the operand's address is directly specified in the instruction. The operand is located at the memory address provided.
Instruction Format:

  • Opcode: The operation to be performed .
  • Direct Address: The memory address where the operand is stored.
  • Opcode | Direct Address
  • MOV R1, 400 (Move the content of memory address 400 into register R1)

< 3. Indirect Addressing Mode >

In this mode, the instruction specifies a memory address that contains the actual address of the operand. In other words, the address of the operand is stored in memory, and the instruction fetches that address to access the operand.
Instruction Format:

  • Opcode: The operation to be performed .
  • Pointer Address: The memory address of a pointer, which points to the operand's actual address.
  • Opcode | Pointer Address
  • MOV R1, [R2] (Move the content of the memory address stored in R2 into R1)

< 4. Register Addressing Mode >

In this mode, the operand is a register. The instruction specifies which register to use, and the operand is the content of that register.
Instruction Format:

  • Opcode: The operation to be performed.
  • Register Address: The register whose value is used as the operand.
  • Opcode | Register Address
  • ADD R1 (Add the contents of register R2 to register R1)

< 5. Register Indirect Addressing Mode >

In this mode, the operand is located at the address stored in a register. The register holds the effective address where the operand resides.
Instruction Format:

  • Opcode: The operation to be performed .
  • Register Address: The register containing the address of the operand.
  • Opcode | Register Address
  • MOV R1, [R2] (Move the content of the memory address stored in R2 into R1)

< 6. Indexed Addressing Mode >

In Indexed Addressing Mode, the operand's address is determined by adding a constant value (index) to the base address stored in a register. This mode is typically used for accessing array elements or specific memory locations.

Instruction Format:

  • Opcode | Base Address + Index Value
  • MOV R1, [R2 + 100] (Move the content of the memory address `R2 + 100` into R1)

Indexed Addressing Mode

< 7. Relative Addressing Mode >

In Relative Addressing Mode, the operand's address is determined by adding an offset (or displacement) to the current program counter (PC). This is commonly used for branching operations.

Instruction Format:

  • Opcode: The operation to be performed (e.g., JMP, CALL).
  • Offset: A constant value that is added to the current program counter to calculate the target address (e.g., +4).
  • Opcode | Offset
  • JMP +4 (Jump to the memory address `PC + 4`)

Relative Addressing Mode

< 8. Stack Addressing Mode >

In Stack Addressing Mode, operands are accessed from the stack, which is a last-in, first-out (LIFO) structure. The stack is typically used for temporary storage of data, such as function calls or local variables.

Instruction Format:

  • Opcode: The operation to be performed (e.g., PUSH, POP).
  • Stack Pointer: The pointer to the top of the stack (e.g., SP).
  • Opcode | Stack Pointer
  • PUSH R1 (Push the value in R1 onto the stack)
  • POP R2 (Pop the value from the stack into R2)

Stack Addressing Mode