aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/Documentation.md23
1 files changed, 15 insertions, 8 deletions
diff --git a/doc/Documentation.md b/doc/Documentation.md
index ca579a2..88647a7 100644
--- a/doc/Documentation.md
+++ b/doc/Documentation.md
@@ -1,5 +1,5 @@
-# Opcode
-Variable length opcodes. Sizes range from 1 to 5 bytes.
+# Instructions
+Variable length instructions. Instruction size ranges from 1 to 5 bytes.
## Instruction formats
Instructions can be in 7 different formats:
1. 1 byte: Opcode(u8)
@@ -15,7 +15,8 @@ Instructions can be in 7 different formats:
6.1 Opcode(u8) + register(i8) + label(i16)\
6.2 Opcode(u8) + register(i8) + intermediate(u16)\
6.3 Opcode(u8) + register(i8) + data(u16)\
-6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)
+6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)\
+6.5 Opcode(u8) + stack_offset(i24)
7. 5 bytes: Opcode(u8) + index(u8) + index(u16) + num_args(u8)
## Registers
Registers have a range of 128. Local variables start from register 0 and increment while parameters start from -1
@@ -44,6 +45,7 @@ The value of the magic number is @AMAL_BYTECODE_SECTION_MAGIC_NUMBER
|u8 |Major version|The major version of the bytecode. Updates in this is a breaking change. |
|u8 |Minor version|The minor version of the bytecode. Updates in this are backwards compatible.|
|u8 |Patch version|The patch version of the bytecode. Updates in this are only minor bug fixes.|
+|u8 |Endian |Endian of the program. 0 = little endian, 1 = big endian. |
The versions in the header only changes for every release, not every change.
@@ -102,11 +104,16 @@ The versions in the header only changes for every release, not every change.
|External function[]|External functions|Multiple external functions, where the number of functions is defined by @num_extern_func|
## External function
-|Type|Field |Description |
-|----|----------|-----------------------------------------------------------------------------------------------------|
-|u8 |num_params|The number of parameters the functions has. |
-|u8 |name_len |The length of the external function name, in bytes. Excluding the null-terminate character. |
-|u8[]|name |The name of the external function, where the size is defined by @name_len. Names are null-terminated.|
+|Type|Field |Description |
+|----|-------------------------|-----------------------------------------------------------------------------------------------------|
+|u8 |num_params |The number of parameters. |
+|u32 |params_num_pointers |The number of pointers in the parameters. |
+|u32 |params_fixed_size |The size of all non-pointer type parameters, in bytes. |
+|u8 |num_return_types |The number of return values. |
+|u32 |return_types_num_pointers|The number of pointers in the return types. |
+|u32 |return_types_fixed_size |The size of all non-pointer type return types, in bytes. |
+|u8 |name_len |The length of the external function name, in bytes. Excluding the null-terminate character. |
+|u8[]|name |The name of the external function, where the size is defined by @name_len. Names are null-terminated.|
# Bytecode exported functions
## Exported functions layout