diff -r f25d338d16c9 -r 0cb4bf2469d1 cws/cw04.tex --- a/cws/cw04.tex Sat Nov 09 06:31:45 2024 +0000 +++ b/cws/cw04.tex Fri Nov 22 12:42:07 2024 +0000 @@ -17,8 +17,7 @@ at 16:00. You are asked to implement a compiler for the WHILE language that targets the assembler language provided by Jasmin or Krakatau (both have a very similar -syntax). Please submit your answers to the questions -below as PDF. You can do the implementation in any programming +syntax). You can do the implementation in any programming language you like, but you need to submit the source code with which you answered the questions, otherwise a mark of 0\% will be awarded. You should use the lexer and parser from the @@ -100,7 +99,7 @@ \noindent If possible use Jasmin for the coursework. The Krakatau assembler -below as a slightly different syntax. +below has a slightly different syntax. \subsection*{Krakatau Assembler (Version 1 \& 2)} @@ -165,12 +164,7 @@ Code instructions for the Jasmin assembler (or Krakatau assembler). For this you should use the ASTs defined in CW3 (including logical operators). As part of the 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 be calculated. The Fibonacci program -is given in Figure~\ref{fibs}. You can write your own program for -calculating factorials. Submit your assembler code as a file that can -be run, not as PDF-text. +instructions for the Fibonacci and Factorial programs. \begin{figure}[t] \lstinputlisting[language=while]{../cwtests/cw04/fib.while} @@ -228,10 +222,10 @@ \end{minipage} \end{center} -\subsection*{Question 3} +\subsection*{Question 3 (OPTIONAL)} -\noindent In this question you are supposed to give the -assembler instructions for the program +\noindent In this question you are asked to think about the following +program: \begin{center} \begin{minipage}{12cm} @@ -247,9 +241,8 @@ \noindent Note that in this program the variable \pcode{i} is used -twice. You need to make a decision how it should be compiled? -Explain your decision and indicate what this program would -print out. Give your answer in the file \texttt{q3-answer.txt}. +twice. Therefore you need to make a decision about how it should be compiled? +What should the program print? \subsection*{Question 4}