Which sequence of one-address, accumulator-based instructions can be used to…
2018
Which sequence of one-address, accumulator-based instructions can be used to evaluate Y = (A - B) / (C + D * E)?
- A.
LOAD DMPY EADD CSTORE YLOAD ASUB BDIV YSTORE Y - B.
LOAD DMPY EADD CLOAD ASTORE YSUB BDIV YSTORE Y - C.
LOAD DADD CMPY ESTORE YLOAD ASUB BDIV YSTORE Y - D.
LOAD DMPY EADD CSTORE YLOAD ADIV YSUB BSTORE Y
Attempted by 145 students.
Show answer & explanation
Correct answer: A
Instruction logic:
Denominator: First compute
D * E, then addCto getC + D * E. Store this intermediate value.Numerator: Then compute
A - B.Final division: Divide the numerator by the stored denominator and store the result in
Y.
Correct sequence:
LOAD DMPY EADD CSTORE YLOAD ASUB BDIV YSTORE Y
Final answer: Option A