The Instruction operation "arithmetic" can be used to work on more complex arithmetic expressions than a single add or subtract, using common mathematical expression handling (also known as 'infix' notation.) Either floating point decimal numbers, or hexadecimal numbers may be used (prefix hexadecimal with 0x).
The example below shows how the 'name' attribute is used for variable substitution.
<instruction operation="arithmetic">
<input value="(x+y)*3-2" />
<input name="x" value="4" />
<input name="y" value="3" />
</instruction>
19
Here is a list of operators that the arithemetic expression handler understands:
Here is a list of functions that the arithemetic expression handler understands, that take 2 parameters:
<instruction operation="arithmetic" note="example using 2 parameter functions.">
<input value="and(max(pow(x,y),pow(y,x)),0x33)" />
<input name="x" value="4" />
<input name="y" value="3" />
</instruction>
17
Here is a list of functions that the arithemetic expression handler understands, that take 1 parameter:
<instruction operation="arithmetic" note="example using 1 parameter functions.">
<input value="not(ceil(x)+floor(y))" />
<input name="x" value="4.133" />
<input name="y" value="3.013" />
</instruction>
-9
Here is a list of functions that the arithemetic expression handler understands, that take 3 parameters:
Note that any bits outside of the word length are not touched!
<instruction operation="arithmetic" note="rotate 7 bits left on an 8 bit word.">
<input value="rol(x,7,8)" />
<input name="x" value="43" />
</instruction>
149
Note that below we are outputting the result in base 16, using the precision attribute.
<instruction precision="b16" operation="arithmetic" note="flip lowest bit using 2-bit word.">
<input value="rol(x,1,2)" />
<input name="x" value="0x55" />
</instruction>
56