{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

problemset6solutions

problemset6solutions - Department of Electrical and...

This preview shows pages 1–4. Sign up to view the full content.

Department of Electrical and Computer Engineering The University of Texas at Austin EE 306, Fall 2006 Problem Set 6 Solutions Due: Not to be turned in Yale N. Patt, Instructor TAs: Aseem Bathla, Cameron Davison, Lisa de la Fuente, Phillip Duran, Jose Joao, Jasveen Kaur, Rustam Miftakhutdinov, Veynu Narasiman, Nady Obeid, Poorna Samanta Note: This problem set is unusually long, and is not to be turned in. We have put it together and handed it out to give you some challenging examples to help you prepare for the final exam. 1. A zero-address machine is a stack-based machine where all operations are done by using values stored on the operand stack. For this problem, you may assume that the ISA allows the following operations: PUSH M - pushes the value stored at memory location M onto the operand stack. POP M - pops the operand stack and stores the value into memory location M. OP - Pops two values off the operand stack and performs the binary operation OP on the two values. The result is pushed back onto the operand stack. Note: OP can be ADD, SUB, MUL, or DIV for parts a and b of this problem. Note: See the stack machine supplemental handout for help on this problem. a. Draw a picture of the stack after each of the instructions below are executed. What is the minimum number of memory locations that have to be used on the stack for the purposes of this program? Also write an arithmetic equation expressing u in terms of v, w, x, y, and z. The values u, v, w, x, y, and z are stored in memory locations U, V, W, X, W, and Z. b. PUSH V c. PUSH W d. PUSH X e. PUSH Y f. MUL g. ADD h. PUSH Z i. SUB j. DIV k. POP U

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Minimum number of memory locations: 4 u = v/((w+(x*y))-z) l. Write the assembly language code for a zero-address machine (using the same type of instructions from part a) for calculating the expression below. The values a, b, c, d, and e are stored in memory locations A, B, C, D, and E. e = ((a * ((b - c) + d))/(a + c)) m. PUSH A n. PUSH B o. PUSH C p. SUB q. PUSH D r. ADD s. MUL t. PUSH A u. PUSH C v. ADD w. DIV x. POP E 2. Do Problem 9.13 on page 244 in the textbook. The problem is that subroutine A calls subroutine B which destroys the linkage back to the original program. Subroutine A needs to save R7 and then load it back before it returns.
3. Do Problem 6.16 on page 175 in the textbook. 4.

This preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

Page1 / 8

problemset6solutions - Department of Electrical and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online