NTA UGC NET 2023 » NTA Study Materials » Computer Science » Three-Address Instructions

Three-Address Instructions

One opcode and three address fields make up three-address instructions, consuming less execution time. Each address field can specify a processor or memory operand using a three-address instruction format.

Computers generally have several instructions in code format. The unit’s responsibility in the CPU is to understand every instruction code and provide the necessary control functions to execute the instruction. Instructions in computers are of various lengths and have a variety of addresses. The address fields included in the instruction format in computers vary according to the arrangement of their registers based on the number of address fields. The three-address instruction contains one opcode and three address fields. The instruction can be described in three ways: address instruction, one-address instruction, and zero-address instruction.

Three-Address Instructions and Examples

Computers using a three-address instruction format can use each address field to indicate the register of a processor or an operand in memory. The assembly language program, which evaluates the formula X = (A + B) * (C + D), is as follows and is accompanied by notes describing each instruction’s register transfer process.

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 * R2

The computer is presumed to be equipped with two processor registers: R1 and R2. A symbol represents the memory address of the operand represented by the letter A. The benefit of using the three address format is that it creates shorter programs to evaluate arithmetic expressions. The drawback is that binary-coded instructions use more bits to define three addresses. Three-address instructions are composed of one opcode and three address fields.

A commercial computer that employs three-address instructions is Cyber 170. Cyber 170’s instruction formats are limited to three fields for register addresses, two fields for register addresses, and only one address for memory.

Advantages

(i) It produces short programs for evaluating mathematical expressions.

(ii) Less execution time.

Disadvantages

(i) Many bits are needed for instructions encoded in binary to define three addresses.

(ii) More advanced processing and decoding circuits are needed.

Uses

Cyber 170 is a commercial computer using three-address instructions.

One Opcode and Three Address Fields

Three-address is a form of machine-specific instruction and consists of one opcode and three fields for address. A single address field can indicate destinations, and two address fields are for the sources.

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 form of instruction for machines consisting of a single opcode with 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

Differences Between Three-Address Instruction and Zero-Address Instruction

THREE-ADDRESS INSTRUCTION

ZERO-ADDRESS INSTRUCTION

It comprises four fields.

It is a single field.

It contains one field for the opcode and 3 fields to address.

It has one field to enter and the opcode, but there are no fields for address.

It comes with lengthy instructions.

It comes with shorter instructions.

It is slower to access the location within processors than memory.

It is quicker to access the locations inside the processor than memory.

There are separate address fields that are used for both destination and source.

There isn’t an address field used for source and destination.

In the three-address format, the destination address cannot contain operand.

When using the zero-address format, there is no field to the operand.

In the format with three addresses, the number of instructions is lower.

In the zero-address format, there are more instructions.

It could require three-memory accesses to complete an instruction.

Three-memory access is not required.

Conclusion 

Computers perform tasks following the instructions given. Instructions in computers are composed of groups referred to as fields. Each field has different information because, for computers, everything is in 0 or 1; thus, each field has its importance based on the criteria that a CPU uses to decide the actions it will take. The most popular fields include:

  • The field for an operation describes the procedure to be executed as the addition.

  • Address field that contains the location of the operand, i.e. memory location or register.

Each address field can specify a processor or memory operand using a three-address instruction format, i.e., one opcode and three address fields.

Also check:

faq

Frequently asked questions

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

What is the three-address instruction format?

Ans. Three-address instruction is a type that is a machine-specific instruction. It is a single opcode with three fi...Read full

What are the various kinds of instructional formats?

Ans. Various types of instructional formats include: Zero-address instr...Read full

What benefits using the two address format over the three address formats used for instructions?

Ans. In 3-address format, the destination address cannot include operand. When using the 2-address format, the desti...Read full

What are the reasons for using addressing modes?

Ans. An addressing method specifies ways to compute the actual memory address for an operation using the information...Read full

Which are the three address instructions that are explained in a clear example?

Ans. THREE-ADDRESS INSTRUCTIONS (consisting of one opcode and three address fields.) ...Read full