594e63014cb11f3bb637cd8d8b8382608dd3e85e
[phd-thesis.git] / appx / bytecode.tex
1 \documentclass[../thesis.tex]{subfiles}
2
3 \input{subfilepreamble}
4
5 \begin{document}
6 \input{subfileprefix}
7 \chapter{Bytecode instruction set}%
8 \label{chp:bytecode_instruction_set}%
9 \todo[inline]{formatting}
10
11 \begin{tabular}{ll}
12 $l$ & label\\
13 $w_r$ & return width\\
14 $w_a$ & argument width\\
15 $fp$ & frame pointer\\
16 $sp$ & stack pointer\\
17 $pc$ & program counter\\
18 \end{tabular}
19
20 Bytecode is byte encoded, stack has 16-bit cells.
21 Longs and reals are stored with the MSB first.
22
23 \footnotesize
24 %\begin{longtable}{lllll}
25 % \caption{\normalsize Semantics for the bytecode instructions\label{tbl:instr_task}}
26 % \endfirsthead%
27 % \caption{\normalsize Semantics for the bytecode instructions (cont.)}
28 % \endhead%
29 % \endfoot%
30 % \endlastfoot%
31 % \toprule
32 % Instr. & Args & Semantics & sp & pc\\
33 %
34 % \midrule
35 % \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]$\\
36 % & & {\bf for all} $i\in\{0..w_r\}$\\
37 % & & $fp = st[fp\shortminus{}w_a\shortminus{}2]$\\
38 % \texttt{jumpF} & $l$ & & $sp\shortminus{}1$ & $\left\{\begin{array}{ll} pc+1 & \textrm{\bf if } st[sp\shortminus{}1]\\l & \textrm{\bf otherwise}\end{array}\right.$\\
39 % \texttt{jump} & $l$ & & $sp\shortminus{}1$ & $l$\\
40 % \texttt{jumpSR} & $w_a~l$ & $st[sp\shortminus{}w_a\shortminus{}1]=pc+2$ & & $l$\\
41 % \texttt{tailCall} & $w_{a_1}~w_{a_2}~l$ & $rotate\:(w_{a_1}+3+w_{a_2},w_{a_2})$ & $fp$ & $jl$\\
42 % & & $fp = fp-w_{a_1}+w_{a_2}$\\
43 % & & \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}\\
44 % \texttt{arg} & $i$ & $st[sp] = st[fp-1-i]$ & $sp+1$\\
45 % \texttt{push} & $n~b_0\ldots b_n$ & $st[sp+i] = s[i]$ & $sp+n$ & $pc+2+n$\\
46 % & & {\bf for all} $i\in\{0..n\}$\\
47 %% \midrule
48 % \texttt{pop} & $n$ & & $sp-n$ & $pc+2$\\
49 %% \midrule
50 % \texttt{rot} & $d~n$ & $rotate\:(d, n)$ & $sp$ & $pc+3$\\
51 %% \midrule
52 % \texttt{dup} & & $st[sp] = st[sp-1]$ & $sp+1$ & $pc+1$\\
53 %% \midrule
54 % \texttt{pushPtrs} & & $st[sp] = sp$ & $sp+3$ & $pc+1$\\
55 % & & $st[sp+1] = fp$\\
56 % & & $st[sp+2] = 0$\\
57 %% \midrule
58 % \texttt{unOp} & & $st[sp-1] = \diamond{}st[sp-1]$ & $sp$ & $pc+1$\\
59 % & & \multicolumn{3}{l}{{\bf for all} $\diamond\in\{\neg\}$}\\
60 %% \midrule
61 % \texttt{binOp} & & $st[sp-2] = st[sp-2] \mathbin{\oplus} st[sp-1]$ & $sp-1$ & $pc+1$\\
62 % & & \multicolumn{3}{l}{{\bf for all} $\oplus\in\{+, -, *, /, \wedge, \vee, \equiv, \not\equiv, \leq, \geq, <, >\}$}\\
63 %% \midrule
64 % \texttt{mkTask} & \texttt{Stable\textsubscript{n}} & $st[sp-n-1] = node (stable,$ & $sp-n+1$ & $pc+2$\\
65 % & & $\qquad\qquad st[sp-1], \ldots, st[sp-n-1])$\\
66 % \texttt{mkTask} & \texttt{Unstable\textsubscript{n}} & $st[sp-n-1] = node (unstable,$ & $sp-n+1$ & $pc+2$\\
67 % & & $\qquad\qquad st[sp-1], \ldots, st[sp-n-1])$\\
68 %% \midrule
69 %% & \multicolumn{3}{l}{Unstable\textsubscript{n}} & st[sp-n-1] = node (unstable, & sp-n+1 & pc+2\\
70 %% & \multicolumn{3}{l}{} & \qquad\qquad st[sp-1], \textrm{\ldots}, st[sp-n-1])\\
71 %% \midrule
72 %%
73 %% & \multicolumn{3}{l}{ReadD } & st[sp-1] \ \ = node (readd, st[sp-1]) & & pc+2\\
74 %% \midrule
75 %% & \multicolumn{3}{l}{ReadA } & st[sp-1] \ \ = node (reada, st[sp-1]) & & pc+2\\
76 %% \midrule
77 %% & \multicolumn{3}{l}{Repeat } & st[sp-1] \ \ = node (repeat, st[sp-1]) & & pc+2\\
78 %% \midrule
79 %% & \multicolumn{3}{l}{Delay } & st[sp-1] \ \ = node (delay, st[sp-1]) & & pc+2\\
80 %% \midrule
81 %%
82 %% & \multicolumn{3}{l}{WriteD } & st[sp-2] \ \ = node (writed, st[sp-1], st[sp-2]) & sp-1 & pc+2\\
83 %% \midrule
84 %% & \multicolumn{3}{l}{WriteA } & st[sp-2] \ \ = node (writea, st[sp-1], st[sp-2]) & sp-1 & pc+2\\
85 %% \midrule
86 %% & \multicolumn{3}{l}{And } & st[sp-2] \ \ = node (and, st[sp-1], st[sp-2]) & sp-1 & pc+2\\
87 %% \midrule
88 %% & \multicolumn{3}{l}{Or } & st[sp-2] \ \ = node (or, st[sp-1], st[sp-2]) & sp-1 & pc+2\\
89 %% \midrule
90 %%
91 %% & \multicolumn{3}{l}{SdsSet i } & st[sp-1] \ \ = node (sdsset,i, st[sp-1]) & & pc+3\\
92 %% \midrule
93 %%
94 %% & \multicolumn{3}{l}{SdsGet i } & st[sp]\ \ \ \ \ = node (sdsget, i) & sp+1 & pc+3\\
95 %% \midrule
96 %% & \multicolumn{3}{l}{DHTTemp i } & st[sp-1] \ \ = node (dhttemp, i) & sp+1 & pc+3\\
97 %% \midrule
98 %% & \multicolumn{3}{l}{DHTHumid i } & st[sp-1] \ \ = node (dhthumid, i) & sp+1 & pc+3\\
99 %% \midrule
100 %%
101 %% & \multicolumn{3}{l}{Step aw jl } & st[sp-1] \ \ = node (step, aw, jl, st[sp-1]) & sp-1 & pc+5\\
102 % \bottomrule
103 %\end{longtable}
104
105 \input{subfilepostamble}
106 \end{document}