In X = (M + N x O)/(P x Q), how many one-address instructions are required to evaluate it?
(A) 4
(B) 6
(C) 8
(D) 10
Answer: (C)
Explanation: In One-address instructions, an accumulator register is required to perform all the instructions. Load and store operations are performed to fetch the values of operands from registers or memory to accumulators and to store the value of accumulator to a memory location. Instructions required to execute the code:
X = (M + N x O)/(P x Q) 1) Load A : ACC <-- M[M] 2) Add N : ACC <-- ACC + M[N] 3) Mul O : ACC <-- ACC x M[O] 4) Store T : M[T] <-- ACC 5) Load P : ACC <-- M[P] 6) Mul Q : ACC <-- ACC x M[Q]d 7) Div T : ACC <-- M[T] / ACC 8) Store X : M[X] <-- ACC
So, option (C) is correct.
Quiz of this Question
Attention reader! Don't stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.