The Gateway to Computer Science Excellence
+10 votes

In $X=(M+N \times O)/(P \times Q)$, how many one-address instructions are required to evaluate it?

  1. 4
  2. 6
  3. 8
  4. 10
in CO and Architecture by Active (3k points)
retagged by | 3.2k views
Why didn't they provide us with instruction set architecture?

4 Answers

+33 votes
Best answer

Accumulator CPU is example of One Address Instruction:

In Acc. CPU first alu operand is always required in the accumulator but second alu operand can be in the register or memory because of the the availability of the one address along with the opcode.

Load and Store is One address Instruction

X= (M + N x O)/(P x Q)

I1: Load P : ACC<--M[P]                      //Load the P value from memory  to ACCUMULATOR

I2: Mul Q: ACC<--ACC*M[Q]           //Second alu operand is in memory and destination is Register

I3: Store T: M[T]<--ACC                   //Store the Value in memory

I4: Load N : ACC<--M[N]                 

I5: Mul O :  ACC<--ACC*M[O]

I6: Add M:  ACC<--ACC+M[M]

I7: Div T:    ACC<--ACC/M[T]

I8: Store X: M[X]<--ACC                //Finally store in value in memory


by Active (1.1k points)
edited by
Thanks a lot.

So basically whenever one address instruction is asked, we have to put data in ACC and modify it? Also, in inst I5, its M[O] instead of M[N] i guess.
Yes,along with that second alu operand maybe in memory.

Thanks for pointing out,In Instruction I5,it was indeed M[O].I have modified the answer.
check for I7 it will be divide


. .btw nice explanation
Classic explanation.

+5 votes
1. LDA P ; AC<----M[P]

2. MUL Q ; AC<----AC*M[Q]

3. STA Y ; M[Y]<----AC

4. LDA N ; AC<----M[N]

5. MUL O ; AC<----AC*M[O]

6. ADD M ; AC<----AC+M[M]

7. DIV Y ; AC<----AC/M[Y]

8. STA X ; M[X]<----AC

Hence it will require minimum 8 instructions to evaluate....
by Active (3.8k points)
+2 votes

Is this answer Correct? pls correct if any mistakes
 Zero Address

  1. PUSH P
  2. PUSH Q
  3. MUL
  4. PUSH O
  5. PUSH N
  6. MUL
  7. PUSH M
  8. ADD
  9. DIV
  10. POP X

One Address

  1. LOAD P
  2. MUL Q
  3. STORE T
  4. LOAD O
  5. MUL N
  6. ADD M
  7. DIV T
  8. STORE X

Two Address

  1. MOV R1,N
  2. MUL R1,0
  3. ADD R1 ,M
  4. MOV R2,Q
  5. MUL R2,P
  6. DIV R1,R2
  7. MOC X,R1

Three Address

  1. ADD R1,P,Q
  2. MUL R2,N,O
  3. ADD R2,R2,M
  4. DIV X,R2,R1
by Boss (21.5k points)
edited by
1st instruction in three address instruction format should be MUL R1,P,Q
didnt get u .
option ( C )
+2 votes
Answer should be 6

1. Load O in accumulator(acc)

2. Multiply N to acc

3. Add M to acc

4. Divide acc by P

5. Divide acc by Q

6. Store acc to X

All arithmatic operation's results are stored in acc itself.
by Junior (913 points)
@shaik sir,how is the above approach wrong. It cannot make it out!
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,391 answers
105,442 users