GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A byte-addressed machine has auto-increment (R1)+ (use R1 as the address, then add 4) and auto-decrement −(R1) (subtract 4 from R1, then use it as the address). Memory holds M[116] = 5, M[120] = 20, M[124] = 40, M[128] = 60. With R1 = 120 and ACC = 0 it executes ADD (R1)+; ADD (R1)+; ADD −(R1); ADD −(R1); ADD −(R1). What are ACC and R1 at the end?

  1. A. ACC = 180, R1 = 116
  2. B. ACC = 125, R1 = 116
  3. C. ACC = 145, R1 = 116
  4. D. ACC = 125, R1 = 120

Correct answer: B. ACC = 125, R1 = 116

(R1)+ reads 120 (+20), R1 = 124; reads 124 (+40), R1 = 128. −(R1): R1 = 124, +40; R1 = 120, +20; R1 = 116, +5. ACC = 20 + 40 + 40 + 20 + 5 = 125, R1 = 116. Treating −(R1) as use-then-decrement gives ACC = 180.

More Computer Organization and Architecture questions

Exams that ask this topic