bytecode_spec.yaml (8011B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | # - :byte: n
# :name: s
# :operands: n
# :operand_desc: ['']
# :desc: >-
# ...
- :byte: 0
:name: EOI
:operands: 0
:desc: >-
End Of Instructions! This is not a real opcode and
only appears at the end of the instruction byte-stream
to signal that there are no more instructions to be read.
Essentially it's just a null-terminator.
- :byte: 200
:name: HALT
:operands: 1
:operand_desc: ['Exit Code (Integer)']
:desc: >-
Stops execution.
- :byte: 1
:name: PUSH_CONST
:operands: 1
:operand_desc: ['Unsigned index to constants table']
:desc: >-
Pushes a constant onto the stack.
Constant is specified by a given index to the
constant-table, containing all local constant.
- :byte: 2
:name: PUSH_LOCAL
:operands: 1
:operand_desc: ['Local variable index (Unsigned)']
:desc: >-
Pushes a local variable (e.g. a function param)
onto the stack. The local variable is identified by
an index operand, to where it is in the current symbol
table.
- :byte: 3
:name: PUSH_SUPER
:operands: 1
:operand_desc: ['Name of super-scoped variable (String)']
:desc: >-
When a variable is out of the local scope, load it
onto the stack by
searching up the super-scope by its name, (much slower
than `PUSH_LOCAL`).
- :byte: 4
:name: POP
:operands: 0
:desc: >-
Pops the top element off of the stack.
- :byte: 5
:name: STORE_LOCAL
:operands: 1
:operand_desc: ['Index to store local variable in table (Unsigned)']
:desc: >-
Pops the top value and stores it in the local symbol table
at a given index.
# - :byte: 6
# :name: STORE_SUPER
# :operands: 1
# :operand_desc: ['Name of super-scoped variable (String)']
# :desc: >-
# When a variable is out of the local scope, pop it
# off of the stack to store it in the super-scope
# searching up the frames for its name, (much slower
# than `STORE_LOCAL`).
- :byte: 6
:name: DUP
:operands: 0
:desc: >-
Duplicates what was on the top of the stack,
by popping it off and then pushing two copies.
- :byte: 7
:name: DUP_N
:operands: 1
:operand_desc: ['The number of duplicates']
:desc: >-
Duplicates the top value on the stack N times.
- :byte: 8
:name: SWAP
:operands: 0
:desc: >-
Swaps the position of the top two stack elements.
- :byte: 9
:name: CALL_1
:operands: 0
:desc: >-
Calls function at top of stack with argument at second
from top of stack.
- :byte: 10
:name: CHECK_TYPE
:operands: 0
:desc: >-
Checks if second from top of stack value is a member
of the set/type loaded from the top of the stack.
- :byte: 11
:name: CAST
:operands: 2
:operand_desc: [
'One byte, specifies the origin type.',
'One byte, specifies the destination type.'
]
:desc: >-
Changes the top-of-stack value to have a different
primitive type.
- :byte: 12
:name: MAKE_FUNC
:operands: 0
:desc: >-
Takes the top-of-stack value, referencing a code
block, and makes it a function, with all the special
properties that come with that.
- :byte: 13
:name: YIELD
:operands: 0
:desc: >-
Causes the current function to yield a value
(i.e. return).
- :byte: 14
:name: RAW_PRINT
:operands: 0
:desc: >-
Native debug print of `TOS`.
Should not be used unless working on the
compiler.
- :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.
- :byte: 254
:name: SET_LINE
:operands: 1
:operand_desc: ['Current line number, given directly as `u16`. Operand value is line number.']
:desc: >-
Sets the current line number that the subsequent
bytecode instructions correspond to in the code
source file.
- :byte: 255
:name: NOP
:operands: 0
:desc: >-
<u>N</u>o <u>Op</u>eration. Does nothing.
You shouldn't see this in the final compiled
bytecode, it may only exists temporarily while the
bytecode is being produced.
|