---
title: "Address-format code for Y=A+(B*C)+D"
subject: "Computer Organization and Architecture"
chapter: 2
key: "semester_5/computer_organization_and_architecture:address-code-16"
source: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/address-code-16
site: BCT Engineering
---

# Address-format code for Y=A+(B*C)+D

Computer Organization and Architecture · Chapter 2: Central Processing Unit

- Asked in: 2068 Baisakh (old course), 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/address-code-16
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_organization_and_architecture/chapter-2

## Question

Write down the following equation in three addresses, two addresses, one address and zero address instruction. If necessary, use temporary location T to store intermediate result. Y = A + (B*C) + D.

## Short answer

Y = A+(B*C)+D requires three three-address, six two-address, five one-address, and eight zero-address instructions. The one-address code needs no temporaries because the accumulator can hold all intermediate results.

## Answer

Assumptions: the operands are memory locations, `R1, R2, ...` are CPU registers, `T1, T2, ...` are temporary memory locations, and `Y` receives the result. Multiplication and division are done before addition and subtraction, and equal-priority operators go left to right. Left-to-right evaluation gives (A + (B×C)) + D.

Fully bracketed: **Y = (A+(B*C))+D**. Postfix (reverse Polish) form: `A B C * + D +`.

#### Three-address instructions (OP dest, src1, src2)
```text
MUL R1, B, C   ; R1 = B * C
ADD R2, A, R1  ; R2 = A + R1
ADD Y, R2, D   ; Y = R2 + D
```
Number of instructions: 3. Shortest program, but each instruction is long (three addresses).

#### Two-address instructions (OP dest, src; dest = dest OP src)
```text
MOV R1, A   ; R1 = A
MOV R2, B   ; R2 = B
MUL R2, C   ; R2 = R2 * C
ADD R1, R2  ; R1 = R1 + R2
ADD R1, D   ; R1 = R1 + D
MOV Y, R1   ; Y = R1
```
Number of instructions: 6. A MOV is needed first because the destination operand is overwritten.

#### One-address instructions (accumulator AC is the implied operand)
```text
LOAD B   ; AC = B
MUL C    ; AC = AC * C
ADD A    ; AC = AC + A
ADD D    ; AC = AC + D
STORE Y  ; Y = AC
```
Number of instructions: 5. No temporary location T is needed here, because every intermediate result can stay in AC (addition is commutative, so B×C is computed first and A is added to it).

#### Zero-address instructions (stack machine)
```text
PUSH A  ; push A
PUSH B  ; push B
PUSH C  ; push C
MUL     ; pop two, compute, push result
ADD     ; pop two, compute, push result
PUSH D  ; push D
ADD     ; pop two, compute, push result
POP Y   ; Y = top of stack
```
Number of instructions: 8. Only PUSH and POP carry an address; ADD, SUB, MUL, DIV work on the top two stack items, so the program follows the postfix form directly.

**Summary:** 3-address = 3, 2-address = 6, 1-address = 5, 0-address = 8 instructions. Fewer addresses per instruction usually means shorter instructions but more of them.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is Y = A + (B*C) + D evaluated?
   A. As A + ((B*C) + D) using multiplication last
   B. As (A + (B*C)) + D
   C. As (A + B) * (C + D)
   D. As A + B * (C + D)
   Answer: B. Equal-priority additions go left to right, with B*C computed first because of the bracket. (Key point: Left-to-right rule)

2. What is the postfix form?
   A. A B C * + D +
   B. A B + C * D +
   C. A B C + * D +
   D. A B C * D + +
   Answer: A. B C * is added to A, then D is added. (Key point: Postfix form)

3. Why does the one-address code need no STORE to a temporary here?
   A. The accumulator holds two values at once
   B. Y is used as a temporary
   C. B*C can be computed in AC, then A and D are added to AC directly
   D. Multiplication results are stored automatically
   Answer: C. All partial results stay in AC because each operation uses the previous result, so only the final STORE Y is needed. (Key point: One-address advantage)

4. Which is the correct set of instruction counts (3-, 2-, 1-, 0-address)?
   A. 3, 5, 6, 8
   B. 6, 3, 5, 8
   C. 3, 6, 8, 5
   D. 3, 6, 5, 8
   Answer: D. The counts are 3, 6, 5 and 8 for three-, two-, one- and zero-address code. (Key point: Instruction counts)

## Related in Computer Organization and Architecture

- [Address-format code for unspecified-2075-asoj](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-15) — Computer Organization and Architecture, chapter 2
- [Instruction fields and address formats for X=(E+F)*(G+H)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Acode-fields-e-f-g-h) — Computer Organization and Architecture, chapter 2
- [Address-format code for Y=(A+B)*(C+D)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-7) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for X=(A*B/C)-(D+E/F)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-1) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for X=(P+Q)×(R+S)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-2) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=A*(B+D/C)+(G*E)/F](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-3) — Computer Organization and Architecture, chapter 2, asked 16×

## Related in other subjects

- [Instruction and data format, addressing modes](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3A8085-instruction-data-format-addressing) — Microprocessor, chapter 2, asked 2×
- [Nyquist zero-ISI criteria; one pulse shaping method](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Anyquist-pulse-shaping-method) — Communication Systems, chapter 6
- [Transformer location for three villages (A)](https://www.bctengineer.com/question.md?key=semester_8%2Ftransmission_and_distribution_system_design%3Athree-villages-transformer-location-a) — Transmission and Distribution System Design, chapter 7, asked 2×
- [Transformer location for three villages (B)](https://www.bctengineer.com/question.md?key=semester_8%2Ftransmission_and_distribution_system_design%3Athree-villages-transformer-location-b) — Transmission and Distribution System Design, chapter 7, asked 2×
