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