This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ECE 209 Fall 2007 Homework 3 1. (12 points) During a function call on the LC-3, state whether the caller or the callee places the following items on the stack, and explain why. (a) Return value Callee – can’t put the value to be returned until it’s computed, and the callee does that. (b) Local variables Callee – only the callee knows anything about its local variables. (c) Arguments Caller – only the caller knows how to compute the values that will be passed in; these will be different every time the function is called, so the callee certainly can’t do it. (d) Dynamic link Callee – gets pushed after the return address, which can only be done by the callee because R7 is set by the JSR instruction that transfers control to the callee. 2. (8 points) When writing subroutines for the LC-3, we always used the callee-save strategy for saving general-purpose registers. Ignoring the “special” registers (R4-R7), does the callee need to save registers (R0-R3) when it’s part of a C program? Explain why or why not. Don’t need to do callee-save, because no data is saved in registers. Data is in variables, which are in memory. (If caller needs to save a temporary value that’s not associated with a variable, then it should do so before calling – essentially, this becomes “caller-save”.) 1 ECE 209...
View Full Document
This note was uploaded on 03/24/2008 for the course ECE 209 taught by Professor Tuck during the Spring '08 term at N.C. State.
- Spring '08