Difference between 2-address and 1-address Instructions


A computer system performs tasks based on the instruction provided to it. These computer instructions are written in different formats based on the number of addresses that they contain. In this article, we will discuss two types of instructions namely, 2-address instructions and 1-address instructions, and the important differences between them.

The most fundamental difference between 2-address instruction and 1-address instruction is that a 2-address instruction requires two operands to perform an operation and the result is stored in one these two operands, while the 1-address instruction requires only one operand to perform an operation and stores the result in the same operand or in a register.

Before discussing the differences between 2-address instruction and 1-address instruction, let us first know a bit about these two types of instructions individually.

What is a 2-Address Instruction?

The type of instruction in a computer system that requires minimum two operands to perform operations is known as a 2-address instruction. In the case of 2-address instruction, the result is stored in one of the two operands.

In other words, a computer instruction in which operations like addition, subtraction, multiplication, etc. are performed on two values stored in registers and the result is also stored back into one of the same registers, it is called a 2-address instruction.

The 2-address instruction is very common in commercial computer systems.

Syntax

The following is the syntax of the 2-address instruction −

A B, C

Where, A is the opcode for example “ADD” for addition, B is the source operand, and C is the destination operand. Here, the destination operand is used to store result, and hence it can be a register or a memory location.

Example

The following is an example to illustrate the 2-address instruction −

ADD A, B A = A + B

Here, contents of the register A and register B will be added and the result will be stored in the register A.

What is a 1-Address Instruction?

A type of instruction in computer system that takes only one operand to perform operations is called a 1-address instruction. In the case of 1-address instruction, the result of operation is stored either in the same operand or in a memory register.

The 1-address instruction mostly used to perform unary operations like increment or decrement a value stored in a register.

Syntax

The 1-addresss instruction takes the following syntax −

A B

Where, A is an opcode like INC for increment, and B is the operand on which the operation is to be performed. Thus, in the case of 1-address instruction, the operand is modified.

Example

The following example illustrate the 1-address instruction −

INC A

It will increment the content of the register A.

Difference between 2-Address Instruction and 1-Address Instruction

The following table highlights all the important differences between 2-address instruction and 1-addresss instruction −

Parameter

2-Address Instruction

1-Address Instruction

Basic

The type of instruction in a computer system that requires minimum two operands to perform operations is known as a 2-address instruction.

A type of instruction in computer system that takes only one operand to perform operations is called a 1-address instruction.

Number of operands

2-address instruction takes two operands.

1-address instruction takes only one operand.

Syntax

The following is the syntax of a 2-address instruction:

Opcode Source, Destination

The following is the syntax of a 2-address instruction:

Opcode Operand

Number of registers

2-address instructions use more number of registers.

1-address instructions use only one register to store both operand and the result.

Execution time

2-address instructions require more time to execute.

1-address instructions require less time to execute.

Complexity

The implementation of a 2-address instruction may be more complex.

The implementation of 1-address instructions is less complex.

Code density

2-address instructions require less instructions to perform tasks, hence they are more compact in terms of code.

1-address instructions result in less compact code than 2-address instructions as they require more instructions to perform the same tasks.

Memory access

2-address instructions require less frequent address to memory.

1-address instructions require frequent memory access to load operands and store results.

Storage

Computer programs written using 2-address instructions require more storage space in memory.

Computer programs that use 1-adress instructions require less memory space than 2-address instruction programs.

Instruction delay

The delay of 2-address instructions can be longer as they require more cycles to execute.

The delay of 1-address instruction is shorter than that of 2-address instructions.

Conclusion

In conclusion, the most significant difference between 2-address instruction and 1-address instruction is that the 1-address instructions require only one operand, while the 2-address instructions require two operands.

Updated on: 21-Apr-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements