Five bits.
Thirty-two opcodes.
The opcode field is five bits wide, producing thirty-two possible instructions. All thirty-two are defined, so the set is closed: there is no reserved space, no extension mechanism, and no undefined opcode for a program to reach. The architecture is fixed. Programs are data.
Two omissions are deliberate. There is no SWAP, because three exclusive disjunctions exchange two registers without a temporary. There are no input or output instructions, because both ports are mapped into the store and a load already reads.
This is the STRATA-16 R0 architecture specification. It is implemented by the machine in this page and by the independent model used in CHECK 02. It is not a deployed instruction set.
A word is canonical when the seven reserved bits are zero and every field the instruction does not read is zero. Exactly one encoding exists for any instruction, which is what makes one machine’s transition comparable with another’s without a normalisation step. A non-canonical word raises a fault at fetch.
- TRANSFER
- 2
- MEMORY
- 4
- STACK
- 2
- ARITHMETIC
- 7
- LOGIC
- 4
- SHIFT
- 3
- COMPARE
- 2
- CONTROL
- 8
| OPCODE | HEX | MNEMONIC | OPERANDS | FLAGS | Φ |
|---|---|---|---|---|---|
| 00000 | 00 | — | — | 3 | |
| 00001 | 01 | Rd, Rs | — | 4 | |
| 00010 | 02 | Rd, #imm | — | 4 | |
| 00011 | 03 | Rd, [addr] | — | 5 | |
| 00100 | 04 | Rd, [Rs] | — | 5 | |
| 00101 | 05 | [addr], Rs | — | 5 | |
| 00110 | 06 | [Rd], Rs | — | 5 | |
| 00111 | 07 | Rs | — | 5 | |
| 01000 | 08 | Rd | — | 5 | |
| 01001 | 09 | Rd, Rs | ZNCV | 5 | |
| 01010 | 0A | Rd, #imm | ZNCV | 5 | |
| 01011 | 0B | Rd, Rs | ZNCV | 5 | |
| 01100 | 0C | Rd, #imm | ZNCV | 5 | |
| 01101 | 0D | Rd | ZNCV | 5 | |
| 01110 | 0E | Rd | ZNCV | 5 | |
| 01111 | 0F | Rd | ZNCV | 5 | |
| 10000 | 10 | Rd, Rs | ZN | 5 | |
| 10001 | 11 | Rd, Rs | ZN | 5 | |
| 10010 | 12 | Rd, Rs | ZN | 5 | |
| 10011 | 13 | Rd | ZN | 5 | |
| 10100 | 14 | Rd, #n | ZNC | 5 | |
| 10101 | 15 | Rd, #n | ZNC | 5 | |
| 10110 | 16 | Rd, #n | ZNC | 5 | |
| 10111 | 17 | Rd, Rs | ZNCV | 5 | |
| 11000 | 18 | Rd, #imm | ZNCV | 5 | |
| 11001 | 19 | addr | — | 5 | |
| 11010 | 1A | addr | — | 5 | |
| 11011 | 1B | addr | — | 5 | |
| 11100 | 1C | addr | — | 5 | |
| 11101 | 1D | addr | — | 5 | |
| 11110 | 1E | — | — | 5 | |
| 11111 | 1F | — | — | 3 |
ADDRd, Rs
00912000 · ADD R1, R2Adds the source register to the destination register.
- RDR1
- RSR2
- IMM/ADDRzero
- RSV 31:25must be zero
- FETCHRUNS
- DECODERUNS
- EXECUTERUNS
- WRITEBACKRUNS
- COMMITRUNS
5 PHASES
UNLISTED FLAGS RETAIN THEIR VALUE
| OPCODE | MNEMONIC | OPERANDS | CLASS | FLAGS | Φ | DESCRIPTION |
|---|---|---|---|---|---|---|
| 00000 | NOP | — | CONTROL | — | 3 | No architectural state changes except the program counter. |
| 00001 | MOV | Rd, Rs | TRANSFER | — | 4 | Copies the source register into the destination register. |
| 00010 | LDI | Rd, #imm | TRANSFER | — | 4 | Loads a zero-extended twelve-bit immediate into the destination register. |
| 00011 | LOAD | Rd, [addr] | MEMORY | — | 5 | Reads a sixteen-bit word from an absolute RAM address into the destination register. |
| 00100 | LDR | Rd, [Rs] | MEMORY | — | 5 | Reads a word from the RAM address held in the source register. |
| 00101 | STORE | [addr], Rs | MEMORY | — | 5 | Writes the source register to an absolute RAM address. |
| 00110 | STR | [Rd], Rs | MEMORY | — | 5 | Writes the source register to the RAM address held in the destination register. |
| 00111 | PUSH | Rs | STACK | — | 5 | Decrements the stack pointer and writes the source register to the stack page. |
| 01000 | POP | Rd | STACK | — | 5 | Reads a word from the stack page into the destination register and increments the stack pointer. |
| 01001 | ADD | Rd, Rs | ARITHMETIC | ZNCV | 5 | Adds the source register to the destination register. |
| 01010 | ADDI | Rd, #imm | ARITHMETIC | ZNCV | 5 | Adds a zero-extended twelve-bit immediate to the destination register. |
| 01011 | SUB | Rd, Rs | ARITHMETIC | ZNCV | 5 | Subtracts the source register from the destination register. |
| 01100 | SUBI | Rd, #imm | ARITHMETIC | ZNCV | 5 | Subtracts a zero-extended twelve-bit immediate from the destination register. |
| 01101 | INC | Rd | ARITHMETIC | ZNCV | 5 | Adds one to the destination register. |
| 01110 | DEC | Rd | ARITHMETIC | ZNCV | 5 | Subtracts one from the destination register. |
| 01111 | NEG | Rd | ARITHMETIC | ZNCV | 5 | Replaces the destination register with its two's complement. |
| 10000 | AND | Rd, Rs | LOGIC | ZN | 5 | Bitwise conjunction of the destination and source registers. |
| 10001 | OR | Rd, Rs | LOGIC | ZN | 5 | Bitwise disjunction of the destination and source registers. |
| 10010 | XOR | Rd, Rs | LOGIC | ZN | 5 | Bitwise exclusive disjunction of the destination and source registers. |
| 10011 | NOT | Rd | LOGIC | ZN | 5 | Bitwise complement of the destination register. |
| 10100 | SHL | Rd, #n | SHIFT | ZNC | 5 | Shifts the destination register left by a four-bit distance. The last bit shifted out enters carry. |
| 10101 | SHR | Rd, #n | SHIFT | ZNC | 5 | Logical right shift. Vacated bits are filled with zero. |
| 10110 | ASR | Rd, #n | SHIFT | ZNC | 5 | Arithmetic right shift. Vacated bits are filled with the sign bit. |
| 10111 | CMP | Rd, Rs | COMPARE | ZNCV | 5 | Subtracts the source from the destination, writing flags and discarding the result. |
| 11000 | CMPI | Rd, #imm | COMPARE | ZNCV | 5 | Compares the destination register against a twelve-bit immediate. |
| 11001 | JMP | addr | CONTROL | — | 5 | Unconditional transfer of control to a ROM address. |
| 11010 | JMZ | addr | CONTROL | — | 5 | Transfers control if the zero flag is set. |
| 11011 | JNZ | addr | CONTROL | — | 5 | Transfers control if the zero flag is clear. |
| 11100 | JMN | addr | CONTROL | — | 5 | Transfers control if the negative flag is set. |
| 11101 | CALL | addr | CONTROL | — | 5 | Pushes the return address onto the stack page and transfers control. |
| 11110 | RET | — | CONTROL | — | 5 | Pops a return address from the stack page into the program counter. |
| 11111 | HALT | — | CONTROL | — | 3 | Stops the sequencer. The architectural state is retained and remains readable. |
Write to it.
Step it.
The editor below assembles with the same assembler the reference programs use, and runs on the same machine every other panel on this page is watching. Errors are reported with their line and their reason; a program that assembles will execute.
STEP retires exactly one instruction. RUN supplies edges at the selected rate. RESET returns the machine to cycle zero with a cleared store, which is the only way back: there is no undo, because a state transition is not reversible.
| ADDR | WORD | DISASSEMBLY | SOURCE |
|---|---|---|---|
| 000 | 0021002A | LDI R1, #42 | LDI R1, #42 |
| 001 | 00220011 | LDI R2, #17 | LDI R2, #17 |
| 002 | 00912000 | ADD R1, R2 | ADD R1, R2 ; R1 ← 0x00 |
| 003 | 00501020 | STORE [0x020], R1 | STORE [0x020], R1 |
| 004 | 00330020 | LOAD R3, [0x020] | LOAD R3, [0x020] |
| 005 | 0183003B | CMPI R3, #59 | CMPI R3, #59 |
| 006 | 01A00008 | JMZ 0x008 | JMZ done |
| 007 | 002400FF | LDI R4, #255 | LDI R4, #0x0FF ; not reach |
| 008 | 01F00000 | HALT | done: HALT |
| # | BLOCK | PC | OP | OPERANDS | RESULT | Φ |
|---|---|---|---|---|---|---|
| NO TRANSITIONS COMMITTED SINCE RESET | ||||||
| NO TRANSITIONS COMMITTED SINCE RESET | ||||||
| NO TRANSITIONS COMMITTED SINCE RESET | ||||||
| PROGRAM | CLOCK | EXERCISES | NOTE |
|---|---|---|---|
| ACCUMULATE | CONTINUOUS | MEMORY · ARITHMETIC · COMPARE · BRANCH | Reads a word from RAM, adds a constant, writes it back, and repeats. The canonical resident program. |
| DECIDE | CONTINUOUS | PORT IN · PORT OUT · COMPARE · BRANCH | Classifies the input port into three bands and drives the output port. One decision per pass. |
| MULTIPLY | HALTS | CALL · RET · SHIFT · LOGIC · STACK | Shift and add multiplication in a subroutine. There is no multiplier in the netlist. |
| SEQUENCE | HALTS | REGISTER INDIRECT · MEMORY · ARITHMETIC | Writes sixteen words of an additive sequence through a register pointer. |
| STACK WALK | HALTS | PUSH · POP · CALL · RET | Exercises the stack page and one level of call depth. |
| ECHO | CONTINUOUS | PORT IN · PORT OUT · SHIFT | Doubles the input port into the output port. The boundary is one byte wide in each direction. |