# HG changeset patch # User Christian Urban # Date 1418332428 0 # Node ID c5850f8f3f5e197af8acbd20d1a8b14519c03280 # Parent 0c43ef11e086afb81a9aeb7a38ee2ad299c2533d updated diff -r 0c43ef11e086 -r c5850f8f3f5e coursework/cw04.pdf Binary file coursework/cw04.pdf has changed diff -r 0c43ef11e086 -r c5850f8f3f5e coursework/cw04.tex --- a/coursework/cw04.tex Wed Dec 10 13:58:06 2014 +0000 +++ b/coursework/cw04.tex Thu Dec 11 21:13:48 2014 +0000 @@ -68,14 +68,13 @@ \subsection*{Question 1 (marked with 5\%)} -You need to lex and parse WHILE programs, and then generate -Java Byte Code instructions for the Jasmin assmebler. As -solution you need to submit the assembler instructions for the -Fibonacci and Factorial programs. Both should be so modified -that a user can input on the console which Fibonacci number -and which Factorial should calculated. The Fibonacci program -is given in Figure~\ref{fibs}. You can write your own program -for calculating factorials. +You need to lex and parse WHILE programs, and then generate Java Byte +Code instructions for the Jasmin assembler. As solution you need to +submit the assembler instructions for the Fibonacci and Factorial +programs. Both should be so modified that a user can input on the +console which Fibonacci number and which Factorial should +calculated. The Fibonacci program is given in Figure~\ref{fibs}. You +can write your own program for calculating factorials. \begin{figure}[t] \lstinputlisting[language=while]{../progs/fib.while} @@ -287,11 +286,14 @@ \end{center} \noindent -where \texttt{n} is the index of the variable that requires an input. +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}[p]\small -\begin{lstlisting}[language=JVMIS,numbers=none] +\begin{figure}[t]\small +\begin{lstlisting}[language=JVMIS] .method public static read()I .limit locals 10 .limit stack 10 @@ -310,7 +312,6 @@ ldc 32 ; the space delimiter isub ifeq Label2 - iload 2 ldc 48 ; we have our digit in ASCII, have to subtract it from 48 isub