cs313-2006-t2-midterm1-solution - CPSC 313, 06w Term 2...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CPSC 313, 06w Term 2 Midterm 1 Solutions Date: February 9, 2007; Instructor: Norm Hutchinson 1. (8 marks) Short answers. 1a. (2 marks) Is the address of a global variable in a C program determined statically (before the program runs) or dynamically (while the program is executing)? Briefly explain. It is determined statically , by the linker in particular. 1b. (2 marks) Is the content of the jump table used in the execution of a switch statement determined statically or dynamically ? Briefly explain. It is statically determined, since the address of each piece of code is determined by the linker. 1c. (2 marks) Does the IA32 instruction-set architecture require that %eax be used to hold the value returned from a C function call? Briefly explain. It does not require it - any register or even the stack could be used for this purpose. The use of %eax is a convention. 1d. (2 marks) If %ecx holds the address of an integer array a , and %edx holds the integer i , give a single assembly-language statement that computes &a[i] and places it in the register %eax . leal (%ecx,%edx,4), %eax # eax = &a[i] 2. (8 marks) Consider the following C source file....
View Full Document

This note was uploaded on 10/09/2011 for the course CPSC 344 taught by Professor Karen during the Fall '10 term at The University of British Columbia.

Page1 / 4

cs313-2006-t2-midterm1-solution - CPSC 313, 06w Term 2...

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

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