#[repr(i16)]pub enum Opcode {
Show 29 variants
Nop = 0,
Add = 1,
Sub = 2,
Mul = 3,
Div = 4,
Rem = 5,
Min = 6,
Max = 7,
Cmp3 = 8,
Neg = 9,
Abs = 10,
Addi = 11,
Shl = 12,
Shr = 13,
Lw = 14,
Sw = 15,
Jal = 16,
Jalr = 17,
Br3 = 18,
Brz = 19,
Halt = 20,
Lt = 21,
St = 22,
Brn = 23,
Brp = 24,
Csrr = 25,
Csrw = 26,
Tret = 27,
Ecall = 28,
}Expand description
Every defined operation.
Discriminants are the encoded opcode values. Negative values are reserved for future extension and never appear here.
Variants§
Nop = 0
do nothing; pc <- pc + 1
Add = 1
rd <- rs1 + rs2
Sub = 2
rd <- rs1 - rs2
Mul = 3
rd <- rs1 * rs2
Div = 4
rd <- rs1 / rs2, truncating
Rem = 5
rd <- rs1 % rs2
Min = 6
rd <- per-trit minimum of rs1, rs2; Kleene AND
Max = 7
rd <- per-trit maximum of rs1, rs2; Kleene OR
Cmp3 = 8
rd <- -1, 0 or +1 as rs1 <, ==, > rs2
Neg = 9
rd <- -rs1; also the per-trit logical NOT
Abs = 10
rd <- |rs1|; total, because the range is symmetric
Addi = 11
rd <- rs1 + imm
Shl = 12
rd <- rs1 * 3^imm, an exact trit shift
Shr = 13
rd <- rs1 / 3^imm, rounded to nearest
Lw = 14
rd <- memory word at rs1 + imm trytes
Sw = 15
memory word at rs1 + imm trytes <- rd
Jal = 16
rd <- pc + 1; pc <- pc + imm
Jalr = 17
rd <- pc + 1; pc <- rs1 + imm
Br3 = 18
three-way: pc <- pc + imm if rs1 > 0; pc <- pc - imm if rs1 < 0; pc <- pc + 1 if rs1 == 0
Brz = 19
pc <- pc + imm if rs1 == 0, else pc <- pc + 1
Halt = 20
stop execution
Lt = 21
rd <- memory tryte at rs1 + imm trytes; no alignment requirement
St = 22
memory tryte at rs1 + imm trytes <- rd; no alignment requirement
Brn = 23
pc <- pc + imm if rs1 < 0, else pc <- pc + 1
Brp = 24
pc <- pc + imm if rs1 > 0, else pc <- pc + 1
Csrr = 25
rd <- control register imm; supervisor or machine only
Csrw = 26
control register imm <- rs1; supervisor or machine only
Tret = 27
pc <- tepc; priv <- tpriv; supervisor or machine only
Ecall = 28
trap to tvec with cause Ecall
Implementations§
Source§impl Opcode
impl Opcode
Sourcepub const fn from_value(v: i64) -> Result<Opcode, DecodeError>
pub const fn from_value(v: i64) -> Result<Opcode, DecodeError>
Decodes an opcode field value.
A match, so dispatch compiles to a jump table rather than a
linear scan of TABLE.