# HG changeset patch # User Christian Urban # Date 1354091306 0 # Node ID 719fd738d2a089058dbcab9c1a199227812ee464 # Parent bd61b03b9eaa85dde27b4d3185eea15995b8efbe tuned diff -r bd61b03b9eaa -r 719fd738d2a0 fib.while --- a/fib.while Wed Nov 28 07:03:29 2012 +0000 +++ b/fib.while Wed Nov 28 08:28:26 2012 +0000 @@ -1,17 +1,15 @@ /* Fibonacci Program input: n - output: fib_res */ +*/ n := 19; minus1 := 0; minus2 := 1; -temp := 0; while n > 0 do { temp := minus2; minus2 := minus1 + minus2; minus1 := temp; n := n - 1 }; -fib_res := minus2; -write fib_res +write minus2 diff -r bd61b03b9eaa -r 719fd738d2a0 slides09.pdf Binary file slides09.pdf has changed diff -r bd61b03b9eaa -r 719fd738d2a0 slides09.tex --- a/slides09.tex Wed Nov 28 07:03:29 2012 +0000 +++ b/slides09.tex Wed Nov 28 08:28:26 2012 +0000 @@ -75,8 +75,8 @@ showstringspaces=false} \lstdefinelanguage{while}{ - morekeywords={if,then,else,while,do,true,false}, - otherkeywords={=,!=,:=,<,>}, + morekeywords={if,then,else,while,do,true,false,write}, + otherkeywords={=,!=,:=,<,>,;}, sensitive=true, morecomment=[n]{/*}{*/}, } @@ -317,8 +317,8 @@ \item is a stack-based VM (like Postscript, CLR of .Net) \item contains a JIT compiler \item many languages take advantage of JVM's infrastructure (JRE) -\item languages compiled to the JVM: Scala, Clojure\ldots \item is garbage collected $\Rightarrow$ no buffer overflows +\item some languages compiled to the JVM: Scala, Clojure\ldots \end{itemize} \end{frame}} @@ -436,12 +436,12 @@ {\Large\bl{$x := 5 + y * 2$}}\bigskip\pause \begin{itemize} -\item lookup: \bl{$\text{iload}\; number$} -\item store: \bl{$\text{istore}\; number$} +\item lookup: \bl{$\text{iload}\; index$} +\item store: \bl{$\text{istore}\; index$} \end{itemize}\bigskip\pause -during compilation we have to maintain a map between our identifiers and the -Java bytecode numbers +while compilating we have to maintain a map between our identifiers and the +Java bytecode indices \begin{center} \bl{$\text{compile}(a, E)$} @@ -480,7 +480,7 @@ \begin{center} \bl{\begin{tabular}{@{}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} -$\text{compile}(\text{skip}, E)$ & $\dn$ & $(Nil, E)$\bigskip\\ +$\text{compile}(\text{skip}, E)$ & $\dn$ & $(N\!il, E)$\bigskip\\ $\text{compile}(x := a, E)$ & $\dn$\\ \multicolumn{3}{l}{$(\text{compile}(a, E) \;@\;\text{istore}\;index, E(x\mapsto index))$}\\ \end{tabular}} @@ -507,7 +507,7 @@ \end{tabular}} \end{center} -where \bl{$n_x$} is the number corresponding to the variable \bl{$x$} +where \bl{$n_x$} is the index corresponding to the variable \bl{$x$} \end{frame}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -519,7 +519,7 @@ {\Large\bl{$\text{if}\;b\;\text{else}\;cs_1\;\text{then}\;cs_2$}}\bigskip\bigskip -\onslide<2->{Case }\only<2>{True:}\only<3>{False:} +\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:} \begin{center} \begin{tikzpicture}[node distance=2mm and 4mm, @@ -597,7 +597,7 @@ \begin{center} \bl{\begin{tabular}{lcl} $\text{compile}(a_1 = a_2, E, lab)$ & $\dn$\\ -\multicolumn{3}{l}{$\quad\text{compile}(a_1, E) \;@\;\text{compile}(a_2. E)\;@\; \text{if\_icmpne}\;lab$} +\multicolumn{3}{l}{$\quad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{if\_icmpne}\;lab$} \end{tabular}} \end{center} @@ -637,7 +637,7 @@ {\Large\bl{$\text{while}\;b\;\text{do}\;cs$}}\bigskip\bigskip -\onslide<2->{Case }\only<2>{True:}\only<3>{False:} +\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:} \begin{center} \begin{tikzpicture}[node distance=2mm and 4mm, @@ -686,7 +686,7 @@ \multicolumn{3}{l}{$\quad\phantom{(}@\;\text{compile}(b, E, l_{wend})$}\\ \multicolumn{3}{l}{$\quad\phantom{(}@\;is$}\\ \multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{wbegin}$}\\ -\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E'')$}\\ +\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E')$}\\ \end{tabular}} \end{center} @@ -702,7 +702,7 @@ \begin{center} \small\bl{\begin{tabular}{l} -.method public static write(I)V\\ +.method public static write(I)V\hspace{1cm}\textcolor{black}{(library function)}\\ \;\; .limit locals 5 \\ \;\; .limit stack 5 \\ \;\; iload 0 \\