\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 1.} (20) Consider the program on pp.64-65.  Suppose we wish to sum
only the even-numbered indexed elements of the array, treating the word
in line 6 as element 0, the one in line 7 as element 1 and so on.  We'll
need to change two lines in the code.  State the line numbers and the
changes.  Your answer MUST have the form,

\begin{lstlisting}
change line 28 to "incl %eax" and change 
line 168 to "addl $2, w"
\end{lstlisting}

(The answer is drawn as two lines here so as to fit the column width,
but remember that it must be a SINGLE-line answer in your electronic
file.)

{\bf 2.} Consider the program in Section 3.6, pp.72ff.
For each of the following, state whether the item is an instruction,
label, addressing mode or directive:

\begin{itemize}

\item [(a)] (5) {\bf swap} in line 37

\item [(b)] (5) {\bf call} in line 37

\item [(c)] (5) {\bf \$999999} in line 65

\item [(d)] (5) {\bf decl} in line 2

\item [(e)] (5) {\bf .long 18} in line 9

\end{itemize}

{\bf 3.} Consider the letter-counting code on pp.93-94.

\begin{itemize}

\item [(a)] (20) What is the maximum possible count for any given letter?

\item [(b)] (10) Give a one-operand instruction (i.e. no comma in the
assembly language) that we could use instead of the {\bf addl} in line
33.

\end{itemize}

{\bf 4.} (25) Consider the program on pp.64-65.  Show the line numbers
of all the instructions that could cause cache misses during the
execution (not fetch) part of the cycle.

{\bf Solutions:}

{\bf 1.}

\begin{lstlisting}
18:   movl $2, %eax
24:   addl $8, %ecx
\end{lstlisting}

{\bf 2.} label, instruction, addressing mode, instruction, directive

{\bf 3.a}  255

{\bf 3.b} \lstinline{incl %eax}  

{\bf 4.} 23, 27

\end{document} 
