-
Notifications
You must be signed in to change notification settings - Fork 0
Instruction Set
Each instruction can take several forms, indicated in each section below detailing the function of each instruction. $<dest> refers to a variable called dest, with <> indicating where a custom name/value should be inserted. The use of square brackets [] means it is optional, so [$] would mean that a parameter can be a variable or a constant value.
A simple summation example, it iterates over an array of items and returns the integer sum of them.
get $size $t1 size ; Get the size attribute of object $t1 and put into $size variable.
cpy $i 0 ; Initialise $i to 0
cpy $sum 0 ; Initialise $sum to 0
:loop ; Start of loop label
get $x $t1 $i ; Read the value of index $i in object $t1 into variable $x
add $sum $sum $x ; Add $x to $sum and put into $sum
inc $i ; Increment $i by 1
jlt :loop $i $size ; If $i < $size then jump back to :loop
ret $sum ; Return the contents of $sumAll variables are preceded by a $. There can be up to 255 variables, none of which needs to be declared before first use. Using a variable that has not been defined or defining the value of variable and never using it will generate warnings in the assembler.
There are 3 special variables: $t1, $t2 and $h. These correspond to the hyperarc that is the subject of the definition being evaluated. For example, $t1 would be the "object", $t2 the "attribute" and $h the current (old) value under and object interpretation of the hypergraph.
Add two numeric NIDs together and put result into dest, or add one value to dest.
add $<dest> [$]<a> [$]<b>
add $<dest> [$]<value>Subtract two numeric NIDs (b from a) and put result into dest.
sub $<dest> [$]<a> [$]<b>
sub $<dest> [$]<value>div $<dest> [$]<a> [$]<b>
div $<dest> [$]<value>mul $<dest> [$]<a> [$]<b>
mul $<dest> [$]<value>Shift value left by n bits and put into dest.
shl $<dest> [$]<value> [$]<n>
shl $<dest> [$]<n>Shift value right by n bits and put into dest.
shr $<dest> [$]<value> [$]<n>
shr $<dest> [$]<n>and $<dest> [$]<a> [$]<b>
and $<dest> [$]<value>or $<dest> [$]<a> [$]<b>
or $<dest> [$]<value>xor $<dest> [$]<a> [$]<b>
xor $<dest> [$]<value>neg $<dest> [$]<value>
neg $<dest>inc $<value>dec $<value>Sets value to null.
clr $<value>Convert value to an integer and put into dest.
int $<dest> [$]<value>
int $<dest>Convert value to a float and put into dest.
flt $<dest> [$]<value>
flt $<dest>Copy a value from source into dest.
cpy $<dest> [$]<source>const <NAME> <value>Return value.
ret [$]<value>jmp :<label>jeq :<label> [$]<a> [$]<b>jne :<label> [$]<a> [$]<b>jle :<label> [$]<a> [$]<b>jge :<label> [$]<a> [$]<b>jlt :<label> [$]<a> [$]<b>jgt :<label> [$]<a> [$]<b>Read a single value from the t1 t2 HARC into dest.
get $<dest> [$]<t1> [$]<t2>Define the HARC t1 t2 as value. The value may be a constant or definition.
def [$]<t1> [$]<t2> [$]<value>Add a dependency where a1 a2 depends upon b1 b2.
dep [$]<a1> [$]<a2> [$]<b1> [$]<b2>
dep [$]<a> [$]<b>Create a new NID in dest which matches the kind NID.
new $<dest> [$]<kind>
new $<dest>Delete the HARC t1 t2.
del [$]<t1> [$]<t2>Follow a path through the graph, starting at element and putting the result into dest. Elements may be repeated any number of times and are separated by dots. The pathd form also adds dependencies to the HARC whose definition this corresponds to ($t1 and $t2).
path $<dest> [$]<element>[.]*
pathd $<dest> [$]<element>[.]*sclone
dclonejisa :<label> [$]<value> [$]<pattern>jisnt :<label> [$]<value> [$]<pattern>