\documentclass[twocolumn]{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}

\setlength\columnsep{25pt}

\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{listings}
\usepackage{amsmath}

\begin{document}

\lstset{xleftmargin=5mm,framexleftmargin=10mm,basicstyle=\footnotesize}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: {\bf \Large Work only on this sheet} (on both sides, if
needed).  MAKE SURE TO COPY YOUR ANSWERS TO A SEPARATE SHEET FOR SENDING
ME AN ELECTRONIC COPY LATER.

{\bf On all Tests, 32-bit word size on Intel machines running Linux is
assumed unless otherwise stated.}

{\bf 1.} (20)  A C's {\bf return} is translated to a certain
machine/asembly language instruction.  What is its name?

{\bf 2.} (25) Suppose we are debugging the code on pp.64-65.  Then names
such as {\bf sum} and {\bf top} will be available to us from our
debugging tool if we had used the \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ option
at the time we assembled the program.

{\bf 3.} (25) Consider the function

\begin{lstlisting}
int f(n)
{  int k;
   k = n * f(n-1);
   return k;
}
\end{lstlisting}

Suppose at runtime the operating system has allocated 600 words for our
stack, and that we do not have write permission for the first word below
(i.e. at a smaller address) the stack space.  Say the stack is empty,
and we make the call {\bf f(100)}.  Then we will get a seg fault on the
\_\_\_\_\_\_\_\_\_\_\_\_\_\_$^{th}$ (or $^{st}$ or $^{rd}$ or $^{nd}$)
call to {\bf f()}; fill in the blank, using an R expression as your
answer.

{\bf 4.} (30) Suppose several local variables in a C source file are declared
this way:

\begin{lstlisting}
int x = 5;
static y, z = 12;
// equiv. to static int y,z=12;
\end{lstlisting}

Then probably:

\begin{itemize}

\item [(a)] (10) 
The variable {\bf x} will be stored in 
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.


\item [(b)] (10) 
The variable {\bf y} will be stored in
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\item [(c)] (10) 
The variable {\bf z} will be stored in
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\end{itemize}

{\bf Solutions:}

{\bf 1.}

\begin{lstlisting}
ret
\end{lstlisting}

{\bf 2.}

\begin{lstlisting}
--gstabs
\end{lstlisting}

{\bf 3.}
Each call expands the stack by 4 words (1 for argument, 1
for local, 1 for bread crumbs, 1 for saved EBP), so 150 calls will
fill the stack, and the 151st will cause a seg fault.

{\bf 4.a} in the stack

{\bf 4.b} in a {\bf .comm} segment

{\bf 4.c} in a {\bf .data} segment

\end{document}

C return translated to ret

return names like sum, top:  --gstabs

recursion:  each call expands the stack by 4 words (1 for argument, 1
for local, 1 for bread crumbs, 1 for saved EBP), so 150 calls will
fill the stack, and the 151st will cause a seg fault

storage of locals:  x in the stack, y in the .comm section, z in the
.data section

