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

# Address-format code for Y=AB+(C/D)+E(F/G)

Computer Organization and Architecture · Chapter 2: Central Processing Unit

- Asked in: 2069 Asar, 8 marks
- Video: [Instruction Format | zero, one, two and three address instructions program | COA by Pro Academy MCA](https://www.youtube.com/watch?v=KVN7WQqTSzI) — Pro Academy 👍
- 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-9
- 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 = AB+(C/D)+E(F/G).

## Short answer

For Y = AB+(C/D)+E(F/G), postfix is A B * C D / + E F G / * +. Three-address format uses 6 instructions (MUL, DIV, ADD, DIV, MUL, ADD). Two-address needs 11 instructions with initial MOVs. One-address accumulator code requires 12 instructions with temporaries T1, T2. Zero-address stack machine uses 14 instructions (PUSH, MUL, PUSH, DIV, ADD, PUSH, PUSH, DIV, MUL, ADD, POP). Instruction count increases as address fields decrease.

## 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. Adjacent letters with no operator, or a letter before a bracket, are read as multiplication. So AB is A × B and E(F/G) is E × (F/G).

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

#### Three-address instructions (OP dest, src1, src2)
```text
MUL R1, A, B    ; R1 = A * B
DIV R2, C, D    ; R2 = C / D
ADD R3, R1, R2  ; R3 = R1 + R2
DIV R4, F, G    ; R4 = F / G
MUL R5, E, R4   ; R5 = E * R4
ADD Y, R3, R5   ; Y = R3 + R5
```
Number of instructions: 6. 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
MUL R1, B   ; R1 = R1 * B
MOV R2, C   ; R2 = C
DIV R2, D   ; R2 = R2 / D
ADD R1, R2  ; R1 = R1 + R2
MOV R2, E   ; R2 = E
MOV R3, F   ; R3 = F
DIV R3, G   ; R3 = R3 / G
MUL R2, R3  ; R2 = R2 * R3
ADD R1, R2  ; R1 = R1 + R2
MOV Y, R1   ; Y = R1
```
Number of instructions: 11. A MOV is needed first because the destination operand is overwritten.

#### One-address instructions (accumulator AC is the implied operand)
```text
LOAD A    ; AC = A
MUL B     ; AC = AC * B
STORE T1  ; T1 = AC
LOAD C    ; AC = C
DIV D     ; AC = AC / D
ADD T1    ; AC = AC + T1
STORE T2  ; T2 = AC
LOAD F    ; AC = F
DIV G     ; AC = AC / G
MUL E     ; AC = AC * E
ADD T2    ; AC = AC + T2
STORE Y   ; Y = AC
```
Number of instructions: 12. Intermediate results that cannot stay in AC are saved in memory temporaries.

#### Zero-address instructions (stack machine)
```text
PUSH A  ; push A
PUSH B  ; push B
MUL     ; pop two, compute, push result
PUSH C  ; push C
PUSH D  ; push D
DIV     ; pop two, compute, push result
ADD     ; pop two, compute, push result
PUSH E  ; push E
PUSH F  ; push F
PUSH G  ; push G
DIV     ; pop two, compute, push result
MUL     ; pop two, compute, push result
ADD     ; pop two, compute, push result
POP Y   ; Y = top of stack
```
Number of instructions: 14. 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 = 6, 2-address = 11, 1-address = 12, 0-address = 14 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. How is AB in Y = AB+(C/D)+E(F/G) interpreted?
   A. As the variable named AB added to the rest
   B. As A added to B
   C. As A multiplied by B
   D. As A divided by B
   Answer: C. Adjacent letters with no operator are read as multiplication. (Key point: Reading AB)

2. What is the postfix form of the expression?
   A. A B * C D / + E F G / * +
   B. A B * C D / + E F / G * +
   C. A B + C D / * E F G / * +
   D. A B * C D + / E F G / * +
   Answer: A. A B * and C D / are added; F G / is multiplied by E; the two parts are added. (Key point: Postfix form)

3. How many three-address instructions are required?
   A. 3
   B. 6
   C. 8
   D. 12
   Answer: B. Six operators (*, /, +, /, *, +) give six instructions. (Key point: Three-address count)

4. In the zero-address (stack machine) program, which instructions contain a memory address?
   A. Every instruction
   B. Only ADD, SUB, MUL and DIV
   C. Only LOAD and STORE
   D. Only PUSH and POP
   Answer: D. Only PUSH and POP carry an address; arithmetic instructions work on the top two stack items. (Key point: Zero-address stack code)

## 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=(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=(W+X)*(Y-Z)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Aaddress-code-13) — 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
