324_Book

# B we can x the bug by replacing the exit function

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: p ´ ¡ ¡ · µ 4 load a %st(1) %st(0) divp 5 addp · ¡ ¡ ¡ µ %st(0) 12 multp ¡ ¡ ´ · ¡ µ %st(0) 6 neg ´ · %st(0) 13 storep x ´ · µ %st(1) %st(0) 7 load c Problem 3.26 Solution: [Pg. 179] This code is similar to that generated by the compiler for selecting between two values based on the outcome of a test. test %eax,%eax %st(1) %st(0) jne L11 fstp %st(0) jmp L9 L11: %st(0) fstp %st(1) L9: %st(0) The resulting top of stack value is x ? a : b. Problem 3.27 Solution: [Pg. 182] 714 APPENDIX B. SOLUTIONS TO PRACTICE PROBLEMS Floating-point code is tricky, with all the different conventions about popping operands, the order of the arguments, etc. This problem gives you a chance to work through some speciﬁc cases in complete detail. 1 fldl b %st(0) %st(1) 2 fldl a %st(0) 3 fmul %st(1),%st ¡ ¡ %st(1) %st(0) %st(1) %st(0) 4 fxch ¡ 5 %st(1) %st(0) fdivrl c 6 fsubrp ¡ %st(0) 7 fstp x This code computes the expression x = a*b - c/b. Problem 3.28 Solution: [Pg. 184] This problem requires you to think about the different oper...
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