retagged by
15,589 views
55 55 votes

Assume that EA = (X)+ is the effective address equal to the contents of location X, with X incremented by one word length after the effective address is calculated; EA = −(X) is the effective address equal to the contents of location X, with X decremented by one word length before the effective address is calculated; EA = (X)− is the effective address equal to the contents of location X, with X decremented by one word length after the effective address is calculated. The format of the instruction is (opcode, source, destination), which means (destination ← source op destination). Using X as a stack pointer, which of the following instructions can pop the top two elements from the stack, perform the addition operation and push the result back to the stack.

  1. ADD (X)−, (X)
  2. ADD (X), (X)−
  3. ADD −(X), (X)+
  4. ADD −(X), (X)

10 Answers

1 1 vote
  1. ADD (X)−, (X):

    • This instruction decrements the stack pointer after the effective address calculation, so it pops the top two elements from the stack.
  2. ADD (X), (X)−:

    • This instruction decrements the stack pointer before the effective address calculation. It pops one element from the stack, not two.
  3. ADD −(X), (X)+:

    • This instruction increments the stack pointer before the effective address calculation, so it doesn't pop the top two elements from the stack.
  4. ADD −(X), (X)+:

    • Similar to option 3, this instruction increments the stack pointer before the effective address calculation, so it doesn't pop the top two elements from the stack.

Therefore, the correct instruction that can pop the top two elements from the stack, perform the addition operation, and push the result back onto the stack is: ADD (X)−, (X)

0 0 votes
If we assume a top down stack where top=top+1.
(100 101 102 103 104<-top)
and see option b
Add (X) ,(X)-
and look at the format= (opcode, source, destination) destination <-source + destination
103=104 + 103
Isn't this coreect

option A Add (X)-,(X)
104=103+104

So this option have not decreased our stack by 1.
but we want Pop, Pop , Push
so top should be definetly one less.

So option B.

 
0 0 votes

Option A: ADD (X)−, (X)

Interpretation / order: evaluate source (X)− first, then destination (X).

  1. Source (X)− (post-decrement): EA = contents at X = 1000 (this is the top element). After EA is computed the CPU does X ← X − 1 → now X = 999.

  2. Destination (X) (no modifier): Now uses the current X = 999 (the former second element).

  3. Compute destination ← source + destination → store sum into address 999.

Effect: we effectively read addresses 1000 and 999, decrement the pointer once (so top element removed), and store the result at 999. Net effect: top two elements were popped, their sum pushed at the new top (999). This matches exactly the required operation (pop two, add, push result). (Example in memory: 999 ← (1000) + (999)).

Option B: ADD (X), (X)−

  • Source (X) reads X = 1000 (top).

  • Destination (X)− is post-decrement: EA = contents at the current X (still 1000), then X decremented to 999.

  • Both operands refer to same address 1000 — you add top with top, then decrement pointer once and store into address 1000 (or possibly 1000 overwritten then pointer decremented). This does not pop two distinct elements. So B fails.

Option C: ADD −(X), (X)+

  • Source −(X) is pre-decrement: X becomes 999, then EA uses address 999.

  • Destination (X)+ is post-increment: EA uses current X (which is 999), then increments X to 1000.

  • Both operands refer to same address 999 — again not two distinct pops. So C fails.

Option D: ADD −(X), (X)

  • Source −(X) pre-decrements X to 999, EA = contents at 999.

  • Destination (X) then uses current X = 999 as well. Both operands refer to same address 999. So D fails.

Answer:
Position:
Show:

Related questions

43 43 votes
4 answers 4 answers
9.8k
9.8k views
Ishrat Jahan asked Oct 29, 2014
9,837 views
Consider a computer with a $4$-ways set-associative mapped cache of the following character­istics: a total of $1\;\text{MB}$ of main memory, a word size of $1\;\text{byt...
30 30 votes
2 answers 2 answers
10.1k
10.1k views
Ishrat Jahan asked Oct 29, 2014
10,057 views
Consider a computer with a $4$-ways set-associative mapped cache of the following character­istics: a total of $1 \ MB$ of main memory, a word size of $1$ byte, a block s...
62 62 votes
6 answers 6 answers
22.4k
22.4k views
Ishrat Jahan asked Oct 28, 2014
22,399 views
A non pipelined single cycle processor operating at $100\;\text{MHz}$ is converted into a synchro­nous pipelined processor with five stages requiring $2.5\;\text{nsec}, 1...
66 66 votes
9 answers 9 answers
28.5k
28.5k views
Ishrat Jahan asked Oct 28, 2014
28,472 views
Consider a CPU where all the instructions require $7$ clock cycles to complete execution. There are $140$ instructions in the instruction set. It is found that $125$ cont...