Your code generator will output "MIL" intermediate code, which can be directly executed by the mil_run MIL interpreter. The MIL interpreter assumes the following about a MIL program:
Please ensure that your generated MIL code meets the above three requirements.
As an example, for the primes.min MINI-L program, the corresponding
MIL code might look like this. Note that your generated
MIL code may look slightly different. However, your MIL code must behave the same way when
it is executed by the mil_run
MIL interpreter. As another example, the
MIL code for the mytest.min MINI-L program might appear as it
does here.
Each instruction in the MIL intermediate code representation is described in detail in the table below.
Syntax | Semantics |
. name | declares a name for a scalar variable |
.[] name, n | declares a name for an array variable consisting of n (must be a positive whole number) elements, with name[0] being the first element |
= dst, src | dst = src (src can be an immediate) |
=[] dst, src, index | dst = src[index] (index can be an immediate) |
[]= dst, index, src | dst[index] = src (index and src can be immediates) |
.< dst | read a value into dst from standard in |
.[]< dst, index | read a value into dst[index] from standard in |
.> src | write the value of src into standard out |
.[]> src, index | write the value of src[index] into standard out |
+ dst, src1, src2 | dst = src1 + src2 |
- dst, src1, src2 | dst = src1 - src2 |
* dst, src1, src2 | dst = src1 * src2 |
/ dst, src1, src2 | dst = src1 / src2 |
% dst, src1, src2 | dst = src1 % src2 |
< dst, src1, src2 | dst = src1 < src2 |
<= dst, src1, src2 | dst = src1 <= src2 |
!= dst, src1, src2 | dst = src1 != src2 |
== dst, src1, src2 | dst = src1 == src2 |
>= dst, src1, src2 | dst = src1 >= src2 |
> dst, src1, src2 | dst = src1 > src2 |
|| dst, src1, src2 | dst = src1 || src2 (logical OR) |
&& dst, src1, src2 | dst = src1 && src2 (logical AND) |
! dst, src | dst = !src (logical NOT) |
: label | declares a label |
:= label | goto label |
?:= label, predicate | if predicate is true (1) goto label |