Skip to content

ISA Reference

Alex edited this page Aug 1, 2026 · 9 revisions

RR16X Instruction Semantics Common execution model

For every instruction:

CPU fetches instruction word from: ProgramEAM:PC Decode instruction. Fetch encoded immediates, if present: Immediate X Immediate Y

in that order.

Execute instruction. Increment PC. PC = PC + instruction_length

Note:

PC increment occurs after execution. Branches and jumps modify PC during execution; final PC increment behavior must be resolved per instruction. Undefined opcodes execute as NIL. Immediate fetch happens before any EAM modification caused by the instruction. Instruction Classes ALU Instructions

Format:

OP Rd, Rx, Ry

or

OP Rd, Rx, Imm

Registers:

Rd = destination Rx/Ry = sources

No flags are modified.

ADD

Opcode:

0x1000

Semantics:

Rd = Rx + Ry

or

Rd = Rx + Imm

Overflow:

ignored wraps modulo 65536 SUB

Opcode:

0x2000

Semantics:

Rd = Rx - Ry

or

Rd = Rx - Imm

No flags.

AND

Opcode:

0x3000 Rd = Rx & Ry OR

Opcode:

0x4000 Rd = Rx | Ry NOT

Opcode:

0x5000 Rd = ~Rx XOR

Opcode:

0x6000 Rd = Rx ^ Ry SHL

Opcode:

0x7000 Rd = Rx << amount

Shift amount:

lower 4 bits of operand

Result:

16-bit wrap SHR

Opcode:

0x8000 Rd = Rx >> amount

Logical shift.

Memory Instructions LDM

Opcode:

0x9000

Format:

LDM Rd, Address, Offset/Register

Semantics:

Effective address:

EA = DataEAM:Address

Read:

Rd = Memory[EA]

Peripheral reads may have side effects.

STM

Opcode:

0xA000

Format:

STM Address, Rx

Semantics:

Memory[DataEAM:Address] = Rx

Peripheral writes may have side effects.

Jump Register Instructions STJ

Opcode:

0xB000

Semantics:

JR = immediate address

Only JR changes.

Does not modify PC.

Does not consume JR.

Branch Instructions

No flags exist.

Branches directly compare operands.

Signed comparison

Example:

JLT address, Rx, Ry

Semantics:

if ((int16_t)Rx < (int16_t)Ry) PC = JR OTHER COMPARISONS AVAILABLE: JEQ (==) JLE (<=) JGT (>) JNE (!=) JGE (>=) JMP (unconditional) Otherwise:

PC continues normally Unsigned comparison

Example:

JLT.U

Uses:

(uint16_t)

comparison. OTHER UNSIGNED COMPARISONS AVAILABLE: JEQ.U JLE.U JGT.U JNE.U JGE.U Jump JMP

Opcode:

0xC700

Semantics:

PC = JR

JR unchanged.

Call CAL

Opcode:

0xD000

Semantics:

Push:

(ProgramEAM << 16) | PC

onto hardware call stack.

Then:

PC = target

Bank handling:

Assembler inserts EAM changes as required.

Return RET

Opcode:

0xE000

Semantics:

Pop:

return_address

Restore:

ProgramEAM = return_address >> 16 PC = return_address & 0xFFFF

RET also enables interrupts.

RET.C

Opcode:

0xE800

Semantics:

Same return behavior as RET.

Additionally:

InterruptEnable = false Halt HLT

Opcode:

0xF000

CPU enters halted state.

Wake behavior:

Implementation-defined.

NIL

Opcode:

0xC000

Semantics:

No operation.

However:

May consume encoded immediates. Maximum: Immediate X Immediate Y

Clone this wiki locally