Open In App

Difference between 3-address instruction and 0-address instruction

Last Updated : 16 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Instruction Formats
1. Three-Address Instructions :
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.

Example:

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 

2. Zero-Address Instructions :
Zero-address instruction is a format of machine instruction. It has one opcode and no address fields.

Example:

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 



Difference between Three-Address Instruction and Zero-Address Instruction :

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.


Previous Article
Next Article

Similar Reads

Difference between 3-address instruction and 1-address instruction
The main difference between 3-address instructions and 1-address instructions is the number of operands or addresses they can operate on. 1-address instructions have only one operand or address specified in the instruction, which is typically a memory location or a register. The instruction operates on the contents of that operand and the result ma
3 min read
Computer Organization | Instruction Formats (Zero, One, Two and Three Address Instruction)
In computer organization, instruction formats refer to the way instructions are encoded and represented in machine language. There are several types of instruction formats, including zero, one, two, and three-address instructions. Each type of instruction format has its own advantages and disadvantages in terms of code size, execution time, and fle
7 min read
Difference between 3-address instruction and 2-address instructions
Prerequisite - Instruction Formats 1. Three-Address Instructions : 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. Example - X = (A + B) x (C + D) Solution: ADD R1, A, B R1 &lt;- M[A] + M[B] ADD R2, C, D R2 &lt;- M[
2 min read
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. In computer architecture and assembly language programming, 2-address
3 min read
Why is the IP address called a "logical" address, and the MAC address is called a "physical" address?
Let us try to deeply understand, why IP address is known as "Logical" while, MAC Address is known as "Physical" address. The IP address and the MAC address are both used for addressing and identifying devices on a computer network, but they serve different purposes and operate at different levels of the network stack. An IP address is a logical add
7 min read
IP address as logical address and MAC address as Physical address
Overview :IP addresses and MAC addresses are essential for data communication. Assume there are two networks. The first network has three devices: A, B, C and the second network has three devices: X, Y, Z. If a device A from the first network wishes to send data to a device Y in the second network, it must first determine where Y is located in the
6 min read
Difference Between Network Address Translation (NAT) and Port Address Translation (PAT)
Network Address Translation (NAT): NAT, in which the Private IP address or local address is translated into the public IP address. NAT is used to slow down the rate of depletion of the available IP addresses by translating the local IP or Private IP address into a global or public IP address. NAT can be a one-to-one relation or many-to-one relation
4 min read
Difference between MAC Address and IP Address
Both MAC Address and IP Address are used to uniquely define a device on the internet. NIC Card’s Manufacturer provides the MAC Address, on the other hand, Internet Service Provider provides IP Address. The main difference between MAC and IP address is that MAC Address is used to ensure the physical address of the computer. It uniquely identifies th
2 min read
Difference between Program and Instruction
1. Program : Programs, as name suggest, are simply a software application that include set of instructions in sequence especially designed to execute particular task and different programming languages are used to program a computer. 2. Instruction : Instructions, as name suggests, are simply set of instructions, documentation or steps which is a s
2 min read
How do You Calculate the Subnet Address from an IP Address and Subnet Mask?
Answer: To calculate the subnet address from an IP address and subnet mask we first convert both into its binary form and perform the bitwise AND operation between IP address and subnet mask.Subnet MaskThe subnet mask of a network is the number in which all the network bits are set to 1 and all host bits are set to 0. Subnet ID or Subnet AddressThe
2 min read