Projects/knight/basic ISA
The basic instruction set of the Knight platform is based on the Rook processor which implements the following on all processors that support its ISA.
All data is stored in big-endian with MSB bit numbering and is assumed aligned unless specified otherwise
[Must be implemented on all processors]
Registers:
1 supplementary capability register [SCID] set at a size of the GPR and its values are fixed in hardware.
1 Program Counter [PC] set at a size determined by the SCID register. Its values can be indirectly set/changed by software.
64 (Dawn) or 16 (Lilith) unified General purpose registers [GPR] set at a size determined by the SCID register. Its values can be both directly and indirectly set/changed by software.
1 Address space number register [ASN] set at a size determined by the SCID register. Its values can only be directly set by software running in supervisor mode.
Thus assembly written for Lilith will run identically on Dawn after being assembled to a native binary, Dawn assembly will work on Lilith if R16 through R63 are not used;
Base system Instructions [MUST BE IMPLEMENTED]:
Any of the GPR can be used as a condition register
| Condition flags |
| C |
| B |
| O |
| GT |
| EQ |
| LT |
| Category | Name | Description |
| Add | ADD | signed add (without carry) |
| ADD.CI | signed add plus carry bit | |
| ADD.CO | signed add, propagate carry out | |
| ADD.CIO | signed add plus carry bit, propagate carry out | |
| ADDI | signed add immediate (without carry) | |
| ADDU | unsigned add (without carry) | |
| ADDU.CI | unsigned add plus carry bit | |
| ADDU.CO | unsigned add, propagate carry out | |
| ADDU.CIO | unsigned add plus carry bit, propagate carry out | |
| ADDUI | unsigned add immediate (without carry) | |
| Subtract | SUB | signed subtract (without borrow) |
| SUB.BI | signed subtract and use borrow in | |
| SUB.BO | signed subtract, propagate borrow out | |
| SUB.BIO | signed subtract and use borrow in, propagate borrow out | |
| SUBI | signed subtract immediate (without borrow) | |
| SUBU | unsigned subtract (without borrow) | |
| SUBU.BI | unsigned subtract and use borrow in | |
| SUBU.BO | unsigned subtract, propagate borrow out | |
| SUBU.BIO | unsigned subtract and use borrow in, propagate borrow out | |
| SUBUI | unsigned subtract immediate (without borrow) | |
| Multiply | MUL | signed integer multiply, returns lower half |
| MULH | signed integer multiply, returns upper half | |
| MULU | unsigned integer multiply, returns lower half | |
| MULUH | unsigned integer multiply, returns upper half | |
| MULTIPLY | R1 := MUL R3 R4 & R2 := MULH R3 R4 | |
| MULTIPLYU | R1 := MULU R3 R4 & R2 := MULUH R3 R4 | |
| Divide | DIV | signed integer divide, returns upper half |
| MOD | signed integer divide, returns lower half | |
| DIVU | unsigned integer divide, returns upper half | |
| MODU | unsigned integer divide, returns lower half | |
| DIVIDE | R1 := DIV R3 R4 & R2 := MOD R3 R4 | |
| DIVIDEU | R1 := DIVU R3 R4 & R2 := MODU R3 R4 | |
| Unique | MUX | R1 := (R3 ∧ ¬R2) v (R4 ∧ R2) or a 2-to-1 multiplexer |
| NMUX | R1 := (R3 ∧ R2) v (R4 ∧ ¬R2) or a 2-to-1 not multiplexer | |
| EXCEPTION | rollback cpu to before exception instruction, signal invalid instruction exception. All previously unallocated opcodes resolve to this. 1111...1111 or 0000...0000 are the preferred opcodes used for intensional exceptions or error barriers | |
| NEG | negate a signed integer | |
| ABS | absolute value of a signed integer | |
| NABS | negative absolute value of a signed integer | |
| MAX | returns largest of two signed integers | |
| MAXU | returns largest of two unsigned integers | |
| MIN | returns smallest of two signed integers | |
| MINU | returns smallest of two unsigned integers | |
| SORT | R1 := MAX R3 R4 & R2 := MIN R3 R4 | |
| SORTU | R1 := MAXU R3 R4 & R2 := MINU R3 R4 | |
| PACK | Pack bits in R2 into R1 masked by R3 | |
| UNPACK | Unpack bits from R2 into R1 masked by R3 | |
| PACK8 | pack signed integer into bottom 8bits of register, ignoring overload | |
| PACK8.CO | pack signed integer into bottom 8bits of register, setting overload bit if exceeds bounds | |
| PACK8U | pack unsigned integer into bottom 8bits of register, ignoring overload | |
| PACK8U.CO | pack unsigned integer into bottom 8bits of register, setting overload bit if exceeds bounds | |
| MPQ | Converse nonimplication | |
| LPQ | Material nonimplication | |
| CPQ | Material implication | |
| BPQ | Converse implication | |
| Shift and rotate | SAL | shift arithmetically left |
| SAR | shift arithmetically right | |
| SL0 | shift left logically fill with zeros | |
| SR0 | shift right logically fill with zeros | |
| SL1 | shift left logically fill with ones | |
| SR1 | shift right logically fill with ones | |
| ROL | circular rotate left | |
| ROR | circular rotate right | |
| DROL | double circular rotate left | |
| DROR | double circular rotate right | |
| Register movement | SWAP | swaps the contents of two registers |
| COPY | copies the contents of one register into another | |
| MOVE | Moves the contents of one register into another and clears the contents to ALL Zeros | |
| READSCID | Copies SCID values into register | |
| READPC | Copies PC into register | |
| Load | LOAD | Load the number of bits the size of the GPR |
| LOAD8 | Load 8 bits signed | |
| LOAD8U | Load 8 bits unsigned | |
| Store | STORE | Store the number of bits the size of the GPR |
| STORE8 | Store the bottom 8 bits of a register | |
| Logical | AND | Bitwise and |
| OR | Bitwise or | |
| XOR | Bitwise xor | |
| NAND | Bitwise nand | |
| NOR | Bitwise nor | |
| XNOR | Bitwise xnor | |
| NOT | Bitwise not | |
| IS | Bitwise IS, shares same opcode with copy | |
| FALSE | Bitwise sets register to 0000...0000 | |
| TRUE | Bitwise sets register to 1111...1111 | |
| CMP | signed comparison | |
| CMPI | signed comparison to immediate | |
| CMPU | unsigned comparison | |
| CMPUI | unsigned comparison to immediate | |
| Jump | JUMP | Always jumps to destination |
| JUMP.C | Jumps to destination if carry bit set | |
| JUMP.B | Jumps to destination if borrow bit set | |
| JUMP.O | Jumps to destination if overload bit set | |
| JUMP.G | Jumps to destination if greater than bit set | |
| JUMP.GE | Jumps to destination if greater than or equal bit set | |
| JUMP.E | Jumps to destination if equal bit set | |
| JUMP.NE | Jumps to destination if equal bit not set | |
| JUMP.LE | Jumps to destination if less than or equal bit set | |
| JUMP.L | Jumps to destination if less than bit set | |
| JUMP.Z | Jumps to destination if register is equal to symmetric complement's ZERO | |
| JUMP.NZ | Jumps to destination if register is not equal to symmetric complement's ZERO | |
| JUMP.N | Jumps to destination if register is equal to symmetric complement's NULL | |
| JUMP.NN | Jumps to destination if register is not equal to symmetric complement's NULL | |
| Coroutine | JSR_COROUTINE | Always branches to destination |
| Branch | BRANCH | Always branches to destination and pushes current PC onto selected register |
Added with 16 bit extension
| Category | Name | Description |
| Load | LOAD16 | Load 16 bits signed |
| LOAD16.U | Load 16 bits signed unaligned | |
| LOAD16U | Load 16 bits unsigned | |
| LOAD16U.U | Load 16 bits unsigned unaligned | |
| Store | STORE16 | Store the bottom 16 bits of a register |
| STORE16.U | Store the bottom 16 bits of a register unaligned | |
| Pack | PACK16 | pack signed integer into bottom 16bits of register, ignoring overload |
| PACK16.CO | pack signed integer into bottom 16bits of register, setting overload bit if exceeds bounds | |
| PACK16U | pack unsigned integer into bottom 16bits of register, ignoring overload | |
| PACK16U.CO | pack unsigned integer into bottom 16bits of register, setting overload bit if exceeds bounds |
Added with 32 bit extension
| Category | Name | Description |
| Load | LOAD32 | Load 32 bits signed |
| LOAD32.U | Load 32 bits signed unaligned | |
| LOAD32U | Load 32 bits unsigned | |
| LOAD32U.U | Load 32 bits unsigned unaligned | |
| Store | STORE32 | Store the bottom 32 bits of a register |
| STORE32.U | Store the bottom 32 bits of a register unaligned | |
| Pack | PACK32 | pack signed integer into bottom 32bits of register, ignoring overload |
| PACK32.CO | pack signed integer into bottom 32bits of register, setting overload bit if exceeds bounds | |
| PACK32U | pack unsigned integer into bottom 32bits of register, ignoring overload | |
| PACK32U.CO | pack unsigned integer into bottom 32bits of register, setting overload bit if exceeds bounds |
Added with 64 bit extension
| Category | Name | Description |
| Load | LOAD64 | Load 64 bits signed |
| LOAD64.U | Load 64 bits signed unaligned | |
| LOAD64U | Load 64 bits unsigned | |
| LOAD64U.U | Load 64 bits unsigned unaligned | |
| Store | STORE64 | Store the bottom 64 bits of a register |
| STORE64.U | Store the bottom 64 bits of a register unaligned | |
| Pack | PACK64 | pack signed integer into bottom 64bits of register, ignoring overload |
| PACK64.CO | pack signed integer into bottom 64bits of register, setting overload bit if exceeds bounds | |
| PACK64U | pack unsigned integer into bottom 64bits of register, ignoring overload | |
| PACK64U.CO | pack unsigned integer into bottom 64bits of register, setting overload bit if exceeds bounds |
Added with 128 bit extension
| Category | Name | Description |
| Load | LOAD128 | Load 128 bits signed |
| LOAD128.U | Load 128 bits signed unaligned | |
| LOAD128U | Load 128 bits unsigned | |
| LOAD128U.U | Load 128 bits unsigned unaligned | |
| Store | STORE128 | Store the bottom 128 bits of a register |
| STORE128.U | Store the bottom 128 bits of a register unaligned | |
| Pack | PACK128 | pack signed integer into bottom 128bits of register, ignoring overload |
| PACK128.CO | pack signed integer into bottom 128bits of register, setting overload bit if exceeds bounds | |
| PACK128U | pack unsigned integer into bottom 128bits of register, ignoring overload | |
| PACK128U.CO | pack unsigned integer into bottom 128bits of register, setting overload bit if exceeds bounds |
Dawn Instruction formats:
| Name | |||||
| 4OP | 10 bit opcode | 6 bit GPR1 | 6 bit GPR2 | 6 bit GPR3 | 6 bit GPR4 |
| 3OP | 10 bit opcode | 6 bit GPR1 | 6 bit GPR2 | 6 bit GPR3 | |
| 2OP | 10 bit opcode | 6 bit GPR1 | 6 bit GPR2 | ||
| 2OPI | 10 bit opcode | 6 bit GPR1 | 6 bit GPR2 | ||
| 1OP | 10 bit opcode | 6 bit GPR1 | |||
| 1OPI | 10 bit opcode | 6 bit GPR1 | |||
| 0OPI | 10 bit opcode | ||||
| HAL_CODE | 10 bit opcode |
Lilith Instruction formats:
| Name | |||||||
| 4OP | 8 bit opcode | 8 bit XOP | 4 bit GPR1 | 4 bit GPR2 | 4 bit GPR3 | ||
| 3OP | 8 bit opcode | 12 bit XOP | 4 bit GPR1 | 4 bit GPR2 | |||
| 2OP | 8 bit opcode | 16 bit XOP | 4 bit GPR1 | ||||
| 2OPI | 8 bit opcode | 4 bit GPR1 | 4 bit GPR2 | ||||
| 1OP | 8 bit opcode | 20 bit XOP | |||||
| 1OPI | 8 bit opcode | 4 bit GPR1 | |||||
| 0OPI | 8 bit opcode | ||||||
| HAL_CODE | 8 bit opcode | ||||||