Three-Address Code: Operand Count and Meaning
In compiler design, three-address code is a form of intermediate code in which each instruction is represented using three addresses (fields that denote locations/identifiers). A typical instruction has the form:
So, a three-address statement conceptually uses three operand “addresses”: the two operands (arg1, arg2) and the destination/result address.
A standard contrast is:
- one-address code: fewer explicit address fields.
- two-address code: two fields (e.g., style).
- three-address code: separates operands from destination.
Therefore, for the multiple-choice question:
A three-address code uses (iii) Three operands.
However: note the wording “operands” can be ambiguous—some textbooks say “three addresses/fields,” while others say “operands including destination.” In either interpretation, three-address code corresponds to the choice that includes three operand/address fields (two sources + one destination).
Expected answer: (iii) Three operands.
Footnotes
-
Wikipedia: Three-address code (compiler intermediate representation) - https://en.wikipedia.org/wiki/Three-address_code - Describes the general form of three-address code instructions. ↩
Three-Address Code (Intermediate Representation) Explained
Key idea: “three addresses” = arg1, arg2, and result
A three-address instruction explicitly names:
- the first operand address (arg1),
- the second operand address (arg2),
- the result/destination address (result).
This is why three-address code is often written like:
Here, each line has two source operands and one destination temporary—three address fields total. three-address code temporary variable intermediate representation
Footnotes
-
Wikipedia: Three-address code (compiler intermediate representation) - https://en.wikipedia.org/wiki/Three-address_code - Describes the general form of three-address code instructions. ↩
How to identify the answer from the definition
- 1Step 1
Three-address code instructions use three explicit address fields.
- 2Step 2
Two fields correspond to input operands, and one field corresponds to the output/destination.
- 3Step 3
Three explicit fields ⇒ choose (iii) Three operands.
- 4Step 4
"Example like has sources and destination (three addresses total)."
Footnotes
-
Wikipedia: Three-address code (compiler intermediate representation) - https://en.wikipedia.org/wiki/Three-address_code - Describes the general form of three-address code instructions. ↩
-
Pro Tip
"When MCQs say “three-address code,” interpret it as “three address fields per instruction.” For an arithmetic form, that’s usually two sources + one destination."
Footnotes
-
Wikipedia: Intermediate representation (compiler) and IR concepts - https://en.wikipedia.org/wiki/Intermediate_representation - Context on IR and why different IR formats use explicit fields. ↩
Beware ambiguous wording
"Some questions say “operands” but mean “addresses/fields.” If the option set is (One/Two/Three/No operands), pick the one that corresponds to three explicit fields (arg1, arg2, result)."
Footnotes
-
Textbook-style overview source (general definition usage) - https://www.geeksforgeeks.org/three-address-code/ - Explains three-address code as having operands and a destination/result field. ↩
Operand/Address Fields by Code Style
Typical number of explicit address fields per instruction
Where three-address code fits in compilation
Parse & build syntax/semantic info
Front endSource constructs are analyzed to generate an intermediate form."
Emit three-address code
IR generationEach operation becomes an instruction with arg1, arg2, result fields."
Simplify and improve IR
OptimizationUsing explicit temporaries/destinations helps local analysis and rewrites."
Select target instructions
Back endLower IR to assembly/bytecode while respecting semantics."
Footnotes
-
Wikipedia: Three-address code (compiler intermediate representation) - https://en.wikipedia.org/wiki/Three-address_code - Describes the general form of three-address code instructions. ↩
Quick FAQ
Knowledge Check
A three-address code uses how many operands/address fields per instruction?