![]() |
VOOZH | about |
According to how many addresses an instruction consumes for arguments, instructions can be grouped. Two numerous kinds of instructions are 3 address and 0 address instructions. It is crucial to comprehend the distinction between these two, in order to know how different processors function in relation to data processing. By the end of this article, readers will learn what 3-address and 0-address instructions are, their strengths and weaknesses, and when to use which instruction variant.
Three-address instruction is a format of machine instruction. It has one opcode and three address fields. One address field is used for destination and two address fields for source.
👁 ImageExample:
X = (A + B) x (C + D)
Solution:
ADD R1, A, B R1 <- M[A] + M[B] ADD R2, C, D R2 <- M[C] + M[D] MUL X, R1, R2 M[X] <- R1 x R2
Zero-address instruction is a format of machine instruction. It has one opcode and no address fields.
👁 ImageExample:
X = (A + B) x (C + D)
Solution:
LOAD A AC <- M[A] PUSH A TOS <- A PUSH B TOS <- B ADD TOS <- (A + B) PUSH C TOS <- C PUSH D TOS <- D ADD TOS <- (C + D) MUL TOS <- (C + D) x (A + B) POP X M[X] <- TOS
| THREE-ADDRESS INSTRUCTION | ZERO-ADDRESS INSTRUCTION |
|---|---|
| It has four fields. | It has only one field. |
| It has one field for opcode and three fields for address. | It has one field for opcode and no fields for address. |
| It has long instruction length. | It has shorter instruction. |
| It is slower accessing location inside processor than memory. | It is faster accessing location inside processor than memory. |
| There is distinct address fields for destination and source. | There is no address field common for destination and source. |
| In 3-address format, destination address can not contain operand. | While in 0-address format, there is no field for operand. |
| In 3-address format, number of instructions are less. | While in 0-address format, number of instructions are more. |
| It may need three memory accesses for one instruction. | It does not need three memory accesses. |
Operand access is significantly the only major distinguishing factor between three-address and zero-address instructions. Whereas 3-address instructions enable direct manipulation of locations in the memory, 0-address instructions work on the basis of a stack. Both has its pros and cons, and which one to use, depends on the architecture and computational load of the system being developed.