%% LyX 1.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[twocolumn]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}

\makeatletter


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}

\makeatletter


\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}

\makeatletter


\usepackage[T1]{fontenc}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}

\makeatletter


\usepackage[T1]{fontenc}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}

\makeatletter


\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.4pt}

\makeatother

\makeatother

\makeatother


\makeatother

\makeatother

\begin{document}

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

\textbf{Directions: Work only on this sheet (on both sides, if needed); do not
turn in any supplementary sheets of paper. There is actually plenty of room
for your answers, as long as you organize yourself BEFORE starting writing.
In order to get full credit, SHOW YOUR WORK.}

{\bf 1.}  In class, we mentioned that some OS features are impossible to
implement without certain hardware.  Fill in the blanks:

\begin{itemize}

\item [(a)] (10) Timesharing is impossible without
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\item [(b)] (5) Protection of one program's memory from writing by
another program is impossible without \_\_\_\_\_\_\_\_\_\_\_\_\_.

\end{itemize}

{\bf 2.}  Fill in the following blanks with powers of 2.  Write, for
example, $2^7$, not 128.  (The various parts of this problem are
completely independent of each other.)

\begin{itemize}

\item [(a)] (5) The maximum number of C {\bf int} variables which could
fit in an Intel page is \_\_\_\_\_\_\_\_\_.

\item [(b)] (10) Assume the page-table format on p.15 of the OS unit in
our PLN.  Then a page table could occupy as many as \_\_\_\_\_\_\_\_\_ bytes
in memory.

\item [(c)] (5) In 12-bit 2s complement storage, the largest value of a signed
integer is \_\_\_\_\_\_\_\_\_- 1.

\item [(d)] (5) In 12-bit 2s complement storage, the largest value of an
unsigned integer is \_\_\_\_\_\_\_\_\_- 1.

\item [(e)] (10) The size, in bytes, of the stack space assigned to a
program by the OS on an Intel machine will likely be a multiple of
\_\_\_\_\_\_\_\_\_.

\end{itemize}

{\bf 3.} (5) MIPS programmers usually pass subroutine arguments via
registers, not via a stack.  Sometimes we even do this on Intel.  Cite
an example from our PLN of this.

{\bf 4.} Suppose we wish to set up a stack data structure (not
necessarily related to subroutine calls) on a MIPS machine.  Say the
stack grows toward 0, and we use \$28 as our stack pointer.  

\begin{itemize}

\item [(a)] (10) Give MIPS assembly code, at most three instructions or
pseudoinstructions, which would push the value 7 onto the stack.  (Don't
worry about changing register contents.)

\item [(b)] (5) Give a real MIPS assembly instruction which will copy
\$12 to the next-to-top element of the stack.

\end{itemize}

{\bf 5.} (10) Give a \underline{single} Intel assembly language
instruction which will replace c(EAX) by c(EAX) mod 32.

{\bf 6.} (10) In our Java example, Minimum.java, suppose the assignment
to X in main() had been

\begin{verbatim}
X = Integer.parseInt(Args[4]);
\end{verbatim}

Show what JVM assembly language code would be generated by the compiler.

{\bf 7.} (10) Look at the program at the top of p.17 in the OS unit in our
PLN.  Give a \underline{single} C {\bf printf()} statement, to be placed
somewhere in main(), which will print out the contents of ESP. 

{\bf Solutions:}

{\bf 1.a.}  The timer.

{\bf 1.b.}  Virtual memory hardware.

{\bf 2.a.}  $2^{10}$.

{\bf 2.b.}  $2^{22}$.

{\bf 2.c.}  $2^{11}$.

{\bf 2.d.}  $2^{12}$.

{\bf 2.e.}  $2^{12}$.

{\bf 3.}  The example of system calls in the OS unit of the PLN.

{\bf 4.a.} 

\begin{verbatim}
subu $28,$28,4
li $4,7
sw $4,0($28)
\end{verbatim}

{\bf 4.b.}  

\begin{verbatim}
sw $12,4($28)
\end{verbatim}

{\bf 5.}

\begin{verbatim}
andl $0x1f, %eax
\end{verbatim}

{\bf 6.}

\begin{verbatim}
aload_0
iconst_4
aaload
\end{verbatim}

{\bf 7.}

\begin{verbatim}
printf("%d\n",&i);
\end{verbatim}

\end{document}

