Compilers
Which describes three-address code, a kind of intermediate representation?
- AA single instruction can contain any number of operations and parentheses
- BEach instruction has at most three addresses and one operation
- CAddresses must always be physical memory addresses
Show answer and explanation
Answer: B. Each instruction has at most three addresses and one operation
Three-address code breaks complex expressions into a sequence of simple instructions with one operation each. For example, x = (a + b) * c becomes t1 = a + b and x = t1 * c, and each instruction mentions at most three addresses: the result and two operands. Intermediate values get temporary names such as t1. This makes evaluation order explicit and eases optimization and translation to CPU instructions. Addresses are variables or temporaries, not physical addresses.
- A. Each instruction has only one operation.
- B. Correct. Instructions have at most three addresses and one operation.
- C. Addresses are variables or temporaries, not physical addresses.