44 views

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$ incremented 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 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 $(\text{opcode, } \text{destination, } \text{source})$, which means $(\text{destination } \leftarrow \text{ source } \: \text{ op } \text{destination})$ with address of source operand being evaluated before the address of destination operand. 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)+$
edited | 44 views

$ADD \: (X), (X)-$
First sources operand is evaluated as $(X)-$ which takes the element at TOS and decrements the pointer by 1 element. Now $X$ points to second operand which is the destination operand itself. So just adding these two will do the job.

1
2