1 \documentclass[../thesis.tex
]{subfiles
}
3 \input{subfilepreamble
}
5 \setcounter{chapter
}{2}
9 \ifSubfilesClassLoaded{\appendix}{}
10 \chapter{Bytecode instruction set
}%
11 \label{chp:bytecode_instruction_set
}%
12 This appendix describeds the semantics of the byte code instruction set.
13 The byte code instructions are of variable length and automatically encoded and decoded using generic programming (see
\todo{ref naar c\-co\-de\-gen
}).
14 \Cref{tbl:bc_notation
} shows the notation convention.
17 \caption{Notation for the byte code semantics
}%
18 \label{tbl:bc_notation
}
22 variable & meaning &
\textnumero{}bytes\\
25 $w_r$ & return width &
1\\
26 $w_a$ & argument width &
1\\
27 $i$ &
\gls{SDS
} or sensor id &
1\\
28 $fp$ & frame pointer &
2\\
29 $sp$ & stack pointer &
2\\
30 $pc$ & program counter &
2\\
36 \begin{longtable
}[c
]{lllll
}
37 \caption{Semantics for the bytecode instructions
\label{tbl:instr_task
}}\\
39 Instruction & Arguments & Semantics & $sp$ & $pc$\\
42 \caption{Semantics for the bytecode instructions (cont.)
}\\
44 Instruction & Arguments & Semantics & $sp$ & $pc$\\
51 \texttt{push
} & $n~b_0
\ldots b_n$ & $st
[sp+i
] = s
[i
]$ & $sp+n$ & $pc+
2+n$\\
52 & &
{\bf for all
} $i
\in\
{0..n\
}$\\
53 \texttt{pop
} & $n$ & & $sp
\shortminus{}n$ & $pc+
2$\\
54 \texttt{rot
} & $d~n$ & $rotate\:(d, n)$ & $sp$ & $pc+
3$\\
55 \texttt{dup
} & & $st
[sp
] = st
[sp
\shortminus{}1]$ & $sp+
1$ & $pc+
1$\\
57 \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.$\\
58 \texttt{jump
} & $l$ & & $sp
\shortminus{}1$ & $l$\\
59 \texttt{jumpSR
} & $w_a~l$ & $st
[sp
\shortminus{}w_a
\shortminus{}1]=pc+
2$ & & $l$\\
60 \texttt{tailCall
} & $w_
{a_1
}~w_
{a_2
}~l$ & $rotate\:(w_
{a_1
}+
3+w_
{a_2
},w_
{a_2
})$ & $fp$ & $jl$\\
61 & & $fp = fp
\shortminus{}w_
{a_1
}+w_
{a_2
}$\\
62 & &
\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
}\\
63 \texttt{arg
} & $i$ & $st
[sp
] = st
[fp
\shortminus{}1\shortminus{}i
]$ & $sp+
1$\\
64 \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]$\\
65 & &
{\bf for all
} $i
\in\
{0..w_r\
}$\\
66 & & $fp = st
[fp
\shortminus{}w_a
\shortminus{}2]$\\
67 \texttt{pushPtrs
} & & $st
[sp
] = sp$ & $sp+
3$ & $pc+
1$\\
71 \texttt{unOp
} & & $st
[sp
\shortminus{}1] =
\diamond{}st
[sp
\shortminus{}1]$ & $sp$ & $pc+
1$\\
72 & &
\multicolumn{3}{l
}{{\bf for all
} $
\diamond\in\
{\neg\
}$
}\\
73 \texttt{binOp
} & & $st
[sp
\shortminus{}2] = st
[sp
\shortminus{}2] \mathbin{\oplus} st
[sp
\shortminus{}1]$ & $sp
\shortminus{}1$ & $pc+
1$\\
74 & &
\multicolumn{3}{l
}{{\bf for all
} $
\oplus\in\
{+,
\shortminus{}, *, /,
\wedge,
\vee,
\equiv,
\not\equiv,
\leq,
\geq, <, >\
}$
}\\
75 & &
\multicolumn{3}{l
}{similar for Real and Long variants
}\\
76 \texttt{cast
}\textsubscript{f-t
} & & $st
[sp
\shortminus{}1] = cast_
{f-t
} (st
[sp
\shortminus{}1])$ & $sp$ & $pc+
1$\\
77 & &
\multicolumn{3}{l
}{{\bf for all
} $f,t
\in\
{Int, Real, Long\
}$
}\\
79 \texttt{mkTask
} &
\texttt{Stable
\textsubscript{n
}} & $st
[sp
\shortminus{}n
\shortminus{}1] = node (stable,$ & $sp
\shortminus{}n+
1$ & $pc+
2$\\
80 & & $
\qquad\qquad st
[sp
\shortminus{}1],
\ldots, st
[sp
\shortminus{}n
\shortminus{}1])$\\
81 &
\texttt{Unstable
\textsubscript{n
}} & $st
[sp
\shortminus{}n
\shortminus{}1] = node (unstable,$ & $sp
\shortminus{}n+
1$ & $pc+
2$\\
82 & & $
\qquad\qquad st
[sp
\shortminus{}1],
\ldots, st
[sp
\shortminus{}n
\shortminus{}1])$\\
84 &
\texttt{ReadD
} & $st
[sp
\shortminus{}1] = node (readd, st
[sp
\shortminus{}1])$ & $sp$ & $pc+
2$\\
85 &
\texttt{ReadA
} & $st
[sp
\shortminus{}1] = node (reada, st
[sp
\shortminus{}1])$ & $sp$ & $pc+
2$\\
86 &
\texttt{WriteD
} & $st
[sp
\shortminus{}2] = node (writed, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
87 &
\texttt{WriteA
} & $st
[sp
\shortminus{}2] = node (writea, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
88 &
\texttt{WriteD
} & $st
[sp
\shortminus{}2] = node (writed, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
89 &
\texttt{PinMode
} & $st
[sp
\shortminus{}2] = node (pinmode, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
91 &
\texttt{Repeat
} & $st
[sp
] = node (repeat, st
[sp
\shortminus{}1])$ & $sp$ & $pc+
2$\\
92 &
\texttt{Delay
} & $st
[sp
] = node (delay, st
[sp
\shortminus{}1])$ & $sp$ & $pc+
2$\\
93 &
\texttt{And
} & $st
[sp
\shortminus{}1] = node (and, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
94 &
\texttt{Or
} & $st
[sp
\shortminus{}1] = node (and, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
95 &
\texttt{Step
} $f$ $w_a$ & $st
[sp
] = node (step, st
[sp
\shortminus{}1], f, w)$ & $sp$ & $pc+
5$\\
97 &
\texttt{SdsGet
} $i$ & $st
[sp+
1] = node (sdsget, i)$ & $sp+
1$ & $pc+
3$\\
98 &
\texttt{SdsSet
} $i$ & $st
[sp
\shortminus{}1] = node (sdsset, st
[sp
\shortminus{}1], i)$ & $sp$ & $pc+
3$\\
99 &
\texttt{SdsUpd
} $i$ $l$ & $st
[sp+
1] = node (sdsset, i, l)$ & $sp+
1$ & $pc+
5$\\
101 &
\texttt{Interrupt
} & $st
[sp
\shortminus{}2] = node (interrupt, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
102 &
\texttt{RateLimit
} & $st
[sp
\shortminus{}1] = node (ratelimit, st
[sp
\shortminus{}1])$ & $sp$ & $pc+
2$\\
103 &
\texttt{TuneRate
} & $st
[sp
\shortminus{}1] = node (tunerate, st
[sp
\shortminus{}1], st
[sp
\shortminus{}2])$ & $sp
\shortminus{}1$ & $pc+
2$\\
105 &
\texttt{DHTTemp
} $i$ & $st
[sp+
1] = node (dhttemp, i)$ & $sp+
1$ & $pc+
3$\\
106 &
\texttt{DHTHumid
} $i$ & $st
[sp+
1] = node (dhthumid, i)$ & $sp+
1$ & $pc+
3$\\
110 \input{subfilepostamble
}
111 \end{document}%chktex 16