256 bytes of memory. 16 registers. 45+ instructions.
Built in Rust. Complete with assembler and TUI debugger.
All registers, Program Counter, Stack Pointer, and memory addresses are strictly 8-bit. No shortcuts.
Write .nca assembly files with labels, constants, strings, and raw data directives. Assembles to compact binary .ncb format.
Interactive debugger with register state visualization, memory view, instruction log, and breakpoint support — all in your terminal.
1-byte, 2-byte, and 3-byte instructions pack maximum program logic into 256 bytes of addressable space.
Modular CPU design with distinct Fetch, Decode, and Execute phases makes the architecture transparent and educational.
Stack overflow/underflow, division by zero, invalid operands — all represented as structured Rust error types with useful diagnostics.
NanoCore models a simple but complete von Neumann architecture. All components live in 256 bytes.
Stack grows downward from 0xFF. 22 bytes available. Program loads at configurable start address.
45+ instructions across 7 categories. Variable-length encoding (1–3 bytes).
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
HLT | — | 1 | Halt execution |
NOP | — | 1 | No operation |
JMP | addr | 2 | Unconditional jump to address |
JMPR | Rx | 2 | Jump to address in register |
JZ | addr | 2 | Jump if Zero flag set |
JNZ | addr | 2 | Jump if Zero flag clear |
CALL | addr | 2 | Call subroutine (push return addr) |
CALLR | Rx | 2 | Call subroutine via register |
RET | — | 1 | Return from subroutine |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
LDI | Rd, imm8 | 3 | Load immediate value into register |
LDA | Rd, addr | 3 | Load from memory address into register |
LDR | Rd, Rs | 2 | Load from address in Rs into Rd |
MOV | Rd, Rs | 2 | Copy register Rs into Rd |
STORE | addr, Rs | 3 | Store register into memory address |
STR | Rd, Rs | 2 | Store Rs at address held in Rd |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
ADD | Rd, Rs | 2 | Rd = Rd + Rs |
ADDI | Rd, imm8 | 3 | Rd = Rd + imm8 |
SUB | Rd, Rs | 2 | Rd = Rd − Rs |
SUBI | Rd, imm8 | 3 | Rd = Rd − imm8 |
INC | Rd | 2 | Rd = Rd + 1 |
DEC | Rd | 2 | Rd = Rd − 1 |
MUL | Rd, Rs | 2 | Rd = Rd × Rs |
MULI | Rd, imm8 | 3 | Rd = Rd × imm8 |
DIV | Rd, Rs | 2 | Rd = Rd ÷ Rs |
DIVI | Rd, imm8 | 3 | Rd = Rd ÷ imm8 |
MOD | Rd, Rs | 2 | Rd = Rd mod Rs |
MODI | Rd, imm8 | 3 | Rd = Rd mod imm8 |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
AND | Rd, Rs | 2 | Rd = Rd & Rs |
OR | Rd, Rs | 2 | Rd = Rd | Rs |
XOR | Rd, Rs | 2 | Rd = Rd ^ Rs |
NOT | Rd | 2 | Rd = ~Rd |
CMP | Rd, Rs | 2 | Set flags from Rd − Rs (no store) |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
SHL | Rd, Rs | 2 | Logical shift left |
SHR | Rd, Rs | 2 | Logical shift right |
ROL | Rd, Rs | 2 | Rotate left |
ROR | Rd, Rs | 2 | Rotate right |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
PUSH | Rs | 2 | Push register onto stack |
POP | Rd | 2 | Pop top of stack into register |
| Mnemonic | Operands | Bytes | Description |
|---|---|---|---|
IN | Rd | 2 | Read a byte from stdin into Rd |
PRINT | Rs | 2 | Print register value as ASCII char |
NanoCore Assembly (.nca) is a simple, human-readable format. Write programs, assemble to binary, run or debug them.
.CONST name value
Define a named constant. Use the name anywhere an immediate value is expected.
.DB byte [byte ...]
Embed raw byte literals directly into the program at the current position.
.STRING "text"
Embed a null-terminated ASCII string into the program at the current position.
Three binaries — emulator, assembler, and debugger.
Step through instructions, inspect registers and memory live, and set breakpoints — all inside your terminal.
Three ways to install NanoCore.