Table of contents
1.
Introduction
2.
What are Instruction Codes and Operands in Computer Architecture?
3.
Structure of an Instruction Code
4.
Types of Instruction Code
5.
Opcodes
5.1.
Types of Opcodes
6.
Address
6.1.
Addressing Modes
7.
Frequently Asked Questions
7.1.
What is an instruction code in the computer architecture?
7.2.
What is the difference between instruction code and instruction format?
7.3.
Is the instruction code and opcode the same?
7.4.
What are the factors affecting instruction set architecture?
7.5.
What is example of opcode?
7.6.
What are the three types of computer instruction code formats?
8.
Conclusion
Last Updated: Mar 27, 2024
Medium

Instruction Codes in Computer Architecture

Author Abhay Trivedi
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Instruction codes In computer architecture are concise groups of bits that instruct computers to execute a specific task operation. Instruction codes and addresses are unique to each computer. The operation code (opcode) in computer instructions is like a secret code that commands the computer what to do such as addition, subtraction, shift, complement, and control flow instructions.

instruction code in computer architecture

Generally, we can categorize instruction codes and addresses into operation codes(Opcodes) and addresses. Opcodes specify how to perform a specific instruction. An address specifies which we should use- a register or an area, for a particular action. Operands are precise computer instructions that show what information the computer requires to function.

Also see, Difference Between Jfet and Mosfet

What are Instruction Codes and Operands in Computer Architecture?

Instruction codes are bits that instruct the computer to execute a specific operation. An instruction comprises groups called fields. These fields include:

An instruction comprises groups called fields. These fields include:

  • The Operation code (Opcode) field determines the process that needs to be performed.
  • The Address field contains the operand's location, i.e., register or memory location.
  • The Mode field specifies how the operand locates.
What are Instruction Codes and Operands in Computer Architecture?

Instruction Format

Structure of an Instruction Code

The instruction code is also known as an instruction set. It is a collection of binary codes. It represents the operations that a computer processor can perform. The structure of an instruction code can vary. It depends on the architecture of the processor but generally consists of the following parts:

  • Opcode: The opcode (Operation code) represents the operation that the processor must perform. It might indicate that the instruction is an arithmetic operation such as addition, subtraction, multiplication, or division.
     
  • Operand(s): The operand(s) represents the data that the operation must be performed on. This data can take various forms, depending on the processor's architecture. It might be a register containing a value, a memory address pointing to a location in memory where the data is stored, or a constant value embedded within the instruction itself.
     
  • Addressing mode: The addressing mode represents how the operand(s) can be interpreted. It might indicate that the operand is a direct address in memory, an indirect address (i.e. a memory address stored in a register), or an immediate value (i.e. a constant embedded within the instruction).
     
  • Prefixes or modifiers: Some instruction sets may include additional prefixes or modifiers that modify the behavior of the instruction. For example, they may specify that the operation should be performed only if a specific condition is met or that the instruction should be executed repeatedly until a specific condition is met.

Types of Instruction Code

There are various types of instruction codes. They are classified based on the number of operands, the type of operation performed, and the addressing modes used. The following are some common types of instruction codes:

  1. One-operand instructions: These instructions have one operand and operate on that operand. For example, the "neg" instruction in the x86 assembly language negates the value of a single operand.
     
  2. Two-operand instructions: These instructions have two operands and perform an operation involving both. For example, the "add" instruction in x86 assembly language adds two operands together.
     
  3. Three-operand instructions: These instructions have three operands and perform an operation that involves all three operands. For example, the "fma" (fused multiply-add) instruction in some processors multiplies two operands together, adds a third operand, and stores the result in a fourth operand.
     
  4. Data transfer instructions: These instructions move data between memory and registers or between registers. For example, the "mov" instruction in the x86 assembly language moves data from one location to another.
     
  5. Control transfer instructions: These instructions change the flow of program execution by modifying the program counter. For example, the "jmp" instruction in the x86 assembly language jumps to a different location in the program.
     
  6. Arithmetic instructions: These instructions perform mathematical operations on operands. For example, the "add" instruction in x86 assembly language adds two operands together.
     
  7. Logical instructions: These instructions perform logical operations on operands. For example, the "and" instruction in x86 assembly language performs a bitwise AND operation on two operands.
     
  8. Comparison instructions: These instructions compare two operands and set a flag based on the result. For example, the "cmp" instruction in x86 assembly language compares two operands and sets a flag indicating whether they are equal, greater than, or less than.
     
  9. Floating-point instructions: These instructions perform arithmetic and other operations on floating-point numbers. For example, the "fadd" instruction in the x86 assembly language adds two floating-point numbers together.

Opcodes

An opcode is a collection of bits representing the basic operations, including add, subtract, multiply, complement, and shift. The number of bits required for the opcode is determined by the number of functions the computer gives. For ‘2n’ operations, the minimum bits accessible to the opcode should be ‘n’, where n is the number of bits. We implement these operations on information saved in processor registers or memory.

Types of Opcodes

There are three different types of instruction codes on the main computer. The instruction's operation code (opcode) is 3 bits long, and the remaining 13 bits are determined by the operation code encountered.

There are three types of formats:

  1. Memory Reference Instruction: It specifies the address with 12 bits and the addressing mode with 1 bit (I). For direct addresses, I equal 0, while for indirect addresses, I equal 1.
  2. Register Reference Instruction: The opcode 111 with a 0 in the leftmost bit of the instruction recognizes these instructions. The remaining 12 bits specify the procedure to be carried out.
  3. Input-Output Instruction: The operation code 111 with a 1 in the leftmost bit of instruction recognizes these instructions. The input-output action is specified using the remaining 12 bits.

Address

We represent the memory address where a given instruction is built. We use an instruction code's address bits as an operand rather than an address. The instruction in such methods has an immediate operand. The command is directed to a direct address if the second portion contains an address.

In the second half, there is another choice, which includes the operand's address. It points to an oblique address. One bit might indicate whether the instruction code executes the direct or indirect address.

Addressing Modes

We can mainly describe the address field for instruction in the following ways:

  • Direct Addressing − Uses the address of the operand.
  • Indirect Addressing − Enables the address as a pointer to the operand.
  • Immediate operand − The second part of the instruction code specifies an operand. 

 

Accumulator Register (AC): This register is found in single register processors (AC), and it performs all operations with memory operands.

Effective Address (EA) is the address of the operand or the target address. It defines the address that we can execute as a target address for a branch-type instruction or the address we can use directly to create an operand for a computation-type instruction without any changes.

Direct and Indirect Addressing

Also read, microprogrammed control unit

Frequently Asked Questions

What is an instruction code in the computer architecture?

Instruction code, also known as machine code, consists of binary representations of individual instructions that a computer's central processing unit (CPU) can understand and execute. Each instruction corresponds to a specific operation that the CPU can perform, such as arithmetic calculations, control flow, etc.

What is the difference between instruction code and instruction format?

Instruction format defines how the different fields of an instruction (opcode, operands, addressing mode, etc.) are arranged within a memory word. While an instruction code consists of the binary values representing the opcode, operands, and other control bits required to perform a specific operation.

Is the instruction code and opcode the same?

No, the opcode is a specific part of the instruction code. It is a binary value that represents the operation or instruction to be executed by the CPU while the instruction code refers to the entire binary representation of a machine instruction.

What are the factors affecting instruction set architecture?

The organization of memory hierarchy (registers, caches, main memory, etc.) influences the design of memory-related instructions along with the sizes and types of data that the processor needs to manipulate (e.g., integers, floating-point numbers, characters) impacts the instruction set.

What is example of opcode?

An opcode, short for operation code, is a part of a machine language instruction that specifies the operation to be performed. For example, in assembly language, an opcode like ADD signifies an addition operation, while MOV represents a data move operation. These opcodes are fundamental to the execution of instructions in a computer's CPU.

What are the three types of computer instruction code formats?

The three types of computer instruction code formats are: 

  • Mnemonic Code: Uses human-readable abbreviations. 
  • Binary Code: Represents instructions using 0s and 1s. 
  • Hexadecimal Code: Condenses binary code for easier human understanding, using base-16 digits (0-9, A-F).

Conclusion

In conclusion, computer architecture is the blueprint that defines the organization and functionality of a computer system. It encompasses the design of the CPU, memory, and input/output systems. Efficient and scalable architectures are crucial for optimal performance, ensuring seamless execution of diverse computing tasks.

To learn more about Micro Operations, refer to Arithmetic Micro Operations.

Click here to read about the Design of Basic Computer, Repeater in Computer NetworkComputer Registers

Recommended Readings:

Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences for placement preparations.

Do upvote our blog to help other ninjas grow.

Happy Learning!

Live masterclass