aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-24 00:48:40 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit7212ea877ed85d3b85af90c902639df44fc493f2 (patch)
treec76d73e9882a832f82cef977efb6fb26fb0e4984 /doc
parentd6f368a3f400fea3e89280262a8147e7ce5d855c (diff)
Add exported variable (only functions for now), export main func, start execution from main func
Diffstat (limited to 'doc')
-rw-r--r--doc/Documentation.md20
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/Documentation.md b/doc/Documentation.md
index 79e81aa..8b2133e 100644
--- a/doc/Documentation.md
+++ b/doc/Documentation.md
@@ -15,7 +15,7 @@ Instructions can be in 7 different formats:
6.1 Opcode(u8) + register(i8) + offset(i16)\
6.2 Opcode(u8) + register(i8) + intermediate(u16)\
6.3 Opcode(u8) + register(i8) + data(u16)\
-6.4 Opcode(u8) + num_param_reg(u8) + num_local_var_reg(u16)
+6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)
7. 5 bytes: Opcode(u8) + index(u16) + num_args(u8) + register(i8)
## Registers
Registers have a range of 128. Local variables start from register 0 and increment while parameters start from -1
@@ -29,7 +29,7 @@ and writing it to a file, which is an IO bottlenecked operation and it won't ben
and may even lose performance because of it.
# Bytecode
-The layout of the full bytecode is: Header (Intermediates Strings Functions External_Functions Instructions)*
+The layout of the full bytecode is: Header (Intermediates Strings Functions External_Functions Exported_Functions Instructions)*
# Bytecode header
## Header layout
@@ -90,6 +90,22 @@ The versions in the header only changes for every release, not every change.
|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
+|Type |Field |Description |
+|-----------------|------------------|-----------------------------------------------------------------------------------------|
+|u16 |num_export_func |The number of exported functions. |
+|u32 |export_funcs_size |The size of the exported functions section, in bytes. |
+|Exported function|Exported functions|Multiple exported functions, where the number of functions is defined by @num_export_func|
+
+## Exported function
+|Type|Field |Description |
+|----|------------------|--------------------------------------------------------------------------------------------------------------------------|
+|u32 |instruction_offset|The offset in the instruction data where the exported function is defined. Is always 0 until the program has been started.|
+|u8 |num_args |The number of arguments the functions has. |
+|u8 |name_len |The length of the exported function name, in bytes. Excluding the null-terminate character. |
+|u8* |name |The name of the exported function, where the size is defined by @name_len. Names are null-terminated. |
+
# Bytecode instructions
## Instructions layout
|Type |Field |Description |