aboutsummaryrefslogtreecommitdiff
path: root/BinaryEncoding.md
diff options
context:
space:
mode:
authorLuke Wagner <mail@lukewagner.name>2017-01-10 13:15:40 -1000
committerGitHub <noreply@github.com>2017-01-10 13:15:40 -1000
commit2d8626f15126d080ce5e63e20bf280c451ea4dc3 (patch)
tree32438c61b62b36ac75f91961122a1335f60d1904 /BinaryEncoding.md
parentc6f9f700392d6f36e34a992d180a30da00bd5bef (diff)
downloadnanowasm-design-2d8626f15126d080ce5e63e20bf280c451ea4dc3.tar.gz
Describe instruction opcode encoding scheme (#926)
* Describe instruction opcode encoding scheme * Not actually 'far' fewer
Diffstat (limited to 'BinaryEncoding.md')
-rw-r--r--BinaryEncoding.md13
1 files changed, 12 insertions, 1 deletions
diff --git a/BinaryEncoding.md b/BinaryEncoding.md
index c1c1a0c..799f529 100644
--- a/BinaryEncoding.md
+++ b/BinaryEncoding.md
@@ -53,6 +53,15 @@ represented by _at most_ ceil(_N_/7) bytes that may contain padding `0x80` or `0
Note: Currently, the only sizes used are `varint7`, `varint32` and `varint64`.
+## Instruction Opcodes
+
+In the MVP, the opcodes of [instructions](Semantics.md) are all encoded in a
+single byte since there are fewer than 256 opcodes. Future features like
+[SIMD](FutureFeatures.md#fixed-width-simd) and [atomics](FutureFeatures.md#threads)
+will bring the total count above 256 and so an extension scheme will be
+necessary, designating one or more single-byte values as prefixes for multi-byte
+opcodes.
+
## Language Types
All types are distinguished by a negative `varint7` values that is the first byte of their encoding (representing a type constructor):
@@ -456,7 +465,9 @@ count may be greater or less than the actual number of locals.
# Function Bodies
Function bodies consist of a sequence of local variable declarations followed by
-[bytecode instructions](Semantics.md). Each function body must end with the `end` opcode.
+[bytecode instructions](Semantics.md). Instructions are encoded as an
+[opcode](#instruction-opcodes) followed by zero or more *immediates* as defined
+by the tables below. Each function body must end with the `end` opcode.
| Field | Type | Description |
| ----- | ---- | ----------- |