Finish up the opcode ascii table layouts

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-01-28 19:27:25 -05:00
parent e8b874a3c9
commit 47ee61ca0d

148
vm.md
View File

@@ -61,37 +61,101 @@ wrapping around to 0.
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 + REG2` * `REG1 = REG1 + REG2`
* Unsigned addition * Unsigned addition
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000000 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Mul * Mul
* Opcode: 0x0001 * Opcode: 0x0001
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 * REG2` * `REG1 = REG1 * REG2`
* Unsigned multiplication * Unsigned multiplication
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000001 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Div * Div
* Opcode: 0x0002 * Opcode: 0x0002
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 / REG2` * `REG1 = REG1 / REG2`
* Unsigned division * Unsigned division
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000010 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Mod * Mod
* Opcode: 0x0003 * Opcode: 0x0003
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 % REG2` (exact semantics TBD) * `REG1 = REG1 % REG2` (exact semantics TBD)
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000011 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* INeg * INeg
* Opcode: 0x0004 * Opcode: 0x0004
* **Params**: REG1 * **Params**: REG1
* `REG1 = REG1 * -1` * `REG1 = REG1 * -1`
* Signed negative * Signed negative
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0000000000000100 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
* And * And
* Opcode: 0x0005 * Opcode: 0x0005
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 & REG2` * `REG1 = REG1 & REG2`
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000101 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Or * Or
* Opcode: 0x0006 * Opcode: 0x0006
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 | REG2` * `REG1 = REG1 | REG2`
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000000110 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Inv * Inv
* Opcode: 0x0007 * Opcode: 0x0007
* **Params**: REG1 * **Params**: REG1
* `REG1 = ~REG1` * `REG1 = ~REG1`
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0000000000000111 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
* Not * Not
* Opcode: 0x0008 * Opcode: 0x0008
* **Params**: REG1 * **Params**: REG1
@@ -103,19 +167,51 @@ wrapping around to 0.
} }
``` ```
* Boolean NOT; equivalent of C's `!` unary operator * Boolean NOT; equivalent of C's `!` unary operator
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0000000000001000 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
* Xor * Xor
* Opcode: 0x0009 * Opcode: 0x0009
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 ^ REG2` * `REG1 = REG1 ^ REG2`
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000001001 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Shl * Shl
* Opcode: 0x000A * Opcode: 0x000A
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 << REG2` * `REG1 = REG1 << REG2`
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000001010 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Shr * Shr
* Opcode: 0x000B * Opcode: 0x000B
* **Params**: REG1, REG2 * **Params**: REG1, REG2
* `REG1 = REG1 >> REG2` * `REG1 = REG1 >> REG2`
* Does not sign extend * Does not sign extend
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0000000000001011 | ...... | ...... | XXXX |
+-------------------------------------------+
```
### TODO ### TODO
@@ -136,6 +232,14 @@ wrapping around to 0.
} }
``` ```
* Sets the COMPARE flag to 1 if REG1 == REG2 * Sets the COMPARE flag to 1 if REG1 == REG2
* ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0001000000000000 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* CmpLt * CmpLt
* Opcode: 0x1001 * Opcode: 0x1001
* **Params**: REG1, REG2 * **Params**: REG1, REG2
@@ -147,17 +251,47 @@ wrapping around to 0.
} }
``` ```
* Sets the COMPARE flag to 1 if REG1 < REG2 * Sets the COMPARE flag to 1 if REG1 < REG2
* Jz * ```
32 16 10 4 0
opcode reg1 reg2 unused
/ / / /
+-------------------------------------------+
| 0001000000000001 | ...... | ...... | XXXX |
+-------------------------------------------+
```
* Jmp
* Opcode: 0x1100 * Opcode: 0x1100
* **Params**: REG1 * **Params**: REG1
* `IP = REG1;`
* Jumps to the address in REG1 unconditionally.
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0001000000000000 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
* Jz
* Opcode: 0x1101
* **Params**: REG1
* ``` * ```
if FLAGS[1] == 0 { if FLAGS[1] == 0 {
IP = REG1; IP = REG1;
} }
``` ```
* Jumps to the address in REG1 if COMPARE flag is 0. * Jumps to the address in REG1 if COMPARE flag is 0.
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0001000000000001 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
* Jnz * Jnz
* Opcode: 0x1001 * Opcode: 0x1002
* **Params**: REG1 * **Params**: REG1
* ``` * ```
if FLAGS[1] != 0 { if FLAGS[1] != 0 {
@@ -165,6 +299,14 @@ wrapping around to 0.
} }
``` ```
* Jumps to the address in REG1 if COMPARE flag is 1. * Jumps to the address in REG1 if COMPARE flag is 1.
* ```
32 16 10 0
opcode reg1 unused
/ / /
+----------------------------------------+
| 0001000000000002 | ...... | XXXXXXXXXX |
+----------------------------------------+
```
## Data movement ## Data movement
@@ -177,7 +319,7 @@ wrapping around to 0.
* Sets REG1 to the value at the memory address in REG2. * Sets REG1 to the value at the memory address in REG2.
* ``` * ```
32 16 10 4 0 32 16 10 4 0
64 - opcode reg1 reg2 unused opcode reg1 reg2 unused
/ / / / / / / /
+-------------------------------------------+ +-------------------------------------------+
| 0010000000000000 | ...... | ...... | XXXX | | 0010000000000000 | ...... | ...... | XXXX |