exam2-rubric - ECE 468 Midterm 2 November 4 2010 Name...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 468 — Midterm 2 November 4, 2010 Name: ______________________________________ Purdue email: ______________________________________ Please sign the following: I afFrm that the answers given on this test are mine and mine alone. I did not receive help from any person or material (other than those explicitly allowed). X ___________________________________________ Part Points Score 1 30 2 20 3 15 4 35 Total 100
Background image of page 1

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

View Full Document Right Arrow Icon
Part 1: Semantic actions and functions (30 pts) 1) Explain when pass-by-value will produce the same results as pass-by- reference (2 pts): No partial credit. Note: a few people brought up passing arrays. The key with arrays is that they are always passed by reference in C/C++, not that pass-by-reference and pass-by-value do the same thing. You could design a language that could pass arrays by value (i.e., by copying them into the arguments), in which case pass-by-value would differ from pass- by-reference. 2) a) Give one reason that caller-saves is better than callee-saves (2 points). b) Give one reason that callee-saves is better than caller-saves (2 points). No partial credit 3) Draw the AST that would be generated for the expression x := y + z * w and for each AST node, show the data object that would be generated. For each data object, show the code that would be generated (if any), the temporary the result will be stored in, and whether the temporary is an R-value or an L-value. (14 pts) 7 AST nodes, 1 point per node, 1 point per piece of code. Don ʼ t forget to add in the AST nodes for “x :=”! Note that a lot of people loaded from variables immediately upon seeing them (as
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

exam2-rubric - ECE 468 Midterm 2 November 4 2010 Name...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online