commit e93541bf05ccfde3f530e238c13b52ad1f571c3c
parent cdc6f72ee39afd45ee92695d020be677bc9c1b9f
Author: Demonstrandum <moi@knutsen.co>
Date: Sun, 28 Jul 2019 23:48:37 +0100
Adding more bytecodes as I develop the compiler.
Diffstat:
2 files changed, 154 insertions(+), 2 deletions(-)
diff --git a/BYTECODE.md b/BYTECODE.md
@@ -20,3 +20,20 @@ Sizes are as follows:
| `00000110` | `DUP` | | Duplicates what was on the top of the stack, by popping it off and then pushing two copies. |
| `00000111` | `DUP_N` | 1 — The number of duplicates | Duplicates the top value on the stack N times. |
| `00001000` | `SWAP` | | Swaps the position of the top two stack elements. |
+| `00101000` | `N_ADD` | | Addition between two pointer-sized unsigned integers. Pops top two elements from the stacks and adds them together, pushing the result. |
+| `00101001` | `I_ADD` | | Addition between two pointer-sized signed integers. Pops top two elements from the stacks and adds them together, pushing the result. |
+| `00101010` | `R_ADD` | | Addition between two 64-bit floating-point numbers. Pops top two elements from the stacks and adds them together, pushing the result. |
+| `00101011` | `U_ADD` | | Addition between two values of unknown types, found out at runtime. Pops top two elements from the stacks and adds them together, pushing the result. |
+| `00101100` | `CONCAT` | | Works like add, but concatenates strings. |
+| `00101101` | `N_SUB` | | Subtraction between two pointer-sized unsigned integers. Pops top two elements from the stacks and subtracts them together, pushing the result. |
+| `00101110` | `I_SUB` | | Subtraction between two pointer-sized signed integers. Pops top two elements from the stacks and subtracts them together, pushing the result. |
+| `00101111` | `R_SUB` | | Subtraction between two 64-bit floating-point numbers. Pops top two elements from the stacks and subtracts them together, pushing the result. |
+| `00110000` | `U_SUB` | | Subtraction between two values of unknown types, found out at runtime. Pops top two elements from the stacks and subtracts one from the other, pushing the result. |
+| `00110001` | `N_MUL` | | Multiplication between two pointer-sized unsigned integers. Pops top two elements from the stacks and multiplies them together, pushing the result. |
+| `00110010` | `I_MUL` | | Multiplication between two pointer-sized signed integers. Pops top two elements from the stacks and multiplies them together, pushing the result. |
+| `00110011` | `R_MUL` | | Multiplication between two 64-bit floating-point numbers. Pops top two elements from the stacks and multiplies them together, pushing the result. |
+| `00110100` | `U_MUL` | | Multiplication between two values of unknown types, found out at runtime. Pops top two elements from the stacks and multiplies them together, pushing the result. |
+| `00110101` | `N_DIV` | | Division between two pointer-sized unsigned integers. Pops top two elements from the stacks and finds their quotient, pushing the result. |
+| `00110110` | `I_DIV` | | Division between two pointer-sized signed integers. Pops top two elements from the stacks and finds their quotient, pushing the result. |
+| `00110111` | `R_DIV` | | Division between two 64-bit floating-point numbers. Pops top two elements from the stacks and finds their quotient, pushing the result. |
+| `00111000` | `U_DIV` | | Division between two values of unknown types, found out at runtime. Pops top two elements from the stacks and finds their quotient, pushing the result. |
diff --git a/bytecode_spec.yaml b/bytecode_spec.yaml
@@ -84,4 +84,139 @@
:name: SWAP
:operands: 0
:desc: >-
- Swaps the position of the top two stack elements.-
\ No newline at end of file
+ Swaps the position of the top two stack elements.
+
+
+- :byte: 40
+ :name: N_ADD
+ :operands: 0
+ :desc: >-
+ Addition between two pointer-sized unsigned integers.
+ Pops top two elements from the stacks and adds
+ them together, pushing the result.
+
+- :byte: 41
+ :name: I_ADD
+ :operands: 0
+ :desc: >-
+ Addition between two pointer-sized signed integers.
+ Pops top two elements from the stacks and adds
+ them together, pushing the result.
+
+- :byte: 42
+ :name: R_ADD
+ :operands: 0
+ :desc: >-
+ Addition between two 64-bit floating-point numbers.
+ Pops top two elements from the stacks and adds
+ them together, pushing the result.
+
+- :byte: 43
+ :name: U_ADD
+ :operands: 0
+ :desc: >-
+ Addition between two values of unknown types, found out at runtime.
+ Pops top two elements from the stacks and adds
+ them together, pushing the result.
+
+- :byte: 44
+ :name: CONCAT
+ :operands: 0
+ :desc: >-
+ Works like add, but concatenates strings.
+
+- :byte: 45
+ :name: N_SUB
+ :operands: 0
+ :desc: >-
+ Subtraction between two pointer-sized unsigned integers.
+ Pops top two elements from the stacks and subtracts
+ them together, pushing the result.
+
+- :byte: 46
+ :name: I_SUB
+ :operands: 0
+ :desc: >-
+ Subtraction between two pointer-sized signed integers.
+ Pops top two elements from the stacks and subtracts
+ them together, pushing the result.
+
+- :byte: 47
+ :name: R_SUB
+ :operands: 0
+ :desc: >-
+ Subtraction between two 64-bit floating-point numbers.
+ Pops top two elements from the stacks and subtracts
+ them together, pushing the result.
+
+- :byte: 48
+ :name: U_SUB
+ :operands: 0
+ :desc: >-
+ Subtraction between two values of unknown types, found out at runtime.
+ Pops top two elements from the stacks and subtracts
+ one from the other, pushing the result.
+
+- :byte: 49
+ :name: N_MUL
+ :operands: 0
+ :desc: >-
+ Multiplication between two pointer-sized unsigned integers.
+ Pops top two elements from the stacks and multiplies
+ them together, pushing the result.
+
+- :byte: 50
+ :name: I_MUL
+ :operands: 0
+ :desc: >-
+ Multiplication between two pointer-sized signed integers.
+ Pops top two elements from the stacks and multiplies
+ them together, pushing the result.
+
+- :byte: 51
+ :name: R_MUL
+ :operands: 0
+ :desc: >-
+ Multiplication between two 64-bit floating-point numbers.
+ Pops top two elements from the stacks and multiplies
+ them together, pushing the result.
+
+- :byte: 52
+ :name: U_MUL
+ :operands: 0
+ :desc: >-
+ Multiplication between two values of unknown types, found out at runtime.
+ Pops top two elements from the stacks and multiplies
+ them together, pushing the result.
+
+- :byte: 53
+ :name: N_DIV
+ :operands: 0
+ :desc: >-
+ Division between two pointer-sized unsigned integers.
+ Pops top two elements from the stacks and finds their
+ quotient, pushing the result.
+
+- :byte: 54
+ :name: I_DIV
+ :operands: 0
+ :desc: >-
+ Division between two pointer-sized signed integers.
+ Pops top two elements from the stacks and finds their
+ quotient, pushing the result.
+
+- :byte: 55
+ :name: R_DIV
+ :operands: 0
+ :desc: >-
+ Division between two 64-bit floating-point numbers.
+ Pops top two elements from the stacks and finds their
+ quotient, pushing the result.
+
+- :byte: 56
+ :name: U_DIV
+ :operands: 0
+ :desc: >-
+ Division between two values of unknown types, found out at runtime.
+ Pops top two elements from the stacks and finds their
+ quotient, pushing the result.+
\ No newline at end of file