in CO and Architecture edited by
7,031 views
13 votes
13 votes

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

  1. $4$
  2. $6$
  3. $8$
  4. $10$
in CO and Architecture edited by
by
7.0k views

3 Comments

Why didn't they provide us with instruction set architecture?
0
0
Why not 6 ?

1 : LDA N;

2: MUL O;

3: ADD M;

4: DIV P;

5: DIV Q;

6: STORE X ← ACC;

Please see this how it is not correct ?
1
1
Source:William Stallings

More variants to solve 

0
0

5 Answers

38 votes
38 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

TOTAL 8 1 ADDRESS INSTRUCTION  REQUIRED.

edited by

4 Comments

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.
0
0
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.
0
0
check for I7 it will be divide

ACC<--ACC/M[T];

. .btw nice explanation
1
1
Classic explanation.

Thanks.
0
0
5 votes
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....
4 votes
4 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
edited by
by

3 Comments

1st instruction in three address instruction format should be MUL R1,P,Q
2
2
didnt get u .
0
0
edited by
option ( C )
0
0
2 votes
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.

1 comment

@shaik sir,how is the above approach wrong. It cannot make it out!
0
0
Answer:

Related questions