improve data structures

This commit is contained in:
andromeda
2026-03-24 20:49:52 +01:00
parent 74fc57cdfc
commit 121a0df8e4
3 changed files with 322 additions and 70 deletions

View File

@@ -212,33 +212,83 @@ entries are as follows:
```
+------------------------------+
| 0 operand operators |
+------------------------------+
| 127 96 |
+------------------------------+
| reserved |
+------------------------------+
| 95 64 |
+------------------------------+
| reserved |
+------------------------------+
| 63 32 |
+------------------------------+
| reserved |
+----------+--------+----------+
| 31 24 | 23 16 | 15 0 |
+----------+--------+----------+
| reserved | opcode | token ID |
+----------+--------+----------+
+-------+----------+---------+----------+
| 1 operand operators |
+-------+----------+---------+----------+
| 31 27 | 26 24 | 23 16 | 15 0 |
+-------+----------+---------+----------+
| zeros | reg bits | opcode | token ID |
| | | dst=r/m | |
+-------+----------+---------+----------+
+-------------------------------------------------------------+
| 1 operand operators |
+-------------------------------------------------------------+
| 127 96 |
+-------------------------------------------------------------+
| reserved |
+----------+-------+-------+-------+-------+----------+-------+
| 95 88 | 87 84 | 83 80 | 79 76 | 75 72 | 71 68 | 67 64 |
+----------+-------+-------+-------+-------+----------+-------+
| reserved | op5&8 | op4&8 | op3&8 | op2&8 | reserved | op0&8 |
+----------+-------+-------+-------+-------+----------+-------+
| 63 56 | 55 48 | 47 40 | 39 32 |
+----------+---------------+---------------+------------------+
| opcode | opcode | opcode | opcode |
| dst=rel8 | dest=rel | dst=imm8 | dst=imm |
+----------+---------------+---------------+------------------+
| 31 24 | 23 16 | 15 0 |
+----------+---------------+----------------------------------+
| reserved | opcode | token ID |
| | dst=r/m | |
+----------+---------------+----------------------------------+
+------------------------------+
| 2 operand operators |
+---------+---------+----------+
| 31 24 | 23 16 | 15 0 |
+---------+---------+----------+
| opcode | opcode | token ID |
| dst=reg | dst=r/m | |
| src=r/m | src=reg | |
+---------+---------+----------+
+----------------------------------------------+
| 2 operand operators |
+----------------------------------------------+
| 127 96 |
+----------------------------------------------+
| reserved |
+-------------------+-------+-------+----------+
| 95 80 | 79 76 | 75 72 | 71 64 |
+-------------------+-------+-------+----------+
| reserved | op3&8 | op2&8 | reserved |
+-------------------+-------+-------+----------+
| 63 48 | 47 40 | 39 32 |
+-------------------+---------------+----------+
| reserved | opcode | opcode |
| | dst=r/m | dst=r/m |
| | src=imm8 | src=imm |
+---------+---------+---------------+----------+
| 31 24 | 23 16 | 15 0 |
+---------+---------+--------------------------+
| opcode | opcode | token ID |
| dst=r | dst=r/m | |
| src=r/m | src=r | |
+---------+---------+--------------------------+
; key:
r/m ; r/m 16/32/64
r ; r 16/32/64
imm ; imm 16/32
imm8 ; imm 8
rel ; rel 16/32
rel8 ; rel 8
opX&8 ; low 8 bits are the operator flag that goes with opcode at offset X from
; the first opcode in the table entry
```
note the lack of support for multiple-byte opcodes or multiple opcodes for one token ID; these features will likely be added at some point after the parser accumulates too much jank.
note much room to expand. If an opcode doesn't exist, it should be 0x00
### token IDs
@@ -339,6 +389,7 @@ supported tokens are listed below
| ret | 0x005A | |
| cmp | 0x005B | |
| | 0x10XX | some memory address; `XX` is as specified below |
| | 0xFEXX | used to pass some raw value `XX` in place of a token id |
| | 0xFFFF | unrecognised token |
values of `XX` in `0x10XX`: