Skip to content

Appendix B: Complete Instruction Set Reference

This appendix provides the complete instruction set reference for the Minichain virtual machine. Each instruction includes:

  • Opcode number (hexadecimal byte value)
  • Assembly syntax (how to write it in assembly code)
  • Effect (what it does to VM state)
  • Gas cost (computational cost)
  • Usage examples and tips

Control the program counter and execution flow.

OpcodeInstructionSyntaxEffectGas
0x00HALTHALTStop execution successfully0
0x01NOPNOPDo nothing (no operation)0
0x02JUMPJUMP RtargetUnconditional jump: PC = R[target]8
0x03JUMPIJUMPI Rcond, RtargetConditional jump: if R[cond] != 0, PC = R[target]8
0x04CALLCALL RtargetCall subroutine: push return address to R14, jump to R[target]700
0x05RETRETReturn from subroutine: jump to address in R148
0x0FREVERTREVERTAbort execution with error0

Perform mathematical operations on register values.

OpcodeInstructionSyntaxEffectGas
0x10ADDADD Rdst, Rs1, Rs2R[dst] = R[s1] + R[s2] (wrapping)2
0x11SUBSUB Rdst, Rs1, Rs2R[dst] = R[s1] - R[s2] (wrapping)2
0x12MULMUL Rdst, Rs1, Rs2R[dst] = R[s1] * R[s2] (wrapping)3
0x13DIVDIV Rdst, Rs1, Rs2R[dst] = R[s1] / R[s2] (unsigned, traps if Rs2 = 0)5
0x14MODMOD Rdst, Rs1, Rs2R[dst] = R[s1] % R[s2] (unsigned modulo)5
0x15ADDIADDI Rdst, Rsrc, immR[dst] = R[src] + imm (add immediate)2

Perform bit-level operations.

OpcodeInstructionSyntaxEffectGas
0x20ANDAND Rdst, Rs1, Rs2R[dst] = R[s1] & R[s2] (bitwise AND)2
0x21OROR Rdst, Rs1, Rs2R[dst] = R[s1] | R[s2] (bitwise OR)2
0x22XORXOR Rdst, Rs1, Rs2R[dst] = R[s1] ^ R[s2] (bitwise XOR)2
0x23NOTNOT Rdst, RsrcR[dst] = ~R[src] (bitwise NOT)2
0x24SHLSHL Rdst, Rs1, Rs2R[dst] = R[s1] << R[s2] (logical left shift)5
0x25SHRSHR Rdst, Rs1, Rs2R[dst] = R[s1] >> R[s2] (logical right shift)5

Compare values and produce boolean results (1 for true, 0 for false).

OpcodeInstructionSyntaxEffectGas
0x30EQEQ Rdst, Rs1, Rs2R[dst] = (R[s1] == R[s2]) ? 1 : 03
0x31NENE Rdst, Rs1, Rs2R[dst] = (R[s1] != R[s2]) ? 1 : 03
0x32LTLT Rdst, Rs1, Rs2R[dst] = (R[s1] < R[s2]) ? 1 : 0 (unsigned)3
0x33GTGT Rdst, Rs1, Rs2R[dst] = (R[s1] > R[s2]) ? 1 : 0 (unsigned)3
0x34LELE Rdst, Rs1, Rs2R[dst] = (R[s1] <= R[s2]) ? 1 : 03
0x35GEGE Rdst, Rs1, Rs2R[dst] = (R[s1] >= R[s2]) ? 1 : 03
0x36ISZEROISZERO Rdst, RsrcR[dst] = (R[src] == 0) ? 1 : 03

Access temporary linear memory. Memory is fast and cheap, but data is lost when execution ends.

OpcodeInstructionSyntaxEffectGas
0x40LOAD8LOAD8 Rdst, RaddrR[dst] = Memory[R[addr]] (1 byte)3
0x41LOAD64LOAD64 Rdst, RaddrR[dst] = Memory[R[addr]] (8 bytes, little-endian)3
0x42STORE8STORE8 Raddr, RsrcMemory[R[addr]] = R[src] (1 byte)3
0x43STORE64STORE64 Raddr, RsrcMemory[R[addr]] = R[src] (8 bytes, little-endian)3
0x44MSIZEMSIZE RdstR[dst] = size of memory in bytes2
0x45MCOPYMCOPY Rdst, Rsrc, Rlenmemcpy(R[dst], R[src], R[len])3 + len

C.6 Storage Instructions (Disk Operations)

Section titled “C.6 Storage Instructions (Disk Operations)”

Access persistent contract storage. Storage is slow and expensive, but data persists across transactions.

OpcodeInstructionSyntaxEffectGas
0x50SLOADSLOAD Rdst, RkeyR[dst] = Storage[R[key]] (persistent, 32-byte slot)100
0x51SSTORESSTORE Rkey, RvalueStorage[R[key]] = R[value] (persistent, 32-byte slot)5,000 or 20,000

Load constants and move data between registers.

OpcodeInstructionSyntaxEffectGas
0x70LOADILOADI Rdst, imm64R[dst] = imm64 (load 64-bit constant)2
0x71MOVMOV Rdst, RsrcR[dst] = R[src] (register copy)2

Query the execution environment and blockchain state.

OpcodeInstructionSyntaxEffectGas
0x80CALLERCALLER RdstR[dst] = caller's address (as u64, truncated)2
0x81CALLVALUECALLVALUE RdstR[dst] = value sent with this call2
0x82ADDRESSADDRESS RdstR[dst] = this contract's address2
0x83BLOCKNUMBERBLOCKNUMBER RdstR[dst] = current block number2
0x84TIMESTAMPTIMESTAMP RdstR[dst] = current block timestamp2
0x85GASGAS RdstR[dst] = remaining gas2

Output values for debugging and logging.

OpcodeInstructionSyntaxEffectGas
0xF0LOGLOG RsrcLog R[src] value (appears in execution trace)2

Complete opcode listing sorted by category and number:

OpcodeMnemonicGas
0x00HALT0
0x01NOP0
0x02JUMP8
0x03JUMPI8
0x04CALL700
0x05RET8
0x0FREVERT0
OpcodeMnemonicGas
0x10ADD2
0x11SUB2
0x12MUL3
0x13DIV5
0x14MOD5
0x15ADDI2
OpcodeMnemonicGas
0x20AND2
0x21OR2
0x22XOR2
0x23NOT2
0x24SHL5
0x25SHR5
OpcodeMnemonicGas
0x30EQ3
0x31NE3
0x32LT3
0x33GT3
0x34LE3
0x35GE3
0x36ISZERO3
OpcodeMnemonicGas
0x40LOAD83
0x41LOAD643
0x42STORE83
0x43STORE643
0x44MSIZE2
0x45MCOPY3+N
OpcodeMnemonicGas
0x50SLOAD100
0x51SSTORE5K-20K
OpcodeMnemonicGas
0x70LOADI2
0x71MOV2
OpcodeMnemonicGas
0x80CALLER2
0x81CALLVALUE2
0x82ADDRESS2
0x83BLOCKNUMBER2
0x84TIMESTAMP2
0x85GAS2
OpcodeMnemonicGas
0xF0LOG2

The Minichain VM instruction set includes:

  • 43 instructions across 9 categories
  • Simple encoding (1-10 bytes per instruction)
  • Register-based (16 general-purpose registers)
  • Gas metered (prevents infinite loops)
  • Memory + Storage (RAM vs Disk model)
  1. Minimal but complete: Only essential instructions, no redundancy
  2. Ethereum-inspired: Familiar to Solidity/EVM developers
  3. Register-based: More efficient than stack-based (fewer instructions needed)
  4. Learning-focused: Simple enough to understand completely

Counter pattern (most common smart contract):

LOADI R0, 0 ; Storage key 0
SLOAD R1, R0 ; Load counter
LOADI R2, 1 ; Constant 1
ADD R1, R1, R2 ; Increment
SSTORE R0, R1 ; Save back

Access control pattern:

CALLER R0 ; Get caller
LOADI R1, OWNER_ADDR ; Load owner
EQ R2, R0, R1 ; Check equality
JUMPI R2, authorized ; If equal, continue
REVERT ; Otherwise, abort

Loop pattern:

loop:
; ... loop body ...
LT R5, R0, R10 ; R0 < R10?
JUMPI R5, loop ; If yes, continue
; ... after loop ...

For implementation details, see: