-
Notifications
You must be signed in to change notification settings - Fork 1
Instruction Set
0x00 noop
Does nothing.
This instruction is potentially useful for marking sections of code for later processing.
0x01 copy <tgt> <src>
Copies the value in src
into tgt
.
This doesn't actually perform a deep copy, just a copy of the pointer.
0x02 type <tgt> <src>
Get the type of the value in src
and assign it (as an atom) to tgt
.
Possible values are 'nil'
, 'integer'
, 'float'
, 'atom'
, 'binary'
, 'address'
, 'function'
, 'tuple'
, 'list'
, 'map'
, 'set'
, and 'resource'
.
0x03 load.nil <tgt>
Loads the nil value into tgt
.
0x04 load.int <tgt> (<integer>)
Loads the given integer into tgt
.
0x05 load.flt <tgt> (<float>)
Loads the given float into tgt
.
0x06 load.atom <tgt> (<atom>)
Loads the given atom into tgt
.
0x07 load.bin <tgt> (<binary>)
Loads the given binary into tgt
.
0x08 load.func <tgt> <src1> <src2> <upv1> ... <upvN>
Loads a function value into tgt
.
src1
must be an atom identifying the module containing the target function. src2
must be an atom identifying the function. Any following registers are upvalues.
If there are any upvalues, they will be passed as the first argument to the target function, in the form of a tuple where the elements are in the same order as they're given to this instruction.
0x09 num.add <tgt> <src1> <src2>
Adds the value in src2
to the value in src1
and stores the result in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0A num.sub <tgt> <src1> <src2>
Subtracts the value in src2
from the value in src1
and stores the result in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0B num.mul <tgt> <src1> <src2>
Multiplies the value in src1
with the value in src2
and stores the result in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0C num.div <tgt> <src1> <src2>
Divides the value in src1
with the value in src2
and stores the result in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0D num.rem <tgt> <src1> <src2>
Computes the remainder of dividing the value in src1
with the value in src2
and stores it in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0E num.pow <tgt> <src1> <src2>
Computes the value in src1
to the power of the value in src2
and stores the result in tgt
.
src1
and src2
must be of the same type, which must be integer or float.
0x0F num.neg <tgt> <src>
Negates the value in src
and stores the result in tgt
.
src
must be of type integer or float.
0x10 num.and <tgt> <src1> <src2>
Computes the bitwise AND between the values in src1
and src2
and stores the result in tgt
.
src1
and src2
must be of type integer.
0x11 num.or <tgt> <src1> <src2>
Computes the bitwise OR between the values in src1
and src2
and stores the result in tgt
.
src1
and src2
must be of type integer.
0x12 num.xor <tgt> <src1> <src2>
Computes the bitwise XOR between the values in src1
and src2
and stores the result in tgt
.
src1
and src2
must be of type integer.
0x13 num.not <tgt> <src>
Performs a bitwise negation of the value in src1
and stores the result in tgt
.
src
must be of type integer.
0x14 num.shl <tgt> <src1> <src2>
Shifts the bits in src1
left by the amount specified in src2
and stores the result in tgt
.
src1
and src2
must be of type integer.
0x15 num.shr <tgt> <src1> <src2>
Shifts the bits in src1
left by the amount specified in src2
and stores the result in tgt
.
src1
and src2
must be of type integer.
0x16 cmp.lt <tgt> <src1> <src2>
Determines whether the value in src1
is less than the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x17 cmp.gt <tgt> <src1> <src2>
Determines whether the value in src1
is greater than the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x18 cmp.eq <tgt> <src1> <src2>
Determines whether the value in src1
is equal to the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x19 cmp.neq <tgt> <src1> <src2>
Determines whether the value in src1
is not equal to the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x1A cmp.lteq <tgt> <src1> <src2>
Determines whether the value in src1
is less than or equal to the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x1B cmp.gteq <tgt> <src1> <src2>
Determines whether the value in src1
is greater than or equal to the value in src2
. Stores the result in tgt
as either the 'true'
atom or the 'false'
atom.
0x1C call.rem <tgt> <src1> <src2> <arg1> ... <argN>
Calls the function identified by the atom in src2
in the module identified by the atom in src1
and stores the result in tgt
. All remaining registers are arguments passed to the target function.
src1
and src2
must be of type atom.
0x1D call.func <tgt> <src> <arg1> ... <argN>
Invokes the function value in src
and assigns the result to tgt
. All following registers are arguments to pass to the target function (after the upvalues tuple possibly passed as the first argument).
tgt
must be of type atom. src
must be of type function.
0x1E call.up <tgt> <src1> <src2> <arg1> ... <argN>
Calls a native function in the virtual machine or in a shared library. src1
is an atom identifying the library, e.g. '__kernel__'
for functions in the VM or 'edit'
for functions in the libedit.so
shared library. src2
is the name of the function as an atom. The result will be stored in tgt
.
src1
and src2
must be of type atom.
0x1F tup.make <tgt> <elt1> ... <eltN>
0x20 tup.get <tgt> <src1> <src2>
0x21 tup.set <tgt> <src1> <src2> <src3>
0x22 tup.del <tgt> <src1> <src2>
0x23 tup.size <tgt> <src>
0x24 list.make <tgt> <elt1> ... <eltN>
0x25 list.head <tgt> <src>
0x26 list.tail <tgt> <src>
0x27 list.cons <tgt> <src1> <src2>
0x28 map.make <tgt> <src1> ... <srcN>
0x29 map.add <tgt> <src1> <src2> <src3>
0x2A map.get <tgt> <src1> <src2>
0x2B map.del <tgt> <src1> <src2>
0x2C map.size <tgt> <src>
0x2D map.keys <tgt> <src>
0x2E map.vals <tgt> <src>
0x2F set.make <tgt> <src1> ... <srcN>
0x30 set.add <tgt> <src1> <src2>
0x31 set.find <tgt> <src1> <src2>
0x32 set.del <tgt> <src1> <src2>
0x33 set.size <tgt> <src>
0x34 set.vals <tgt> <src>
0x35 bin.size <tgt> <src>
0x36 bin.ebin <tgt> <src1> <src2> <src3>
0x37 bin.dbin <tgt> <src1> <src2> <src3>
0x38 bin.efs <tgt> <src1> <src2> <src3> (<endianness>)
0x39 bin.efd <tgt> <src1> <src2> <src3> (<endianness>)
0x3A bin.dfs <tgt> <src1> <src2> (<endianness>)
0x3B bin.dfd <tgt> <src1> <src2> (<endianness>)
0x3C bin.eisu <tgt> <src1> <src2> <src3> <src4> (<endianness>)
0x3D bin.dis <tgt> <src1> <src2> <src3> (<endianness>)
0x3E bin.diu <tgt> <src1> <src2> <src3> (<endianness>)
0x3F jump.goto (<block>)
Branches to block
.
This is a terminator instruction.
0x40 jump.cond <src> (<block1> <block2>)
Branches to block1
if src
is the 'true'
atom. Otherwise, branches to block2
.
This is a terminator instruction.
0x41 jump.ret <src>
Returns src
from the current function, transferring control to the calling function.
This is a terminator instruction.
0x42 exc.new <src>
This is a terminator instruction.
0x43 exc.get <tgt>
0x44 exc.cont
This is a terminator instruction.