Skip to content

Commit ca48ea7

Browse files
authored
cannon: Update MIPS readme (#10552)
* cannon: Add missing instructions to MIPS readme * cannon: Remove pseudo-instructions from MIPS readme * cannon: Fix readme table alignment * cannon: Fix documentation - overflows are allowed
1 parent 507c515 commit ca48ea7

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

cannon/mipsevm/README.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,66 @@
11
# `mipsevm`
22

3-
Supported 55 instructions:
3+
Supported 63 instructions:
44
| Category | Instruction | Description |
55
|----------------------|---------------|----------------------------------------------|
6+
| `Arithmetic` | `add` | Add. |
67
| `Arithmetic` | `addi` | Add immediate (with sign-extension). |
7-
| `Arithmetic` | `addiu` | Add immediate unsigned (no overflow). |
8-
| `Arithmetic` | `addu` | Add unsigned (no overflow). |
8+
| `Arithmetic` | `addiu` | Add immediate unsigned. |
9+
| `Arithmetic` | `addu` | Add unsigned. |
910
| `Logical` | `and` | Bitwise AND. |
1011
| `Logical` | `andi` | Bitwise AND immediate. |
11-
| `Branch` | `b` | Unconditional branch. |
1212
| `Conditional Branch` | `beq` | Branch on equal. |
13-
| `Conditional Branch` | `beqz` | Branch if equal to zero. |
1413
| `Conditional Branch` | `bgez` | Branch on greater than or equal to zero. |
1514
| `Conditional Branch` | `bgtz` | Branch on greater than zero. |
1615
| `Conditional Branch` | `blez` | Branch on less than or equal to zero. |
1716
| `Conditional Branch` | `bltz` | Branch on less than zero. |
1817
| `Conditional Branch` | `bne` | Branch on not equal. |
19-
| `Conditional Branch` | `bnez` | Branch if not equal to zero. |
18+
| `Logical` | `clo` | Count leading ones. |
2019
| `Logical` | `clz` | Count leading zeros. |
20+
| `Arithmetic` | `div` | Divide. |
2121
| `Arithmetic` | `divu` | Divide unsigned. |
2222
| `Unconditional Jump` | `j` | Jump. |
2323
| `Unconditional Jump` | `jal` | Jump and link. |
2424
| `Unconditional Jump` | `jalr` | Jump and link register. |
2525
| `Unconditional Jump` | `jr` | Jump register. |
2626
| `Data Transfer` | `lb` | Load byte. |
2727
| `Data Transfer` | `lbu` | Load byte unsigned. |
28+
| `Data Transfer` | `lh` | Load halfword. |
29+
| `Data Transfer` | `lhu` | Load halfword unsigned. |
30+
| `Data Transfer` | `ll` | Load linked word. |
2831
| `Data Transfer` | `lui` | Load upper immediate. |
2932
| `Data Transfer` | `lw` | Load word. |
33+
| `Data Transfer` | `lwl` | Load word left. |
3034
| `Data Transfer` | `lwr` | Load word right. |
3135
| `Data Transfer` | `mfhi` | Move from HI register. |
3236
| `Data Transfer` | `mflo` | Move from LO register. |
33-
| `Data Transfer` | `move` | Move between registers. |
3437
| `Data Transfer` | `movn` | Move conditional on not zero. |
3538
| `Data Transfer` | `movz` | Move conditional on zero. |
39+
| `Data Transfer` | `mthi` | Move to HI register. |
3640
| `Data Transfer` | `mtlo` | Move to LO register. |
3741
| `Arithmetic` | `mul` | Multiply (to produce a word result). |
42+
| `Arithmetic` | `mult` | Multiply. |
3843
| `Arithmetic` | `multu` | Multiply unsigned. |
39-
| `Arithmetic` | `negu` | Negate unsigned. |
40-
| `No Op` | `nop` | No operation. |
41-
| `Logical` | `not` | Bitwise NOT (pseudo-instruction in MIPS). |
44+
| `Logical` | `nor` | Bitwise NOR. |
4245
| `Logical` | `or` | Bitwise OR. |
4346
| `Logical` | `ori` | Bitwise OR immediate. |
4447
| `Data Transfer` | `sb` | Store byte. |
48+
| `Data Transfer` | `sc` | Store conditional. |
49+
| `Data Transfer` | `sh` | Store halfword. |
4550
| `Logical` | `sll` | Shift left logical. |
4651
| `Logical` | `sllv` | Shift left logical variable. |
4752
| `Comparison` | `slt` | Set on less than (signed). |
4853
| `Comparison` | `slti` | Set on less than immediate. |
49-
| `Comparison` | `sltiu` | Set on less than immediate unsigned. |
54+
| `Comparison` | `sltiu` | Set on less than immediate unsigned. |
5055
| `Comparison` | `sltu` | Set on less than unsigned. |
5156
| `Logical` | `sra` | Shift right arithmetic. |
57+
| `Logical` | `srav` | Shift right arithmetic variable. |
5258
| `Logical` | `srl` | Shift right logical. |
5359
| `Logical` | `srlv` | Shift right logical variable. |
60+
| `Arithmetic` | `sub` | Subtract. |
5461
| `Arithmetic` | `subu` | Subtract unsigned. |
5562
| `Data Transfer` | `sw` | Store word. |
63+
| `Data Transfer` | `swl` | Store word left. |
5664
| `Data Transfer` | `swr` | Store word right. |
5765
| `Serialization` | `sync` | Synchronize shared memory. |
5866
| `System Calls` | `syscall` | System call. |

cannon/mipsevm/mips.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ func execute(insn uint32, rs uint32, rt uint32, mem uint32) uint32 {
498498
switch fun {
499499
case 0x2: // mul
500500
return uint32(int32(rs) * int32(rt))
501-
case 0x20, 0x21: // clo
501+
case 0x20, 0x21: // clz, clo
502502
if fun == 0x20 {
503503
rs = ^rs
504504
}

0 commit comments

Comments
 (0)