aboutsummaryrefslogtreecommitdiff
path: root/doc/Documentation.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/Documentation.md')
-rw-r--r--doc/Documentation.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/Documentation.md b/doc/Documentation.md
new file mode 100644
index 0000000..34d1b41
--- /dev/null
+++ b/doc/Documentation.md
@@ -0,0 +1,31 @@
+# Opcode
+Variable length opcodes. Sizes range from 1 to 4 bytes.
+## Instruction formats
+Instructions can be in 6 different formats:
+1. 1 byte: Opcode
+2. 2 bytes: Opcode + register
+3. 3 bytes: Opcode + register + register
+4. 3 bytes:\
+4.1 Opcode + intermediate\
+4.2 Opcode + data\
+4.3 Opcode + index\
+4.4 Opcode + offset
+5. 4 bytes: Opcode + register + register + register
+6. 4 bytes: Opcode + register + offset
+
+# Compiler flow
+(Tokenize&parse -> Resolve AST -> Generate SSA -> Generate bytecode) -> Generate program\
+Each step except the last is done using multiple threads in parallel and the output of each step is used
+in the next step. The last step is not done in parallel because the last step is combining all bytecode
+and writing it to a file, which is an IO bottlenecked operation and it won't benefit from multithreading
+and may even lose performance because of it.
+
+# Bytecode header
+## Header layout
+|Size|Name |Description |
+|----|-------------|----------------------------------------------------------------------------|
+|4 |Magic number |The magic number used to identify an amalgam bytecode file. |
+|1 |Major version|The major version of the bytecode. Updates in this is a breaking change. |
+|1 |Minor version|The minor version of the bytecode. Updates in this are backwards compatible.|
+|1 |Patch version|The patch version of the bytecode. Updates in this are only minor bug fixes.|
+The versions in the header only changes for every release, not every change. \ No newline at end of file