APX Virtual Machine v2¶
Experimental version of APX VM currently being implemented in c-apx.
Instruction list¶
Each instruction starts with a single opcode byte followed by 0 or more additional bytes.
| Opcode Number | Opcode Name | Size | Additional instruction bytes | Description |
|---|---|---|---|---|
| 0 | NOP | 1 | No operation | |
| 1 | PACK_PROG_HDR | 7 |
|
pack program header |
| 2 | UNPACK_PROG_HDR | 7 |
|
pack program header |
| 3 | PACK_U8 | 1 | pack single uint8 | |
| 4 | PACK_U16 | 1 | pack single uint16 | |
| 5 | PACK_U32 | 1 | pack single uint32 | |
| 6 | PACK_S8 | 1 | pack single sint8 | |
| 7 | PACK_S16 | 1 | pack single sint16 | |
| 8 | PACK_S32 | 1 | pack single sint32 | |
| 9 | PACK_STR | 3 |
|
pack string |
| 10 | PACK_U8AR | 3 |
|
pack uint8 array |
| 11 | PACK_U16AR | 3 |
|
pack uint16 array |
| 12 | PACK_U32AR | 3 |
|
pack uint32 array |
| 13 | PACK_S8AR | 3 |
|
pack uint8 array |
| 14 | PACK_S16AR | 3 |
|
pack uint16 array |
| 15 | PACK_S32AR | 3 |
|
pack uint32 array |
| 64 | UNPACK_U8 | 1 | unpack single uint8 | |
| 65 | UNPACK_U16 | 1 | unpack single uint16 | |
| 66 | UNPACK_U32 | 1 | unpack single uint32 | |
| 67 | UNPACK_S8 | 1 | unpack single sint8 | |
| 68 | UNPACK_S16 | 1 | unpack single sint16 | |
| 69 | UNPACK_S32 | 1 | unpack single sint32 | |
| 70 | UNPPACK_STR | 3 |
|
unpack string |
| 71 | UNPACK_U8AR | 3 |
|
unpack uint8 array |
| 72 | UNPACK_U16AR | 3 |
|
unpack uint16 array |
| 73 | UNPACK_U32AR | 3 |
|
unpack uint32 array |
| 74 | UNPACK_S8AR | 3 |
|
unpack sint8 array |
| 75 | UNPACK_S16AR | 3 |
|
unpack sint16 array |
| 76 | UNPACK_S32AR | 3 |
|
unpack sint32 array |
| 128 | RECORD_ENTER | 1 | record inside of record | |
| 129 | RECORD_SELECT | 3 |
|
ID of record element |
| 130 | RECORD_LEAVE | 1 | ||
| 131 | ARRAY_ENTER | 1 | Used for array of records | |
| 132 | ARRAY_LEAVE | 1 |
APX Variants¶
Variants are variables that can store values of different types. They are supported in one way or another in most programming languages.
Types of variants:
- Scalars (integers, strings)
- Lists (list of variants)
- Maps (key-value map to variants)
Variant types are identified internally using integers according to the following table:
| Value | Name |
|---|---|
| -1 | VTYPE_INVALID |
| 0 | VTYPE_SCALAR |
| 1 | VTYPE_LIST |
| 2 | VTYPE_MAP |
Variant Language Mapping¶
Each APX implementation maps the APX variant according to what is available to the language.
| Programming Language | VTYPE_SCALAR | VTYPE_LIST | VTYPE_MAP |
|---|---|---|---|
| C (with dtl_type library) | dtl_sv_t | dtl_av_t | dtl_hv_t |
| C++ (with Qt variants) | QVariant | QVariantList | QVariantMap |
| Python | (int, str) | list | dict |
| Visual Basic (Excel) | Variant | Variant | Scripting.Dictionary |
Instruction Details¶
TBD