X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=results.mtask.tex;h=50cd1d6a6fe1ad4bb867a4aa5a588d7e964f52c9;hb=fcef9f5c5b6021ac424b19c44b4bda608eceaf40;hp=a939d4f4b2f4447295eed77854d34e35c8803d21;hpb=a182f0a12fdb361d341337ce8240cbcd6ca96ebc;p=msc-thesis1617.git diff --git a/results.mtask.tex b/results.mtask.tex index a939d4f..50cd1d6 100644 --- a/results.mtask.tex +++ b/results.mtask.tex @@ -224,10 +224,30 @@ BCIfStmt (BC b) (BC t) (BC e) = BC ( t >>| tell [BCJmp endif, BCLab else] >>| e >>| tell [BCLab endif] ) + instance noOp ByteCode where noOp = tell` [BCNop] \end{lstlisting} +The semantics for the \glspl{mTask} bytecode view are different than the +semantics for the \gls{C} view. \glspl{Task} in the \gls{C} view can start new +\gls{Task} or themselves to continue, while in the bytecode view, \gls{Task} +run idefinitly, one-shot or on interrupt. To allow interval and interrupt +\glspl{Task} to terminate, a return instruction is added. This class was not +available in the original system and is thus added. It just writes a single +instruction so that the interpreter knows to stop execution. +Listing~\ref{lst:return} shows the classes and implementation for the return +expression. + +\begin{lstlisting}[label={lst:return},% + caption={Bytecode view for the return instruction}] +class retrn v where + retrn :: v () Expr + +instance retrn ByteCode where + retrn = tell` [BCReturn] +\end{lstlisting} + \subsection{Shared Data Sources \& Assignment} Shared data sources must be acquired from the state and constructing one involves multiple steps. First, a fresh identifier is grabbed from the state. @@ -327,4 +347,3 @@ position in the program memory. 20 : BCDigitalWrite (Digital D0) \end{lstlisting} \todo{More elaborate example} -\todo{Add return instruction}