Chapter14solutions

Chapter14solutions - Chapter 14 14.1. The function main()...

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

View Full Document Right Arrow Icon
Chapter 14 14.1. The function main() is the place in a C program where execution begins. A program without a function main() has no starting point. 14.2. a. When a function is called, the address of the caller's activation record on the runtime stack is referred to as the dynamic link. The dynamic link enables the caller’s frame pointer to be restored when the callee completes. b. The return address is the address of the next instruction in the caller to be executed when the callee returns control. It is the instruction immediately following the JSR in the caller. The return address enables us to resume execution in the caller once the callee completes. c. The return value is the output (actually, one of the outputs) of a function. 14.3. a. The function declaration informs the compiler about the return type, input parameters, and function name for a given function. This information is required so that the compiler can generate code for a function call to this function if it appears in the source code prior to the function definition. b. A function prototype is the same as function definition. c. A function definition contains the source code for a function. d. An argument is an input value for a callee function. e. A parameter is a value provided by the caller function for at callee function. 14.4. a. caller b. callee c. callee d. callee 14.5. The output of the program is "2 2". The variable 'z' in the function MyFunc() is declared within the local scope of the function. The value of 'z' from main() is passed to MyFunc(), but all operations on 'z' in MyProc affect only the local copy and not the one in main(). 14.6. "1 2 6 3 4 "
Background image of page 1

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

View Full DocumentRight Arrow Icon
14.7. Activation Record Description Writer int a local variable Bump dynamic link address of data Bump return address address of instruction Bump return value other Bump int x argument --- 14.8 The output of the program is “x = 1 y = 2”. Even though the function Swap() swaps the values of the two arguments, these values are only swapped in the activation record for Swap. From the perspective of function main(), the values of x and y remain unchanged. 14.9. The parameters are placed onto the stack before the JSR is called.
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.

Page1 / 10

Chapter14solutions - Chapter 14 14.1. The function main()...

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