Share
Explore BrainMass

Explanation of a Series of Assembly Arithmetic Operations

Assume a stack-oriented processor that includes the stack operations PUSH and POP. Arithmetic operations automatically involve the top one or two stack elements. Begin with an empty stack. What stack elements remain after the following instructions are executed?
PUSH 4
PUSH 7
PUSH 8
ADD
PUSH 10
SUB
MUL

Solution Preview

As the problem stated, we start with an empty stack. After the first instruction the stack looks like this:

4
---

The next statement is a PUSH so the new value is added to the top of the stack. We have:

7
4
---

The next statement is a PUSH so the ...

Solution Summary

In this solution I provide a detailed explanation of how a stack-based machine processes and evaluates an arithmetic expression that contains more than one operator.

$2.19