--- a/progs/while/compile.sc Wed Nov 18 12:18:33 2020 +0000
+++ b/progs/while/compile.sc Tue Nov 24 21:22:31 2020 +0000
@@ -47,40 +47,6 @@
return
.end method
-.method public static read()I
- .limit locals 10
- .limit stack 10
-
- ldc 0
- istore 1 ; this will hold our final integer
-Label1:
- getstatic java/lang/System/in Ljava/io/InputStream;
- invokevirtual java/io/InputStream/read()I
- istore 2
- iload 2
- ldc 10 ; the newline delimiter
- isub
- ifeq Label2
- iload 2
- 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
- ldc 10
- iload 1
- imul
- iadd
- istore 1
- goto Label1
-Label2:
- ;when we come here we have our integer computed in local variable 1
- iload 1
- ireturn
-.end method
-
.method public static main([Ljava/lang/String;)V
.limit locals 200
.limit stack 200
@@ -118,7 +84,7 @@
}
// this allows us to write things like
-// i"add" and l"Label"
+// i"iadd" and l"Label"
// environments
@@ -139,6 +105,7 @@
compile_aexp(a1, env) ++ compile_aexp(a2, env) ++ compile_op(op)
}
+
// boolean expression compilation
// - the jump-label is for where to jump if the condition is not true
def compile_bexp(b: BExp, env : Env, jmp: String) : String = b match {
@@ -256,3 +223,46 @@
@main
def test2() =
run(fib_test, "fib")
+
+
+
+
+
+
+/* Jasmin code for reading an integer
+
+.method public static read()I
+ .limit locals 10
+ .limit stack 10
+
+ ldc 0
+ istore 1 ; this will hold our final integer
+Label1:
+ getstatic java/lang/System/in Ljava/io/InputStream;
+ invokevirtual java/io/InputStream/read()I
+ istore 2
+ iload 2
+ ldc 10 ; the newline delimiter
+ isub
+ ifeq Label2
+ iload 2
+ 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
+ ldc 10
+ iload 1
+ imul
+ iadd
+ istore 1
+ goto Label1
+Label2:
+ ;when we come here we have our integer computed in local variable 1
+ iload 1
+ ireturn
+.end method
+
+*/
\ No newline at end of file
--- a/progs/while/test-small.j Wed Nov 18 12:18:33 2020 +0000
+++ b/progs/while/test-small.j Tue Nov 24 21:22:31 2020 +0000
@@ -14,7 +14,16 @@
.limit locals 200
.limit stack 200
- bipush 8
+ ; 1 + ((2 * 3) + (4 - 3))
+ ldc 1
+ ldc 2
+ ldc 3
+ imul
+ ldc 4
+ ldc 3
+ isub
+ iadd
+ iadd
invokestatic test/test/write(I)V
return
.end method
\ No newline at end of file
Binary file slides/slides06.pdf has changed
--- a/slides/slides06.tex Wed Nov 18 12:18:33 2020 +0000
+++ b/slides/slides06.tex Tue Nov 24 21:22:31 2020 +0000
@@ -14,6 +14,13 @@
%\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
\newcommand{\qq}{\mbox{\texttt{"}}}
+\usepackage{tcolorbox}
+\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
+\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
+\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
+
+
+
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -193,6 +200,23 @@
\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[t,fragile]
+\begin{mybox3}{}
+ In CW3, in the collatz program there is the line write "$\backslash$n" Should this print "/n" or perform the new line command /n ? Also should write be print() or println() ?
+\end{mybox3}
+\end{frame}
+
+\begin{frame}[t]
+ \begin{mybox3}{}
+ When will we have the mid-term that was originally scheduled for last week? We haven't heard anything about it for 2 weeks.
+\end{mybox3}
+\end{frame}
+
+\begin{frame}<1-12>[c]
+\end{frame}
+
+
\end{document}
@@ -968,6 +992,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+
+
+
\end{document}
@@ -1271,6 +1298,8 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+