324_Book

# Even for the case where one of the arguments is in

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: . The storep operation pops the top element from the stack and stores the result in memory. A unary operation such as neg (negation) uses the top stack element as its argument and overwrites this element with the result. Binary operations such as addp and multp use the top two elements of the stack as their arguments. They pop both arguments off the stack and then push the result back onto the stack. We use the sufﬁx ‘p’ with the store, add, subtract, multiply, and divide instructions to emphasize the fact that these instructions pop their operands. As an example, suppose we wish to evaluate the expression x = (a-b)/(-b+c). We could translate this expression into the following code. Alongside each line of code, we show the contents of the ﬂoating-point 3.14. *FLOATING-POINT CODE 177 register stack. In keeping with our earlier convention, we show the stack as growing downward, so the “top” of the stack is really at the bottom. 1 · %st(2) %st(1) %st(0) load c %st(0) 6 load a %st(1) 2 load b %st(0) 7 subp · %st(1) %st(0) 3 neg · %st(1) %st(0)...
View Full Document

## This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online