Instruction Codes

Instruction codes are binary bits that lay down sequential operations needed to perform a specific task.

A computer program comprises a set of sequentially-ordered instructions that the computer interprets and executes to perform some user-specified tasks. Programs are written in special programming languages that are human-readable. However, a computer can’t execute high-level code, for it only understands binary machine code. Hence, for the execution of a particular task, a computer first converts the high-level codes into binary machine-executable codes and then performs the user-specified task. 

An instruction code is a set of bits that lays down a sequence of micro-operation that the computer needs to perform a specific task. Operands are definite elements of instructions which specify the data on which the operation is to be done. The data can be numbers, characters, logical data, and even addresses. For example, an instruction describes an addition operation and the numbers (operand) on which the operation is to be performed.

Structure of an Instruction Code

In general, each instruction code is 16-bit and consists of three parts called fields, which include:

  • The mode field defines how the location of the operand can be found by the computer. 

  • The operation code field or Opcode specifies the operation, such as addition, subtraction, shift, and complement, to be performed. The bits required for the operation code may vary as it is dependent on the total operations available on the computer. 

  • The address field contains the operand’s address, that is, memory or register memory location. The operand is stored in the computer’s memory just as data is stored. Based on the address of the operand, there are different types of operands: direct operand, indirect operand, and immediate operand. 

Mode

Opcode

Address of the Operand

Types of Instruction Code

In general, there are three code formats for computer instructions. Of 16-bit code, the opcode usually contains 3 bits, and the rest of 13-bit is subjective, depending on the operation code encountered. Based on the instruction code format, the three types of instruction code are:

1. Memory-reference instruction: In this type of code, 12 bits are used to specify the memory address, 3 bits for the opcode (000 to 110), and 1 bit to specify the mode as indirect addressing mode (I). 

2. Register-reference instruction: In this type of code, 12 bits indicate the register operation address, 3 bits for the opcode (111), and 1 bit is utilised for setting the mode as 0. The instructions are executed on the register. 

3. Input-output instruction: This type of code contains a 12-bit input/output operation address, 3 bits for the opcode (111), and 1 bit is utilised for setting the mode as 1. These instructions are required to transfer to and from the AC register and output device.

Completeness of Instruction Set 

For a set of computer instructions to be complete, the computer must include an adequate number of instructions in each of the following categories:

  • Arithmetic, logical, and shift instructions: These instructions specify the computational capabilities for processing the data one may wish to employ.

  • An instruction set for deploying data between the memory and processor registers

  • Instructions regulating the program along with instructions that examine status conditions

  • Input/output instructions

It is necessary to possess the capability to move data between the memory unit and registers, for a large amount of binary data is stored in the memory unit; however, all actions are executed in the processor registers. 

Instruction Cycle Code

A computer program consists of orderly instructions that are executed by a processor through a cycle called the instruction cycle. Each instruction cycle is executed in the following phases:

  • Fetching instructions from the memory unit

  • Decoding the instruction

  • Reading the operand address from memory

  • Executing the instruction

After executing an instruction, the cycle starts again at step 1, for the next instruction. The program instructions are stored in RAM. The processor initiates the execution program by fetching the instructions one at a time from the RAM. The CPU’s control unit decodes the operand part of the instruction, based on the instruction format. The ALU component of the CPU is responsible for the execution of the instructions and operation of data.

Conclusion

An instruction code is a set of bits that lay down a sequence of micro-operation that the computer needs to perform a specific task. Operands are definite elements of instructions that specify the data on which operation is to be done. In general, each instruction code is 16-bit and consists of three parts called fields, which include the mode, the opcode, and the address. 

faq

Frequently asked questions

Get answers to the most common queries related to the NTA Examination Preparation.

What is the difference between a computer program and instructions?

Ans. A computer program is a set of sequentially-arranged instructions, written using a programming language, wherea...Read full

What is an operand?

Ans. Operands are definite elements of instructions that specify the data on which operation is to be done. The data...Read full

What are memory-reference instruction codes?

Ans. In this type of code, 12 bits are used to specify the memory address, 3 bits for the opcode (000 to 110), and 1...Read full

What is the requirement for a set of instructions to be complete?

Ans. For a complete set of computer instructions, the computer should include an adequate number of input/output ins...Read full

What are the stages in an instruction cycle?

Ans. Each instruction cycle consists of the following phases: ...Read full