Skip to main content

Instruction Set

Applies to both RGB lines

The two lines run different AluVM versions with different opcodes; pick your line below. See Two RGB lines.

This page lists the instructions that actually exist at the pinned versions. Neither line has load/store memory instructions, push/pop or Merkle-proof opcodes, and only Line B's vts checks a signature. For the VM model (registers, libraries, complexity), see the AluVM overview.

rgb-aluvm 0.11.1​

Line B runs rgb-aluvm 0.11.1, a fork of AluVM 0.11, with the RGB ISA extension from rgb-consensus 0.11.1. The full instruction enum is in rgb-aluvm src/isa/instr.rs; opcodes are in src/isa/opcodes.rs.

Control flow​

OpcodeMnemonicEffect
0x00failStop with st0 = false
0x01testStop if st0 is false, otherwise do nothing
0x02jmp offsetJump; increments cy0
0x03jif offsetJump if st0 is true; increments cy0
0x04routine offsetCall a subroutine in the same library; increments cy0, pushes the return site to cs0
0x05call lib:offsetCall another library; increments cy0 and cp0, pushes the return site
0x06exec lib:offsetJump to another library with no return; doesn't touch cy0 or the call stack
0x07retReturn to the site on top of cs0; doesn't change cy0
0xFFnopNothing

cy0 is a u16. A script can make at most 2^16 jumps. Control-flow instructions cost complexity 2 each (src/isa/exec.rs).

ALU (opcodes 0x08–0x3F)​

Two-operand forms: the result goes into the second register, e.g. add.{flags} a64[0],a64[1].

GroupMnemonics
Set / clearclr, put, putif
Move and convertmov, dup, swp, cpy, cnv, spy
Comparegt, lt, eq, ifz, ifn, st, inv (these set st0)
Arithmeticadd, sub, mul, div, rem, stp, neg, abs
Bitwiseand, or, xor, not, shl, shr, scl, scr, rev
Byte strings (s16)put, mov, swp, fill, len, cnt, eq, con, find, extr, inj, join, splt, ins, del, rev

Arithmetic overflow either wraps or leaves the result undefined, depending on the instruction flags. There are no zero, sign or overflow flags.

Crypto (ISA extensions, 0x80–0x8B)​

OpcodeMnemonicEffect
0x80ripemd s16[x],r160[y]RIPEMD-160 of a string register
0x81 / 0x82sha2 s16[x],r256[y] / r512[y]SHA-256 / SHA-512
0x84blake3 s16[x],r256[y]BLAKE3
0x88–0x8Bsecpgen, secpmul, secpadd, secpnegsecp256k1 point operations

None of these verifies a signature over arbitrary data. The only signature check is the RGB ISA's vts, which checks the operation's own signature field. The PFA (permissioned fungible asset) schema uses it to require the issuer's key on every transfer (rgb-schemas 0.11.1 src/pfa.rs).

RGB ISA (0xC0–0xD3)​

From rgb-consensus 0.11.1 src/vm/op_contract.rs and src/vm/opcodes.rs:

OpcodeMnemonicEffect
0xC0cnp type,a16[i]Count the operation's inputs of an owned state type
0xC1cns type,a16[i]Count its outputs of a type
0xC2cng type,a8[i]Count its global values of a type
0xC3cnc type,a32[i]Count the contract's global values of a type
0xC4ldp type,a16[i],s16[j]Load an input's structured state
0xC5lds type,a16[i],s16[j]Load an output's structured state
0xC6ldf type,a16[i],a64[j]Load an output's fungible amount
0xC8ldg type,a8[i],s16[j]Load a global value of this operation
0xC9ldc type,a32[i],s16[j]Load a global value of the contract
0xCAldm type,s16[j]Load operation metadata
0xD0svs typeCheck that the sum of inputs equals the sum of outputs for a fungible type
0xD1sas typeCheck that the sum of outputs equals a64[0]
0xD2sps typeCheck that the sum of inputs equals a64[0]
0xD3vts s16[i]Verify the transition's signature field against the public key in s16[i]

The NIA script on the overview page uses put, svs, ldg, extr, sas, test and ret.

Sources​