Binary file handouts/ho07.pdf has changed
--- a/handouts/ho07.tex Tue Nov 17 04:38:01 2015 +0000
+++ b/handouts/ho07.tex Tue Nov 17 04:53:14 2015 +0000
@@ -578,6 +578,23 @@
work harder and find out appropriate values for the stack and
local variables.
+To sum up, in Figure~\ref{test} is the complete code generated
+for the slightly non-sensical program
+
+\begin{lstlisting}[mathescape,language=While]
+x := 1 + 2;
+write x
+\end{lstlisting}
+
+\noindent Having this code at our disposal, we need the
+assembler to translate the generated code into bytecode (a
+class file) that can be understood by the JVM.
+
+
+\begin{figure}[p]
+\lstinputlisting{../progs/test-small.j}
+\caption{Generated code for a test program.\label{test}}
+\end{figure}
\end{document}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/test-small.j Tue Nov 17 04:53:14 2015 +0000
@@ -0,0 +1,29 @@
+.class public test.test
+.super java/lang/Object
+
+.method public <init>()V
+ aload_0
+ invokenonvirtual java/lang/Object/<init>()V
+ return
+.end method
+
+.method public static write(I)V
+ .limit locals 1
+ .limit stack 2
+ getstatic java/lang/System/out Ljava/io/PrintStream;
+ iload 0
+ invokevirtual java/io/PrintStream/println(I)V
+ return
+.end method
+
+.method public static main([Ljava/lang/String;)V
+ .limit locals 200
+ .limit stack 200
+ ldc 1
+ ldc 2
+ iadd
+ istore 0
+ iload 0
+ invokestatic test/test/write(I)V
+ return
+.end method