handouts/ho07.tex
changeset 943 5365ef60707e
parent 941 66adcae6c762
child 960 c7009356ddd8
--- a/handouts/ho07.tex	Fri Oct 13 23:49:34 2023 +0100
+++ b/handouts/ho07.tex	Sat Oct 21 09:09:09 2023 +0100
@@ -91,7 +91,7 @@
 \noindent The first instruction loads the constant $1$ onto the stack,
 the next one loads $2$, the third instruction adds both numbers together
 replacing the top two elements of the stack with the result $3$. For
-simplicity, we will consider throughout only arithmetic involving
+simplicity, we will consider only arithmetic operations involving
 integer numbers. This means our main JVM instructions for arithmetic
 will be \instr{iadd}, \instr{isub}, \instr{imul}, \instr{idiv} and so on.
 The \code{i} stands for integer instructions in the JVM (alternatives
@@ -341,7 +341,7 @@
 unconditional, meaning we always have to jump to the end of
 $cs_2$. The corresponding instruction of the JVM is
 \instr{goto}. In case $b$ turns out to be false we need the
-control-flow
+control-flow to be:
 
 \begin{center}
 \begin{tikzpicture}[node distance=2mm and 4mm,line cap=round,
@@ -476,7 +476,7 @@
 if-statement:
 
 \begin{lstlisting}[mathescape,numbers=none,language=While]
-if 1 = 1 then x := 2 else y := 3
+if 1 == 1 then x := 2 else y := 3
 \end{lstlisting}
 
 \noindent 
@@ -503,7 +503,7 @@
 \end{tikzpicture}
 
 \noindent The first three lines correspond to the the boolean
-expression $1 = 1$. The jump for when this boolean expression
+expression \texttt{1 == 1}. The jump for when this boolean expression
 is false is in Line~3. Lines 4-6 corresponds to the if-branch;
 the else-branch is in Lines 8 and 9. 
 
@@ -642,23 +642,24 @@
 void). Since the method has only one argument, we only need a single
 local variable (Line~2) and a stack with two cells will be sufficient
 (Line 3). Line 4 instructs the JVM to get the value of the member
-\pcode{out} from the class \pcode{java/lang/System}. It expects the value
-to be of type \pcode{java/io/PrintStream}. A reference to this value
-will be placed on the stack.\footnote{Note the syntax \texttt{L
-\ldots{};} for the \texttt{PrintStream} type is not an typo. Somehow the
-designers of Jasmin decided that this syntax is pleasing to the eye. So
-if you wanted to have strings in your Jasmin code, you would need to
-write \texttt{Ljava/lang/String;}\;. If you want arrays of one
-dimension, then use \texttt{[\ldots}; two dimensions, use
-\texttt{[[\ldots} and so on. Looks all very ugly to my eyes.} Line~5
-copies the integer we want to print out onto the stack. In the line
-after that we call the method \pcode{println} (from the class
-\pcode{java/io/PrintStream}). We want to print out an integer and do not
-expect anything back (that is why the type annotation is \pcode{(I)V}).
-The \pcode{return}-instruction in the next line changes the control-flow
-back to the place from where \pcode{write} was called. This method needs
-to be part of a header that is included in any code we generate. The
-helper-method \pcode{write} can be invoked with the two instructions
+\pcode{out} from the class \pcode{java/lang/System}. It expects the
+value to be of type \pcode{java/io/PrintStream}. A reference to this
+value will be placed on the stack.\footnote{Note the syntax
+  \texttt{Ljava\ldots{};} for the \texttt{PrintStream} type is not an
+  typo. Somehow the designers of Jasmin decided that this syntax is
+  pleasing to the eye. So if you wanted to have strings in your Jasmin
+  code, you would need to write \texttt{Ljava/lang/String;}\;. If you
+  want arrays of one dimension, then use \texttt{[\ldots}; two
+  dimensions, use \texttt{[[\ldots} and so on. Looks all very ugly to
+  my eyes.} Line~5 copies the integer we want to print out onto the
+stack. In the line after that we call the method \pcode{println} (from
+the class \pcode{java/io/PrintStream}). We want to print out an
+integer and do not expect anything back (that is why the type
+annotation is \pcode{(I)V}).  The \pcode{return}-instruction in the
+next line changes the control-flow back to the place from where
+\pcode{write} was called. This method needs to be part of a header
+that is included in any code we generate. The helper-method
+\pcode{write} can be invoked with the two instructions
 
 \begin{lstlisting}[mathescape,language=JVMIS]
 iload $E(x)$ 
@@ -745,11 +746,11 @@
 section let us have a look at how we can support the following three
 constructions
 
-\begin{lstlisting}[mathescape,language=While]
-new(arr[15000])
-x := 3 + arr[3 + y]
-arr[42 * n] := ...
-\end{lstlisting}
+\begin{itemize}
+\item \lstinline|new(arr[15000])|
+\item \lstinline|x := 3 + arr[3 + y]|
+\item \lstinline|arr[42 * n] := ...|
+\end{itemize}  
 
 \noindent
 The first construct is for creating new arrays. In this instance the