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

# Address-format code for Y=(W+X)*(Y-Z)

Computer Organization and Architecture · Chapter 2: Central Processing Unit

- Asked in: 2076 Asoj, 8 marks
- Video: [Instruction Format | zero, one, two and three address instructions program | CAO | COA](https://www.youtube.com/watch?v=Htw_NTvj1ss) — Techno Tutorials ( e-Learning)
- 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-13
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_organization_and_architecture/chapter-2

## Question

Write codes using 3, 2, 1 and 0 address instruction formats to perform the operation Y = (W+X)*(Y-Z).

## Short answer

For Y = (W+X)*(Y-Z), three three-address, six two-address, seven one-address, and eight zero-address instructions are needed. The one-address code saves intermediate values in temporaries.

## 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. Y appears on both sides, so the result is written to Y only in the last instruction, after the old value of Y has been used.

Fully bracketed: **Y = (W+X)*(Y-Z)**. Postfix (reverse Polish) form: `W X + Y Z - *`.

#### Three-address instructions (OP dest, src1, src2)
```text
ADD R1, W, X   ; R1 = W + X
SUB R2, Y, Z   ; R2 = Y - Z
MUL Y, R1, R2  ; Y = R1 * R2
```
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, W   ; R1 = W
ADD R1, X   ; R1 = R1 + X
MOV R2, Y   ; R2 = Y
SUB R2, Z   ; R2 = R2 - Z
MUL R1, R2  ; R1 = R1 * R2
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 W    ; AC = W
ADD X     ; AC = AC + X
STORE T1  ; T1 = AC
LOAD Y    ; AC = Y
SUB Z     ; AC = AC - Z
MUL T1    ; AC = AC * T1
STORE Y   ; Y = AC
```
Number of instructions: 7. Intermediate results that cannot stay in AC are saved in memory temporaries.

#### Zero-address instructions (stack machine)
```text
PUSH W  ; push W
PUSH X  ; push X
ADD     ; pop two, compute, push result
PUSH Y  ; push Y
PUSH Z  ; push Z
SUB     ; pop two, compute, push result
MUL     ; 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 = 7, 0-address = 8 instructions. Fewer addresses per instruction 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. In Y = (W+X)*(Y-Z), why is the result written to Y only in the last instruction?
   A. Y cannot be a destination in a three-address instruction
   B. The old value of Y is needed for Y-Z, so it must not be overwritten earlier
   C. Y is a register, not a memory location
   D. Multiplication must always be last
   Answer: B. Writing Y early would destroy the old Y that the subtraction needs. (Key point: Y on both sides)

2. What is the postfix form of the expression?
   A. W X + Y Z - *
   B. W X Y Z + - *
   C. W X + Y Z * -
   D. W X * Y Z - +
   Answer: A. W X + and Y Z - are computed, then multiplied. (Key point: Postfix form)

3. How many three-address instructions are needed?
   A. 2
   B. 5
   C. 6
   D. 3
   Answer: D. Two additions/subtractions and one multiplication: three instructions. (Key point: Three-address count)

4. How many zero-address instructions are needed?
   A. 6
   B. 7
   C. 8
   D. 10
   Answer: C. Four PUSH, three arithmetic instructions and one POP make 8. (Key point: Zero-address count)

## Close variants set in other exams

- [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×
- [Address-format code for Y=A/(B+C)+(D+E)*F](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-4) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=(A+B)*(C+D)+G/E*F](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-5) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for X=(A-B*F)*C+D/E](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-6) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=A/B+(C×D)+F(H/G)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-8) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=AB+(C/D)+E(F/G)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-9) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=(A-B+C)*(E+F/G)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-10) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=(A-B/C)×(D+E×G)/F](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-11) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=(A-B/C)*[D+(E*G)]](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-12) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=(A+B)/C+D/(E*F)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-14) — Computer Organization and Architecture, chapter 2, asked 16×
- [Address-format code for Y=AB+(F/G)+CD](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-17) — Computer Organization and Architecture, chapter 2, asked 16×

## Related in Computer Organization and Architecture

- [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

## 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×
- [Datapath operation and instruction cycles](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Adatapath-operation-instruction-cycles) — Embedded System, chapter 2
- [Convolutional vs block codes; (7,4) cyclic code for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aconv-vs-block-cyclic-7-4-1011) — Communication Systems, chapter 8, asked 2×
