Binary file cws/cw03.pdf has changed
Binary file cws/cw04.pdf has changed
--- a/cws/cw04.tex Mon Oct 30 15:08:40 2023 +0000
+++ b/cws/cw04.tex Mon Oct 30 18:46:27 2023 +0000
@@ -41,6 +41,7 @@
\subsection*{Jasmin Assembler}
+For this coursework you will need an assembler.
The Jasmin assembler is available from
\begin{center}
@@ -48,6 +49,7 @@
\end{center}
\noindent
+This is a jar-file you can run on the commandline.
There is a user guide for Jasmin
\begin{center}
@@ -65,7 +67,7 @@
Jasmin, for example \texttt{loops.j}, you can use
\begin{center}
-\texttt{java -jar jasmin-2.4/jasmin.jar loops.j}
+\texttt{java -jar jasmin.jar loops.j}
\end{center}
\noindent in order to translate it into Java Byte Code. If needed, you
@@ -96,12 +98,17 @@
\small\url{http://www.csc.villanova.edu/~tway/courses/csc4181/s2022/labs/finalproject/JVM.pdf}
\end{center}
+\noindent
+If possible use Jasmin for the coursework. The Krakatau assembler
+below as a slightly different syntax.
+
+
\subsection*{Krakatau Assembler}
The Krakatau assembler is available from
\begin{center}
-\url{https://github.com/Storyyeller/Krakatau}
+ \url{https://github.com/Storyyeller/Krakatau/tree/master}
\end{center}
\noindent This assembler requires Python and a package called
@@ -126,7 +133,16 @@
Krakatau is installed (I just downloaded the zip file from
Github and \pcode{Krakatau-master} was the directory where it
was installed). Again the resulting class-file you can run with
-\texttt{java}.
+\texttt{java}. There is also a newer version of Krakatau available at
+
+\begin{center}
+\url{https://github.com/Storyyeller/Krakatau/tree/v2}
+\end{center}
+
+\noindent
+This is now a Rust program using Cargo as package manager (I have not tried this
+version---I assume it should produce the same output, but might be
+easier to install because it avoids Python's \emph{dependency hell}).
%\noindent You need to submit a document containing the answers
@@ -173,7 +189,7 @@
\end{center}
\noindent The intended meaning is to first assign the variable
-\textit{Id} the value of the first arithmetic expression, test
+\textit{Id} the value of the first arithmetic expression, then test
whether this value is less or equal than the value of the
second arithmetic expression. If yes, go through the loop, and
at the end increase the value of the loop variable by 1 and
@@ -267,7 +283,7 @@
\end{center}
\noindent
-should print out 1 to 10 with the first for-loop, but only 1
+should print out 0 to 10 with the first for-loop, but only 0
to 4 in the second. Similarly it should print out \code{"Should print"},
but not \code{"Should not print"}. For this you need to add
a label to the end of every for-loop and also to the end of the
@@ -304,7 +320,7 @@
\begin{center}
\begin{minipage}{12cm}
\begin{lstlisting}[language={},numbers=none]
-javap -v HelloWorld
+javap -c HelloWorld
\end{lstlisting}
\end{minipage}
\end{center}
@@ -318,7 +334,7 @@
\begin{minipage}{12cm}
\begin{lstlisting}[language=Scala,numbers=none]
object HelloWorld {
- def main(args: Array[String]) {
+ def main(args: Array[String]) = {
println("Hello World!")
}
}
@@ -420,10 +436,11 @@
\end{center}
\noindent
-where \texttt{n} is the index of the variable that requires an input. If you
-use Windows you need to take into account that a ``return'' is not just a newline,
-\code{'\\10'}, but \code{'\\13\\10'}. This means you need to change line~12 in
-Figure~\ref{read} to \pcode{ldc 13}.
+where \texttt{n} is the index of the variable that requires an input.
+%If you
+%use Windows you need to take into account that a ``return'' is not just a newline,
+%\code{'\\10'}, but \code{'\\13\\10'}. This means you need to change line~12 in
+%Figure~\ref{read} to \pcode{ldc 13}.
\begin{figure}[t]\small
@@ -439,9 +456,13 @@
invokevirtual java/io/InputStream/read()I
istore 2
iload 2
- ldc 10 ; the newline delimiter for Unix (Windows 13)
+ ldc 10 ; test for the newline delimiter for Unix
isub
- ifeq Label2
+ ifeq Label2
+ iload 2
+ ldc 13 ; test for the carriage-return in Windows
+ isub
+ ifeq Label2
iload 2
ldc 32 ; the space delimiter
isub
@@ -462,7 +483,10 @@
ireturn
.end method
\end{lstlisting}\normalsize
-\caption{Assembler code for reading an integer from the console.\label{read}}
+\caption{Assembler code for reading an integer from the console.
+ This code is portable for Unix and Windows (see Lines 11--18 for 2 separate
+ tests for the various end-of-line markers). Thanks to Harry
+ Dilnot to make it portable.\label{read}}
\end{figure}
\end{document}