66c24660dd46af92c731b21d7fa5533baf00b9bc
[msc-thesis1617.git] / mtaskext.examples.tex
1 The thermostat example given previously in Listing~\ref{lst:exmtask} would be
2 compiled to the following code. The left column indicates the
3 position in the program memory.
4
5 \begin{lstlisting}[caption={Thermostat bytecode},language=c]
6 1-2 : BCAnalogRead (Analog A0)
7 3-6 : BCPush (Int 50)
8 7 : BCGre
9 8-9 : BCJmpF 17 //Jump to else
10 10-12: BCPush (Bool 1)
11 13-14: BCDigitalWrite (Digital D0)
12 15-16: BCJmp 21 //Jump to end of if
13 17-19: BCPush (Bool 0) //Else label
14 20 : BCDigitalWrite (Digital D0)
15 \end{lstlisting}