Commit ca48ea7b authored by mbaxter's avatar mbaxter Committed by GitHub

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
parent 507c515e
# `mipsevm` # `mipsevm`
Supported 55 instructions: Supported 63 instructions:
| Category | Instruction | Description | | Category | Instruction | Description |
|----------------------|---------------|----------------------------------------------| |----------------------|---------------|----------------------------------------------|
| `Arithmetic` | `add` | Add. |
| `Arithmetic` | `addi` | Add immediate (with sign-extension). | | `Arithmetic` | `addi` | Add immediate (with sign-extension). |
| `Arithmetic` | `addiu` | Add immediate unsigned (no overflow). | | `Arithmetic` | `addiu` | Add immediate unsigned. |
| `Arithmetic` | `addu` | Add unsigned (no overflow). | | `Arithmetic` | `addu` | Add unsigned. |
| `Logical` | `and` | Bitwise AND. | | `Logical` | `and` | Bitwise AND. |
| `Logical` | `andi` | Bitwise AND immediate. | | `Logical` | `andi` | Bitwise AND immediate. |
| `Branch` | `b` | Unconditional branch. |
| `Conditional Branch` | `beq` | Branch on equal. | | `Conditional Branch` | `beq` | Branch on equal. |
| `Conditional Branch` | `beqz` | Branch if equal to zero. |
| `Conditional Branch` | `bgez` | Branch on greater than or equal to zero. | | `Conditional Branch` | `bgez` | Branch on greater than or equal to zero. |
| `Conditional Branch` | `bgtz` | Branch on greater than zero. | | `Conditional Branch` | `bgtz` | Branch on greater than zero. |
| `Conditional Branch` | `blez` | Branch on less than or equal to zero. | | `Conditional Branch` | `blez` | Branch on less than or equal to zero. |
| `Conditional Branch` | `bltz` | Branch on less than zero. | | `Conditional Branch` | `bltz` | Branch on less than zero. |
| `Conditional Branch` | `bne` | Branch on not equal. | | `Conditional Branch` | `bne` | Branch on not equal. |
| `Conditional Branch` | `bnez` | Branch if not equal to zero. | | `Logical` | `clo` | Count leading ones. |
| `Logical` | `clz` | Count leading zeros. | | `Logical` | `clz` | Count leading zeros. |
| `Arithmetic` | `div` | Divide. |
| `Arithmetic` | `divu` | Divide unsigned. | | `Arithmetic` | `divu` | Divide unsigned. |
| `Unconditional Jump` | `j` | Jump. | | `Unconditional Jump` | `j` | Jump. |
| `Unconditional Jump` | `jal` | Jump and link. | | `Unconditional Jump` | `jal` | Jump and link. |
...@@ -25,23 +25,28 @@ Supported 55 instructions: ...@@ -25,23 +25,28 @@ Supported 55 instructions:
| `Unconditional Jump` | `jr` | Jump register. | | `Unconditional Jump` | `jr` | Jump register. |
| `Data Transfer` | `lb` | Load byte. | | `Data Transfer` | `lb` | Load byte. |
| `Data Transfer` | `lbu` | Load byte unsigned. | | `Data Transfer` | `lbu` | Load byte unsigned. |
| `Data Transfer` | `lh` | Load halfword. |
| `Data Transfer` | `lhu` | Load halfword unsigned. |
| `Data Transfer` | `ll` | Load linked word. |
| `Data Transfer` | `lui` | Load upper immediate. | | `Data Transfer` | `lui` | Load upper immediate. |
| `Data Transfer` | `lw` | Load word. | | `Data Transfer` | `lw` | Load word. |
| `Data Transfer` | `lwl` | Load word left. |
| `Data Transfer` | `lwr` | Load word right. | | `Data Transfer` | `lwr` | Load word right. |
| `Data Transfer` | `mfhi` | Move from HI register. | | `Data Transfer` | `mfhi` | Move from HI register. |
| `Data Transfer` | `mflo` | Move from LO register. | | `Data Transfer` | `mflo` | Move from LO register. |
| `Data Transfer` | `move` | Move between registers. |
| `Data Transfer` | `movn` | Move conditional on not zero. | | `Data Transfer` | `movn` | Move conditional on not zero. |
| `Data Transfer` | `movz` | Move conditional on zero. | | `Data Transfer` | `movz` | Move conditional on zero. |
| `Data Transfer` | `mthi` | Move to HI register. |
| `Data Transfer` | `mtlo` | Move to LO register. | | `Data Transfer` | `mtlo` | Move to LO register. |
| `Arithmetic` | `mul` | Multiply (to produce a word result). | | `Arithmetic` | `mul` | Multiply (to produce a word result). |
| `Arithmetic` | `mult` | Multiply. |
| `Arithmetic` | `multu` | Multiply unsigned. | | `Arithmetic` | `multu` | Multiply unsigned. |
| `Arithmetic` | `negu` | Negate unsigned. | | `Logical` | `nor` | Bitwise NOR. |
| `No Op` | `nop` | No operation. |
| `Logical` | `not` | Bitwise NOT (pseudo-instruction in MIPS). |
| `Logical` | `or` | Bitwise OR. | | `Logical` | `or` | Bitwise OR. |
| `Logical` | `ori` | Bitwise OR immediate. | | `Logical` | `ori` | Bitwise OR immediate. |
| `Data Transfer` | `sb` | Store byte. | | `Data Transfer` | `sb` | Store byte. |
| `Data Transfer` | `sc` | Store conditional. |
| `Data Transfer` | `sh` | Store halfword. |
| `Logical` | `sll` | Shift left logical. | | `Logical` | `sll` | Shift left logical. |
| `Logical` | `sllv` | Shift left logical variable. | | `Logical` | `sllv` | Shift left logical variable. |
| `Comparison` | `slt` | Set on less than (signed). | | `Comparison` | `slt` | Set on less than (signed). |
...@@ -49,10 +54,13 @@ Supported 55 instructions: ...@@ -49,10 +54,13 @@ Supported 55 instructions:
| `Comparison` | `sltiu` | Set on less than immediate unsigned. | | `Comparison` | `sltiu` | Set on less than immediate unsigned. |
| `Comparison` | `sltu` | Set on less than unsigned. | | `Comparison` | `sltu` | Set on less than unsigned. |
| `Logical` | `sra` | Shift right arithmetic. | | `Logical` | `sra` | Shift right arithmetic. |
| `Logical` | `srav` | Shift right arithmetic variable. |
| `Logical` | `srl` | Shift right logical. | | `Logical` | `srl` | Shift right logical. |
| `Logical` | `srlv` | Shift right logical variable. | | `Logical` | `srlv` | Shift right logical variable. |
| `Arithmetic` | `sub` | Subtract. |
| `Arithmetic` | `subu` | Subtract unsigned. | | `Arithmetic` | `subu` | Subtract unsigned. |
| `Data Transfer` | `sw` | Store word. | | `Data Transfer` | `sw` | Store word. |
| `Data Transfer` | `swl` | Store word left. |
| `Data Transfer` | `swr` | Store word right. | | `Data Transfer` | `swr` | Store word right. |
| `Serialization` | `sync` | Synchronize shared memory. | | `Serialization` | `sync` | Synchronize shared memory. |
| `System Calls` | `syscall` | System call. | | `System Calls` | `syscall` | System call. |
......
...@@ -498,7 +498,7 @@ func execute(insn uint32, rs uint32, rt uint32, mem uint32) uint32 { ...@@ -498,7 +498,7 @@ func execute(insn uint32, rs uint32, rt uint32, mem uint32) uint32 {
switch fun { switch fun {
case 0x2: // mul case 0x2: // mul
return uint32(int32(rs) * int32(rt)) return uint32(int32(rs) * int32(rt))
case 0x20, 0x21: // clo case 0x20, 0x21: // clz, clo
if fun == 0x20 { if fun == 0x20 {
rs = ^rs rs = ^rs
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment