edited by
21,175 views
54 votes
54 votes

Consider the following data path of a simple non-pipelined CPU. The registers $A, B$, $A_{1},A_{2}, \textsf{MDR},$ the $\textsf{bus}$ and the $\textsf{ALU}$ are $8$-$bit$ wide. $\textsf{SP}$ and $\textsf{MAR}$ are $16$-$bit$ registers. The $\textsf{MUX}$ is of size $8 \times (2:1)$ and the $\textsf{DEMUX}$ is of size $8 \times (1:2)$. Each memory operation takes $2$ $\textsf{CPU}$ clock cycles and uses $\textsf{MAR}$ (Memory Address Register) and $\textsf{MDR}$ (Memory Date Register). $\textsf{SP}$ can be decremented locally.

The $\textsf{CPU}$ instruction "push r" where, $r =$ $A$ or $B$ has the specification

  • $M[SP] ← r $
  • $SP ← SP - 1$

How many $\textsf{CPU}$ clock cycles are required to execute the "push r" instruction?

  1. $2$
  2. $3$
  3. $4$
  4. $5$
edited by

11 Answers

0 votes
0 votes
  1. Fetch Instruction: (1 cycle)

    • Retrieve the instruction "push r" from memory.
  2. Decode and Read Register r: (1 cycle)

    • Decode the instruction to determine which register (A or B) to push.
    • Read the value from the specified register r.
  3. Memory Write: (2 cycles)

    • Load the value from r into the MDR (Memory Data Register).
    • Transfer the content of SP to MAR (Memory Address Register).
    • Write the value from MDR to memory at the address specified by MAR.
  4. Decrement SP: (1 cycle)

    • Subtract 1 from the value in the SP (Stack Pointer) register.

Therefore, the entire "push r" instruction requires 1 + 1 + 2 + 1 = 5 CPU clock cycles to complete.

Answer:

Related questions

55 votes
55 votes
12 answers
1
47 votes
47 votes
6 answers
2