<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. Status. </b>The Inter specification allows for any number of primitive invocations to
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. Arithmetic. </b>The following are standard integer arithmetic operations:
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !plus val val -> val</span></span>. 16 or 32-bit integer addition.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !minus val val -> val</span></span>. 16 or 32-bit integer subtraction.
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !unaryminus val -> val</span></span>. Equivalent to performing <spanclass="extract"><spanclass="extract-syntax">0 - x</span></span>.
</li><li>(d) <spanclass="extract"><spanclass="extract-syntax">primitive !times val val -> val</span></span>. 16 or 32-bit integer multiplication.
</li><li>(e) <spanclass="extract"><spanclass="extract-syntax">primitive !divide val val -> val</span></span>. 16 or 32-bit integer division.
</li><li>(f) <spanclass="extract"><spanclass="extract-syntax">primitive !modulo val val -> val</span></span>. Remainder after such a division.
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. Logical operators. </b>In general, the value 0 is false, and all other values are true.
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !not val -> val</span></span>. True if the value is false, and vice versa.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !and val val -> val</span></span>. True if both are true: doesn't evaluate the second if the first is false.
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !or val val -> val</span></span>. True if either is true: doesn't evaluate the second if the first is true.
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. Bitwise operators. </b>These differ in that they do not "short circuit", and do not squash values
<pclass="commentary firstcommentary"><aid="SP5"class="paragraph-anchor"></a><b>§5. Numerical comparison. </b>These are comparisons of signed integers. (If Inform needs to compare unsigned
<pclass="commentary firstcommentary"><aid="SP6"class="paragraph-anchor"></a><b>§6. Sequential evaluation. </b>The reason for the existence of <spanclass="extract"><spanclass="extract-syntax">!ternarysequential</span></span> is that it's a convenient
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !sequential val val -> val</span></span>. Evaluates the first, then the second
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !random val -> val</span></span>. Produce a uniformly random integer in the range 0 up to <spanclass="extract"><spanclass="extract-syntax">val</span></span> minus 1.
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !printchar val -> void</span></span>. Print a character value.
</li><li>(d) <spanclass="extract"><spanclass="extract-syntax">primitive !printnl void -> void</span></span>. Print a newline. (This is needed because
some of our VMs use character 10 for newline, and crash on 13, and others vice versa.)
</li><li>(e) <spanclass="extract"><spanclass="extract-syntax">primitive !printdword val -> void</span></span>. Print a dictionary word.
</li><li>(f) <spanclass="extract"><spanclass="extract-syntax">primitive !printstring val -> void</span></span>. Print a packed string.
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !font val -> void</span></span>. Change to fixed-width font if value is 1, or regular if 0.
<pclass="commentary firstcommentary"><aid="SP9"class="paragraph-anchor"></a><b>§9. Stack access. </b>The stack is not directly accessible anywhere in memory, so the only access
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !push val -> void</span></span>. Push value onto the stack.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !pull ref -> void</span></span>. Pull value from the stack and write it into
<pclass="commentary firstcommentary"><aid="SP10"class="paragraph-anchor"></a><b>§10. Accessing storage. </b>Here the <spanclass="extract"><spanclass="extract-syntax">ref</span></span> term is a refernce to a piece of storage: a property of an
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !store ref val -> val</span></span>. Put the value in <spanclass="extract"><spanclass="extract-syntax">ref</span></span>.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !setbit ref val -> void</span></span>. Set bits in the mask <spanclass="extract"><spanclass="extract-syntax">val</span></span> in <spanclass="extract"><spanclass="extract-syntax">ref</span></span>.
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !clearbit ref val -> void</span></span>. Clear bits in the mask <spanclass="extract"><spanclass="extract-syntax">val</span></span> in <spanclass="extract"><spanclass="extract-syntax">ref</span></span>.
</li><li>(d) <spanclass="extract"><spanclass="extract-syntax">primitive !postincrement ref -> val</span></span>. Performs the equivalent of <spanclass="extract"><spanclass="extract-syntax">ref++</span></span>.
</li><li>(e) <spanclass="extract"><spanclass="extract-syntax">primitive !preincrement ref -> val</span></span>. Performs the equivalent of <spanclass="extract"><spanclass="extract-syntax">++ref</span></span>.
</li><li>(f) <spanclass="extract"><spanclass="extract-syntax">primitive !postdecrement ref -> val</span></span>. Performs the equivalent of <spanclass="extract"><spanclass="extract-syntax">ref--</span></span>.
</li><li>(g) <spanclass="extract"><spanclass="extract-syntax">primitive !predecrement ref -> val</span></span>. Performs the equivalent of <spanclass="extract"><spanclass="extract-syntax">--ref</span></span>.
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !lookup val val -> val</span></span>. Find word at this word offset.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !lookupbyte val val -> val</span></span>. Find byte at this byte offset.
<pclass="commentary firstcommentary"><aid="SP11"class="paragraph-anchor"></a><b>§11. Indirect function calls. </b>Invocations of functions can only be made with <spanclass="extract"><spanclass="extract-syntax">inv</span></span> when the function is
<pclass="commentary firstcommentary"><aid="SP12"class="paragraph-anchor"></a><b>§12. Control flow. </b>The simplest control statement is an "if". Note that a different primitive
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !while val code -> void</span></span>. Similar to <spanclass="extract"><spanclass="extract-syntax">while</span></span> in C.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !for val val val code -> void</span></span>. Similar to <spanclass="extract"><spanclass="extract-syntax">for</span></span> in C.
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !objectloopx ref val code -> void</span></span>. A loop over instances,
stored in the variable <spanclass="extract"><spanclass="extract-syntax">ref</span></span>, of the kind of object <spanclass="extract"><spanclass="extract-syntax">val</span></span>.
</li><li>(d) <spanclass="extract"><spanclass="extract-syntax">primitive !objectloop ref val val code -> void</span></span>. A more general form,
where the secomd <spanclass="extract"><spanclass="extract-syntax">val</span></span> is a condition to be evaluated which decides whether
to execute the code for given <spanclass="extract"><spanclass="extract-syntax">ref</span></span> value.
Instead: a <spanclass="extract"><spanclass="extract-syntax">switch</span></span> takes a single <spanclass="extract"><spanclass="extract-syntax">code</span></span>, but that <spanclass="extract"><spanclass="extract-syntax">code</span></span> can in turn
contain only invocations of <spanclass="extract"><spanclass="extract-syntax">!case</span></span>, followed optionally by one of <spanclass="extract"><spanclass="extract-syntax">!default</span></span>.
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !break void -> void</span></span>. Exit the innermost switch case or loop.
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !continue void -> void</span></span>. Complete the current iteration of
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !return val -> void</span></span>. Finish the current function, giving the
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !jump lab -> void</span></span>. Jumo to this label in the current function.
<pclass="commentary firstcommentary"><aid="SP13"class="paragraph-anchor"></a><b>§13. Interactive fiction-only primitives. </b>The following would make no sense in a general-purpose program. Most mirror
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !move val val -> void</span></span>. Moves first to second (both are objects).
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !in val val -> val</span></span>. Tests if first is in second (both are objects).
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !notin val val -> val</span></span>. Negation of same.
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !ofclass val val -> val</span></span>. Does the first belong to the enumerated
<ulclass="items"><li>(a) <spanclass="extract"><spanclass="extract-syntax">primitive !give val val -> void</span></span>. Set the second (an attribute) for the first (an object).
</li><li>(b) <spanclass="extract"><spanclass="extract-syntax">primitive !take val val -> void</span></span>. Unset the second (an attribute) for the first (an object).
</li><li>(c) <spanclass="extract"><spanclass="extract-syntax">primitive !has val val -> val</span></span>. Test if the first (an object) has the second (an attibute).
</li><li>(d) <spanclass="extract"><spanclass="extract-syntax">primitive !hasnt val val -> val</span></span>. Negation of same.