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

# Address-format code for Y=AB+(F/G)+CD

Computer Organization and Architecture · Chapter 2: Central Processing Unit

- Asked in: 2067 Asar (old course), 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-17
- 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+(F/G)+CD.

## Short answer

The postfix expression is A B * F G / + C D * +. Three-address code uses 5 instructions, two-address 9, one-address 11, zero-address 12. Fewer addresses per instruction results in more instructions overall.

## 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 CD is C × D.

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

#### Three-address instructions (OP dest, src1, src2)
```text
MUL R1, A, B    ; R1 = A * B
DIV R2, F, G    ; R2 = F / G
ADD R3, R1, R2  ; R3 = R1 + R2
MUL R4, C, D    ; R4 = C * D
ADD Y, R3, R4   ; Y = R3 + R4
```
Number of instructions: 5. 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, F   ; R2 = F
DIV R2, G   ; R2 = R2 / G
ADD R1, R2  ; R1 = R1 + R2
MOV R2, C   ; R2 = C
MUL R2, D   ; R2 = R2 * D
ADD R1, R2  ; R1 = R1 + R2
MOV Y, R1   ; Y = R1
```
Number of instructions: 9. 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 F    ; AC = F
DIV G     ; AC = AC / G
ADD T1    ; AC = AC + T1
STORE T2  ; T2 = AC
LOAD C    ; AC = C
MUL D     ; AC = AC * D
ADD T2    ; AC = AC + T2
STORE Y   ; Y = AC
```
Number of instructions: 11. 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 F  ; push F
PUSH G  ; push G
DIV     ; pop two, compute, push result
ADD     ; pop two, compute, push result
PUSH C  ; push C
PUSH D  ; push D
MUL     ; pop two, compute, push result
ADD     ; pop two, compute, push result
POP Y   ; Y = top of stack
```
Number of instructions: 12. 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 = 5, 2-address = 9, 1-address = 11, 0-address = 12 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 = AB+(F/G)+CD, which operations are done before the additions?
   A. A+F and G+C first
   B. A*B, F/G and C*D (multiplication and division first)
   C. Only F/G, because it is in brackets
   D. The additions, left to right, then the products
   Answer: B. Multiplication and division have higher priority than addition, so the three products/quotient are computed first. (Key point: Operation order)

2. How many instructions does the three-address program need, and why is it the shortest?
   A. 9; each instruction needs a MOV first
   B. 3; one for each product
   C. 5; each instruction names destination and both sources
   D. 12; every operand must be pushed
   Answer: C. Two multiplies, one divide and two adds give 5 instructions, since each can name dest, src1 and src2. (Key point: Three-address program)

3. Why does the two-address program start with MOV R1, A?
   A. MOV is the only way to do multiplication
   B. Memory operands cannot be multiplied at all
   C. It stores the result in Y
   D. The destination operand is overwritten, so the first operand must be copied into a register
   Answer: D. In OP dest, src the destination is both source and result, so it must be loaded first without destroying A. (Key point: Two-address MOV)

4. Why does the one-address program use STORE T1 and STORE T2?
   A. Only AC is available, so intermediate results must be saved in memory temporaries
   B. To clear AC before the next instruction
   C. To push values onto a stack
   D. Because ADD cannot use AC
   Answer: A. AC is the one implied operand, so A*B must be saved before AC is reused for F/G. (Key point: Accumulator temporaries)

5. In the zero-address program, which instructions carry an address, and what is the postfix form used?
   A. All instructions; A B + * F G
   B. Only PUSH and POP; postfix A B * F G / + C D * +
   C. Only ADD and MUL; postfix A * B F / G
   D. None; postfix is A+B*F
   Answer: B. Stack machine ADD, MUL, DIV use the top two stack items; PUSH and POP name memory. The program follows the postfix form. (Key point: Zero-address stack program)

## 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=(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×

## 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
- [Link CD 6 rad/s, point E and link AB](https://www.bctengineer.com/question.md?key=semester_3%2Fapplied_mechanics_dynamics%3Alink-cd-6rads-velocity-e-link-ab-gpm) — Applied Mechanics (Dynamics), chapter 4, asked 2×
- [Design pipelines AB, BC and CD, C = 120](https://www.bctengineer.com/question.md?key=semester_5%2Fwater_supply_engineering%3Apd-c74) — Water Supply Engineering, chapter 7
