+To get a feeling for what MontiumC looks like, consider the fragment in
+figure \ref{ExampleLow}. This is a piece of code that reads values from
+one memory, multiplies them by two, and writes them back to another
+memory. As you can see, this is an awful lot of code. This has two main
+reasons. First, looping and memory indexing is very explicit and takes a
+lot of instructions. Second, the code is effectively software pipelined
+to make it run more efficiently.
+
+In figure \ref{ExampleHigh} the same code is displayed, but this time
+using higer level C features (for loops, arra indexing). This is the
+level of code we are trying to achieve, but we're not there yet. It
+should be noted that this is still not "normal" C, since we use the
+"imul" function instead of the normal * operator. However, since the
+Montium defines a lot of different operations, most of which have a
+number of options (saturation, truncation, post shifting, etc.) these
+cannot all be mapped onto normal C operators. By using a specific
+function call for each, we can still distinguish between all the
+different operations and add extra arguments where needed.
+
+\subsubsection{What do we have now?}
+The result of this work is a usable, but conservative, specification. It
+defines the subset of features that should certainly be supported. In practice,
+some other features will also work, but not reliably. Therefore, these are left
+out of the specification.
+
+It is not unlikely that the specification is still incorrect in a few places (or
+rather, that the code does not implement the specification properly). Since
+so far there has been not any automated checking of programs against the
+specification, these errors have not been uncovered. Once the new hardware is
+more clearly defined and the MontiumC specification is updated for it, this
+checking should be added so the specification and compiler can be better
+matched.
+
+\begin{figure}
+ \caption{Low level MontiumC example}
+\label{ExampleLow}
+\begin{verbatim}
+mem input;
+mem output;
+word factor;
+
+void run(void) {
+ factor = from_int(2);
+ input = alloc_mem(P0M0);
+ output = alloc_mem(P0M1);
+ set_base(input, 0);
+ set_offset(input, 0);
+ set_base(output, -1);
+ set_offset(output, -1);
+
+ next_cycle();
+ word in = read_mem(input);
+ word out = p0o0(imul(ra1(in), rc1(factor)))
+ add_offset(input, 1);
+ add_offset(output, 1);
+ init_loop(LC1, 8);
+ do {
+ write_mem(output, out);
+ in = read_mem(input);
+ out = p0m0(imul(ra1(in), rc1(factor)))
+ add_offset(input, 1);
+ add_offset(output, 1);
+ } while(loop_next(LC1));
+
+ write_mem(output, out);
+\end{verbatim}
+\end{figure}
+
+\begin{figure}
+ \caption{High level MontiumC example}
+ \label{ExampleHigh}
+\begin{verbatim}
+P0M0 int input[10];
+P0M1 int output[10];
+
+void run(void) {
+ for (int i=0; i<10; ++i)
+ output[i] = mul(input[i], 2);
+}
+\end{verbatim}
+\end{figure}
+