The expression \( X = (A+B) \times (C+D) \) has been evaluated using two address instructions method. The following is the set of instructions used.
MOV R1, A
(B) MUL R1, R2
(C) MOV R2, C
(D) ADD R2, D
(E) MOV X, R1
\(\textbf{Choose the correct sequence of instruction execution from the options given below:}\)
A, B, C, D
A, C, B, D
B, A, D, C
C, B, D, A
Step 1: Understand the Expression.
We are given the expression \( X = (A+B) \times (C+D) \), and we are using two-address instructions. This involves loading operands into registers, performing operations on them, and storing the result in a final variable.
Step 2: Instruction Breakdown.
- (A) MOV R1, A: Load the value of \( A \) into register \( R1 \).
- (C) MOV R2, C: Load the value of \( C \) into register \( R2 \).
- (B) MUL R1, R2: Multiply the values in \( R1 \) and \( R2 \), and store the result in \( R1 \). This gives \( A \times C \).
- (D) ADD R2, D: Add the value of \( D \) to register \( R2 \) which currently holds the value of \( C \), so it becomes \( C + D \).
- (E) MOV X, R1: Store the result from \( R1 \) (which contains \( A \times C \)) into the variable \( X \).
Step 3: Execution Order.
The correct sequence of instructions to compute the expression \( (A+B) \times (C+D) \) using two-address instructions is:
1. First, load \( A \) into \( R1 \) (A).
2. Then, load \( C \) into \( R2 \) (C).
3. Perform the multiplication \( A \times C \) (B).
4. Add \( D \) to \( C \) (D).
5. Store the result of multiplication into \( X \) (E).
Step 4: Conclusion.
The correct sequence is (2) A, C, B, D. Therefore, the correct answer is option (2).