3.2k views

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

retagged | 3.2k views
0
Why didn't they provide us with instruction set architecture?

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.

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

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

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.

by Active (1.1k points)
edited
0
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
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.
+1
check for I7 it will be divide

ACC<--ACC/M[T];

. .btw nice explanation
0
Classic explanation.

Thanks.
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]

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)

Is this answer Correct? pls correct if any mistakes

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

2. MUL Q
3. STORE T
5. MUL N
7. DIV T
8. STORE X

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

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

2. Multiply N 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)
0
@shaik sir,how is the above approach wrong. It cannot make it out!