Every opcode has the syntax: 0001: wait %d%
where 0001
is an opcode id, %d
any param.
For example 0002: jump 0xABCD
as bytecode 02 00 05 CD AB
.
CLEO VM has the following types of arguments:
Type | ID | Example | Result |
---|---|---|---|
Int8 | 04 | 04 EA | 0xEA |
Int16 | 05 | 05 AB CD | 0xCDAB |
Int32 | 01 | 01 AB CD EF 00 | 0x00EFCDAB |
Float | 06 | 06 5C 8F C2 3F | 1.52 |
Local var | 03 | 03 0A 00 | 10@ |
Global var* | 02 | 02 0A 0F | $3850 |
String | 0E | 0E 05 68 65 6C 6C 6F | "hello" |
* Global variables unimplemented yet.
Set a wake up timer for the script.
Example: 0001: wait 10
Jump to address.
Example: 0002: jump @some_label
Binding a variable (local).
Example: 0003: 0@ = 10
Work same as opcode 0003
. Any value except String
0004: @var += @any
0005: @var -= @any
0006: @var *= @any
0007: @var /= @any
Set flags of VM.
@int = 0
- only one opcode must be true (not or). LogicalOpcode::One
.
@int = 1 .. 7
- same as AND. LogicalOpcode::And
.
@int = 21 .. 27
- same as OR. LogicalOpcode::Or
.
Jump to label if a condition is false. Example
0008: if and
00AB: some_opcode 10 50
0AF0: some_opcode 2@
0009: jump_if_false @condition_false
// here is true
<some code>
:condition_false
// here is false
<some code>
Print in IO any value.
0003: 10@ = 2.8
000A: print 10@ // will print "10@ = 2.8"
000A: print 5.1 // will print "5.1"
Using in conditions.
0008: if
0010: 10@ > 5
0009: jump_if_false @less_than_5
< do something >
Always return false for strings! You have to implement custom opcodes or upgrade current.
0011: @var != @any
0012: @var > @any
0013: @var < @any
0014: @var >= @any
0015: @var <= @any