X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=appx%2Fbytecode.tex;fp=appx%2Fbytecode.tex;h=12e1c825c90fe85e427af572b1c5c98bc90ed4bb;hb=2260acc961f4041fc214d093d0225d382396564e;hp=ce6c4dffbadc31f2a65651d9e81fe73e4519a53c;hpb=6e1620de7fd37b567a1b52b022ed43ab5dfa9015;p=phd-thesis.git diff --git a/appx/bytecode.tex b/appx/bytecode.tex index ce6c4df..12e1c82 100644 --- a/appx/bytecode.tex +++ b/appx/bytecode.tex @@ -2,32 +2,35 @@ \input{subfilepreamble} -\setcounter{chapter}{2} \begin{document} \input{subfileprefix} -\ifSubfilesClassLoaded{\appendix}{} +\ifSubfilesClassLoaded{\appendix\setcounter{chapter}{2}}{} \chapter{Bytecode instruction set}% \label{chp:bytecode_instruction_set}% -This appendix describeds the semantics of the byte code instruction set. -The byte code instructions are of variable length and automatically encoded and decoded using generic programming (see \todo{ref naar c\-co\-de\-gen}). +This appendix describeds the semantics of the byte code instruction set of \gls{MTASK} (see \cref{chp:implementation}). +The byte code instructions are of variable length and automatically encoded and decoded using generic programming (see \cref{sec:ccodegen}). \Cref{tbl:bc_notation} shows the notation convention. +\Cref{tbl:instr_task} shows the semantics of all major byte code instructions, shorthand instructions and auxiliary peripherals have been omitted for brevity but have the analogous semantics as their counterparts. -\begin{table}[ht!] - \caption{Notation for the byte code semantics}% +\begin{table} + \caption{Notation convention for the byte code semantics.}% \label{tbl:bc_notation} \centering \begin{tabular}{lll} \toprule variable & meaning & \textnumero{}bytes\\ \midrule + $fp$ & frame pointer & 2\\ + $sp$ & stack pointer & 2\\ + $pc$ & program counter & 2\\ $l$ & label & 2\\ + \midrule $w_r$ & return width & 1\\ $w_a$ & argument width & 1\\ $i$ & \gls{SDS} or sensor id & 1\\ - $fp$ & frame pointer & 2\\ - $sp$ & stack pointer & 2\\ - $pc$ & program counter & 2\\ + $n$ & number & 1\\ + $d$ & depth & 1\\ \bottomrule \end{tabular} \end{table} @@ -48,8 +51,7 @@ The byte code instructions are of variable length and automatically encoded and \endfoot% \bottomrule \endlastfoot% - \texttt{push} & $n~b_0\ldots b_n$ & $st[sp+i] = s[i]$ & $sp+n$ & $pc+2+n$\\ - & & {\bf for all} $i\in\{0..n\}$\\ + \texttt{push} & $n~b_0\ldots b_n$ & $st[sp+i] = s[i]$ {\bf for all} $i\in\{0..n\}$ & $sp+n$ & $pc+2+n$\\ \texttt{pop} & $n$ & & $sp\shortminus{}n$ & $pc+2$\\ \texttt{rot} & $d~n$ & $rotate\:(d, n)$ & $sp$ & $pc+3$\\ \texttt{dup} & & $st[sp] = st[sp\shortminus{}1]$ & $sp+1$ & $pc+1$\\ @@ -60,7 +62,7 @@ The byte code instructions are of variable length and automatically encoded and \texttt{tailCall} & $w_{a_1}~w_{a_2}~l$ & $rotate\:(w_{a_1}+3+w_{a_2},w_{a_2})$ & $fp$ & $jl$\\ & & $fp = fp\shortminus{}w_{a_1}+w_{a_2}$\\ & & \multicolumn{3}{p{.75\textwidth}}{{\bf where} $w_{a_1}$ is the width of the current function and $w_{a_2}$ the width of the called function}\\ - \texttt{arg} & $i$ & $st[sp] = st[fp\shortminus{}1\shortminus{}i]$ & $sp+1$\\ + \texttt{arg} & $n$ & $st[sp] = st[fp\shortminus{}1\shortminus{}n]$ & $sp+1$\\ \texttt{return} & $w_r~w_a$ & $st[fp\shortminus{}w_a\shortminus{}3+i] = st[fp+1]$ & $st[fp\shortminus{}w_a\shortminus{}3+w_r]$ & $st[fp\shortminus{}w_a\shortminus{}1]$\\ & & {\bf for all} $i\in\{0..w_r\}$\\ & & $fp = st[fp\shortminus{}w_a\shortminus{}2]$\\ @@ -68,42 +70,41 @@ The byte code instructions are of variable length and automatically encoded and & & $st[sp+1] = fp$\\ & & $st[sp+2] = 0$\\ \midrule - \texttt{unOp} & & $st[sp\shortminus{}1] = \diamond{}st[sp\shortminus{}1]$ & $sp$ & $pc+1$\\ - & & \multicolumn{3}{l}{{\bf for all} $\diamond\in\{\neg\}$}\\ + \texttt{unOp} & & $st[sp\shortminus{}1] = \diamond{}st[sp\shortminus{}1]$ {\bf for all} $\diamond\in\{\neg\}$ & $sp$ & $pc+1$\\ \texttt{binOp} & & $st[sp\shortminus{}2] = st[sp\shortminus{}2] \mathbin{\oplus} st[sp\shortminus{}1]$ & $sp\shortminus{}1$ & $pc+1$\\ & & \multicolumn{3}{l}{{\bf for all} $\oplus\in\{+, \shortminus{}, *, /, \wedge, \vee, \equiv, \not\equiv, \leq, \geq, <, >\}$}\\ - & & \multicolumn{3}{l}{similar for Real and Long variants}\\ - \texttt{cast}\textsubscript{f-t} & & $st[sp\shortminus{}1] = cast_{f-t} (st[sp\shortminus{}1])$ & $sp$ & $pc+1$\\ + & & \multicolumn{3}{l}{similar for \cleaninline{Real} and \cleaninline{Long} variants}\\ + \texttt{cast}\textsubscript{f-t} & & $st[sp\shortminus{}1] = cast_{f\shortminus{}-t} (st[sp\shortminus{}1])$ & $sp$ & $pc+1$\\ & & \multicolumn{3}{l}{{\bf for all} $f,t\in\{Int, Real, Long\}$}\\ % \pagebreak \texttt{mkTask} & \texttt{Stable\textsubscript{n}} & $st[sp\shortminus{}n\shortminus{}1] = node (stable,$ & $sp\shortminus{}n+1$ & $pc+2$\\ & & $\qquad\qquad st[sp\shortminus{}1], \ldots, st[sp\shortminus{}n\shortminus{}1])$\\ - & \texttt{Unstable\textsubscript{n}} & $st[sp\shortminus{}n\shortminus{}1] = node (unstable,$ & $sp\shortminus{}n+1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{Unstable\textsubscript{n}} & $st[sp\shortminus{}n\shortminus{}1] = node (unstable,$ & $sp\shortminus{}n+1$ & $pc+2$\\ & & $\qquad\qquad st[sp\shortminus{}1], \ldots, st[sp\shortminus{}n\shortminus{}1])$\\ \midrule - & \texttt{ReadD} & $st[sp\shortminus{}1] = node (readd, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ - & \texttt{ReadA} & $st[sp\shortminus{}1] = node (reada, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ - & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{WriteA} & $st[sp\shortminus{}2] = node (writea, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{PinMode} & $st[sp\shortminus{}2] = node (pinmode, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{ReadD} & $st[sp\shortminus{}1] = node (readd, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + \texttt{mkTask} & \texttt{ReadA} & $st[sp\shortminus{}1] = node (reada, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + \texttt{mkTask} & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{WriteA} & $st[sp\shortminus{}2] = node (writea, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{WriteD} & $st[sp\shortminus{}2] = node (writed, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{PinMode} & $st[sp\shortminus{}2] = node (pinmode, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ \midrule - & \texttt{Repeat} & $st[sp] = node (repeat, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ - & \texttt{Delay} & $st[sp] = node (delay, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ - & \texttt{And} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{Or} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{Step} $f$ $w_a$ & $st[sp] = node (step, st[sp\shortminus{}1], f, w)$ & $sp$ & $pc+5$\\ + \texttt{mkTask} & \texttt{Repeat} & $st[sp] = node (repeat, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + \texttt{mkTask} & \texttt{Delay} & $st[sp] = node (delay, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + \texttt{mkTask} & \texttt{And} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{Or} & $st[sp\shortminus{}1] = node (and, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{Step} $f$ $w_a$ & $st[sp] = node (step, st[sp\shortminus{}1], f, w)$ & $sp$ & $pc+5$\\ \midrule - & \texttt{SdsGet} $i$ & $st[sp+1] = node (sdsget, i)$ & $sp+1$ & $pc+3$\\ - & \texttt{SdsSet} $i$ & $st[sp\shortminus{}1] = node (sdsset, st[sp\shortminus{}1], i)$ & $sp$ & $pc+3$\\ - & \texttt{SdsUpd} $i$ $l$ & $st[sp+1] = node (sdsset, i, l)$ & $sp+1$ & $pc+5$\\ + \texttt{mkTask} & \texttt{SdsGet} $i$ & $st[sp+1] = node (sdsget, i)$ & $sp+1$ & $pc+3$\\ + \texttt{mkTask} & \texttt{SdsSet} $i$ & $st[sp\shortminus{}1] = node (sdsset, st[sp\shortminus{}1], i)$ & $sp$ & $pc+3$\\ + \texttt{mkTask} & \texttt{SdsUpd} $i$ $l$ & $st[sp+1] = node (sdsset, i, l)$ & $sp+1$ & $pc+5$\\ \midrule - & \texttt{Interrupt} & $st[sp\shortminus{}2] = node (interrupt, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ - & \texttt{RateLimit} & $st[sp\shortminus{}1] = node (ratelimit, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ - & \texttt{TuneRate} & $st[sp\shortminus{}1] = node (tunerate, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{Interrupt} & $st[sp\shortminus{}2] = node (interrupt, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ + \texttt{mkTask} & \texttt{RateLimit} & $st[sp\shortminus{}1] = node (ratelimit, st[sp\shortminus{}1])$ & $sp$ & $pc+2$\\ + \texttt{mkTask} & \texttt{TuneRate} & $st[sp\shortminus{}1] = node (tunerate, st[sp\shortminus{}1], st[sp\shortminus{}2])$ & $sp\shortminus{}1$ & $pc+2$\\ \midrule - & \texttt{DHTTemp} $i$ & $st[sp+1] = node (dhttemp, i)$ & $sp+1$ & $pc+3$\\ - & \texttt{DHTHumid} $i$ & $st[sp+1] = node (dhthumid, i)$ & $sp+1$ & $pc+3$\\ + \texttt{mkTask} & \texttt{DHTTemp} $i$ & $st[sp+1] = node (dhttemp, i)$ & $sp+1$ & $pc+3$\\ + \texttt{mkTask} & \texttt{DHTHumid} $i$ & $st[sp+1] = node (dhthumid, i)$ & $sp+1$ & $pc+3$\\ \end{longtable} \end{landscape}