GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Trace PC used as an autoincrement operand register

2 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Follow the shared one-memory-word instruction at word address 2000 through fetch, operand access through PC, and postincrement. One subpart requests the operand address; the other the final PC for a non-jump.

Descriptive
Report issue

Operand address with PC autoincrement

Instructions & Addressing Modes

Question 10(a), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. Find the operand address.
Question 10(a), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. Find the operand address.
Tap to enlarge
Answer & solution

Answer: 2001, under conventional instruction-fetch PC advancement. (no official key was published)

Use the conventional fetch sequence for a word-addressed CPU. Before instruction fetch PC=2000. Fetching the one-word instruction into the instruction register advances PC to 2001. Decoding then selects PC as the mode-2 address register. The effective operand address is the value of PC at that point, namely 2001, so the operand is the contents of memory word M[2001]. The operand fetch subsequently increments PC again, but this later value is not the operand address.

In register-transfer notation: IR ← M[PC]; PC ← PC+1; EA ← PC; operand ← M[EA]; PC ← PC+1. The addresses 2000 and 2001 respectively hold the instruction and its following operand word. This is the usual immediate-operand idiom implemented by PC autoincrement. It assumes ordinary instruction-fetch advancement of the PC, implicit in the question's CPU convention; it does not treat PC as still 2000 during operand addressing.

Original paper, page 10

Descriptive
Report issue

PC after operand fetch

Instructions & Addressing Modes

Question 10(b), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. For a non-jump instruction, find PC after execution.
Question 10(b), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. For a non-jump instruction, find PC after execution.
Tap to enlarge
Answer & solution

Answer: 2002. (no official key was published)

There are two distinct increments. First the instruction fetch consumes the memory word at 2000 and advances PC to 2001. Next mode 2 uses the current PC as the address of the operand, reads M[2001], and increments that selected register by one. Because the selected register is PC, it becomes 2002.

The instruction is specified to be non-jumping, so no later branch-target assignment replaces this sequential address. PC=2002 therefore identifies the next instruction, after both the instruction word and its inline operand word. Do not increment a third time for execution: the next fetch has not yet happened. Conversely 2001 accounts only for instruction fetch and overlooks the addressing mode's explicit post-increment. This result uses the conventional word-addressed fetch semantics implicit in part (a).

Original paper, page 10