Difference between 2-address instruction and 1-address instructions

Prerequisite – Instruction Formats
1. Two-Address Instructions :
Two-address instruction is a format of machine instruction. It has one opcode and two address fields. One address field is common and can be used for either destination or source and other address field for source.

Example:

X = (A + B) x (C + D) 

Solution:

MOV R1, A      R1 <- M[A]
ADD R1, B      R1 <- R1 + M[B]
MOV R2, C      R2 <- M[C]
ADD R2, D      R2 <- R2 + D
MUL R1, R2     R1 <- R1 x R2
MOV X, R1      M[X] <- R1 

2. One-Address Instructions :
One-Address instruction is also a format of machine instruction. It has only two fields. One for opcode and other for operand.



Example:

X = (A + B) x (C + D) 

Solution:

LOAD A      AC <- M[A]
ADD B       AC <- AC + M[B]
STORE T     M[T] <- AC
LOAD C      AC <- M[C]
ADD D       AC <- AC + M[D]
MUL T       AC <- AC x M[T]
STORE X     M[X] <- AC  

Difference between Two-Address Instruction and One-Address Instruction :

TWO-ADDRESS INSTRUCTION ONE-ADDRESS INSTRUCTION
It has three fields. It has only two fields.
It has one field for opcode and two fields for address. It has one field for opcode and one field for address.
It has long instruction length as compared to one-address. While it has shorter instruction length.
It is slower accessing location inside processor than memory. It is faster accessing location inside processor than memory.
It generally needs two memory accesses. It generally needs one memory accesses.
There may be three memory accesses needed for an instruction. There is a single memory access needed for an instruction.
It can’t completely eliminate three memory access. It eliminates two memory access completely.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.