pub enum Instruction {
Show 79 variants ADD(ADD), AND(AND), DIV(DIV), EQ(EQ), EXP(EXP), GT(GT), LT(LT), MLOG(MLOG), MROO(MROO), MOD(MOD), MOVE(MOVE), MUL(MUL), NOT(NOT), OR(OR), SLL(SLL), SRL(SRL), SUB(SUB), XOR(XOR), RET(RET), RETD(RETD), ALOC(ALOC), MCL(MCL), MCP(MCP), MEQ(MEQ), BHSH(BHSH), BHEI(BHEI), BURN(BURN), CALL(CALL), CCP(CCP), CROO(CROO), CSIZ(CSIZ), CB(CB), LDC(LDC), LOG(LOG), LOGD(LOGD), MINT(MINT), RVRT(RVRT), SCWQ(SCWQ), SRW(SRW), SRWQ(SRWQ), SWW(SWW), SWWQ(SWWQ), TR(TR), TRO(TRO), ECR(ECR), K256(K256), S256(S256), TIME(TIME), NOOP(NOOP), FLAG(FLAG), BAL(BAL), JMP(JMP), JNE(JNE), SMO(SMO), ADDI(ADDI), ANDI(ANDI), DIVI(DIVI), EXPI(EXPI), MODI(MODI), MULI(MULI), ORI(ORI), SLLI(SLLI), SRLI(SRLI), SUBI(SUBI), XORI(XORI), JNEI(JNEI), LB(LB), LW(LW), SB(SB), SW(SW), MCPI(MCPI), GTF(GTF), MCLI(MCLI), GM(GM), MOVI(MOVI), JNZI(JNZI), JI(JI), CFEI(CFEI), CFSI(CFSI),
}
Expand description

Representation of a single instruction for the interpreter.

The opcode is represented in the tag (variant), or may be retrieved in the form of an Opcode byte using the opcode method.

The register and immediate data associated with the instruction is represented within an inner unit type wrapper around the 3 remaining bytes.

Variants§

§

ADD(ADD)

Adds two registers.

§

AND(AND)

Bitwise ANDs two registers.

§

DIV(DIV)

Divides two registers.

§

EQ(EQ)

Compares two registers for equality.

§

EXP(EXP)

Raises one register to the power of another.

§

GT(GT)

Compares two registers for greater-than.

§

LT(LT)

Compares two registers for less-than.

§

MLOG(MLOG)

The integer logarithm of a register.

§

MROO(MROO)

The integer root of a register.

§

MOD(MOD)

Modulo remainder of two registers.

§

MOVE(MOVE)

Copy from one register to another.

§

MUL(MUL)

Multiplies two registers.

§

NOT(NOT)

Bitwise NOT a register.

§

OR(OR)

Bitwise ORs two registers.

§

SLL(SLL)

Left shifts a register by a register.

§

SRL(SRL)

Right shifts a register by a register.

§

SUB(SUB)

Subtracts two registers.

§

XOR(XOR)

Bitwise XORs two registers.

§

RET(RET)

Return from context.

§

RETD(RETD)

Return from context with data.

§

ALOC(ALOC)

Allocate a number of bytes from the heap.

§

MCL(MCL)

Clear a variable number of bytes in memory.

§

MCP(MCP)

Copy a variable number of bytes in memory.

§

MEQ(MEQ)

Compare bytes in memory.

§

BHSH(BHSH)

Get block header hash for height.

§

BHEI(BHEI)

Get current block height.

§

BURN(BURN)

Burn coins of the current contract’s asset ID.

§

CALL(CALL)

Call a contract.

§

CCP(CCP)

Copy contract code for a contract.

§

CROO(CROO)

Get code root of a contract.

§

CSIZ(CSIZ)

Get code size of a contract.

§

CB(CB)

Get current block proposer’s address.

§

LDC(LDC)

Load a contract’s code as executable.

§

LOG(LOG)

Log an event.

§

LOGD(LOGD)

Log data.

§

MINT(MINT)

Mint coins of the current contract’s asset ID.

§

RVRT(RVRT)

Halt execution, reverting state changes and returning a value.

§

SCWQ(SCWQ)

Clear a series of slots from contract storage.

§

SRW(SRW)

Load a word from contract storage.

§

SRWQ(SRWQ)

Load a series of 32 byte slots from contract storage.

§

SWW(SWW)

Store a word in contract storage.

§

SWWQ(SWWQ)

Store a series of 32 byte slots in contract storage.

§

TR(TR)

Transfer coins to a contract unconditionally.

§

TRO(TRO)

Transfer coins to a variable output.

§

ECR(ECR)

The 64-byte public key (x, y) recovered from 64-byte signature on 32-byte message.

§

K256(K256)

The keccak-256 hash of a slice.

§

S256(S256)

The SHA-2-256 hash of a slice.

§

TIME(TIME)

Get timestamp of block at given height.

§

NOOP(NOOP)

Performs no operation.

§

FLAG(FLAG)

Set flag register to a register.

§

BAL(BAL)

Get the balance of contract of an asset ID.

§

JMP(JMP)

Dynamic jump.

§

JNE(JNE)

Conditional dynamic jump.

§

SMO(SMO)

Send a message to recipient address with call abi, coins, and output.

§

ADDI(ADDI)

Adds a register and an immediate value.

§

ANDI(ANDI)

Bitwise ANDs a register and an immediate value.

§

DIVI(DIVI)

Divides a register and an immediate value.

§

EXPI(EXPI)

Raises one register to the power of an immediate value.

§

MODI(MODI)

Modulo remainder of a register and an immediate value.

§

MULI(MULI)

Multiplies a register and an immediate value.

§

ORI(ORI)

Bitwise ORs a register and an immediate value.

§

SLLI(SLLI)

Left shifts a register by an immediate value.

§

SRLI(SRLI)

Right shifts a register by an immediate value.

§

SUBI(SUBI)

Subtracts a register and an immediate value.

§

XORI(XORI)

Bitwise XORs a register and an immediate value.

§

JNEI(JNEI)

Conditional jump.

§

LB(LB)

A byte is loaded from the specified address offset by an immediate value.

§

LW(LW)

A word is loaded from the specified address offset by an immediate value.

§

SB(SB)

Write the least significant byte of a register to memory.

§

SW(SW)

Write a register to memory.

§

MCPI(MCPI)

Copy an immediate number of bytes in memory.

§

GTF(GTF)

Get transaction fields.

§

MCLI(MCLI)

Clear an immediate number of bytes in memory.

§

GM(GM)

Get metadata from memory.

§

MOVI(MOVI)

Copy immediate value into a register

§

JNZI(JNZI)

Conditional jump against zero.

§

JI(JI)

Jump.

§

CFEI(CFEI)

Extend the current call frame’s stack by an immediate value.

§

CFSI(CFSI)

Shrink the current call frame’s stack by an immediate value.

Implementations§

source§

impl Instruction

source

pub fn opcode(&self) -> Opcode

This instruction’s opcode.

source

pub fn reg_ids(&self) -> [Option<RegId>; 4]

Unpacks all register IDs into a slice of options.

source§

impl Instruction

source

pub const SIZE: usize = 4usize

Size of an instruction in bytes

source

pub fn to_bytes(self) -> [u8; 4]

Convenience method for converting to bytes

Trait Implementations§

source§

impl Clone for Instruction

source§

fn clone(&self) -> Instruction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Instruction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Instruction

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<ADD> for Instruction

source§

fn from(op: ADD) -> Self

Converts to this type from the input type.
source§

impl From<ADDI> for Instruction

source§

fn from(op: ADDI) -> Self

Converts to this type from the input type.
source§

impl From<ALOC> for Instruction

source§

fn from(op: ALOC) -> Self

Converts to this type from the input type.
source§

impl From<AND> for Instruction

source§

fn from(op: AND) -> Self

Converts to this type from the input type.
source§

impl From<ANDI> for Instruction

source§

fn from(op: ANDI) -> Self

Converts to this type from the input type.
source§

impl From<BAL> for Instruction

source§

fn from(op: BAL) -> Self

Converts to this type from the input type.
source§

impl From<BHEI> for Instruction

source§

fn from(op: BHEI) -> Self

Converts to this type from the input type.
source§

impl From<BHSH> for Instruction

source§

fn from(op: BHSH) -> Self

Converts to this type from the input type.
source§

impl From<BURN> for Instruction

source§

fn from(op: BURN) -> Self

Converts to this type from the input type.
source§

impl From<CALL> for Instruction

source§

fn from(op: CALL) -> Self

Converts to this type from the input type.
source§

impl From<CB> for Instruction

source§

fn from(op: CB) -> Self

Converts to this type from the input type.
source§

impl From<CCP> for Instruction

source§

fn from(op: CCP) -> Self

Converts to this type from the input type.
source§

impl From<CFEI> for Instruction

source§

fn from(op: CFEI) -> Self

Converts to this type from the input type.
source§

impl From<CFSI> for Instruction

source§

fn from(op: CFSI) -> Self

Converts to this type from the input type.
source§

impl From<CROO> for Instruction

source§

fn from(op: CROO) -> Self

Converts to this type from the input type.
source§

impl From<CSIZ> for Instruction

source§

fn from(op: CSIZ) -> Self

Converts to this type from the input type.
source§

impl From<DIV> for Instruction

source§

fn from(op: DIV) -> Self

Converts to this type from the input type.
source§

impl From<DIVI> for Instruction

source§

fn from(op: DIVI) -> Self

Converts to this type from the input type.
source§

impl From<ECR> for Instruction

source§

fn from(op: ECR) -> Self

Converts to this type from the input type.
source§

impl From<EQ> for Instruction

source§

fn from(op: EQ) -> Self

Converts to this type from the input type.
source§

impl From<EXP> for Instruction

source§

fn from(op: EXP) -> Self

Converts to this type from the input type.
source§

impl From<EXPI> for Instruction

source§

fn from(op: EXPI) -> Self

Converts to this type from the input type.
source§

impl From<FLAG> for Instruction

source§

fn from(op: FLAG) -> Self

Converts to this type from the input type.
source§

impl From<GM> for Instruction

source§

fn from(op: GM) -> Self

Converts to this type from the input type.
source§

impl From<GT> for Instruction

source§

fn from(op: GT) -> Self

Converts to this type from the input type.
source§

impl From<GTF> for Instruction

source§

fn from(op: GTF) -> Self

Converts to this type from the input type.
source§

impl From<Instruction> for [u8; 4]

source§

fn from(inst: Instruction) -> Self

Converts to this type from the input type.
source§

impl From<Instruction> for RawInstruction

source§

fn from(inst: Instruction) -> Self

Converts to this type from the input type.
source§

impl From<JI> for Instruction

source§

fn from(op: JI) -> Self

Converts to this type from the input type.
source§

impl From<JMP> for Instruction

source§

fn from(op: JMP) -> Self

Converts to this type from the input type.
source§

impl From<JNE> for Instruction

source§

fn from(op: JNE) -> Self

Converts to this type from the input type.
source§

impl From<JNEI> for Instruction

source§

fn from(op: JNEI) -> Self

Converts to this type from the input type.
source§

impl From<JNZI> for Instruction

source§

fn from(op: JNZI) -> Self

Converts to this type from the input type.
source§

impl From<K256> for Instruction

source§

fn from(op: K256) -> Self

Converts to this type from the input type.
source§

impl From<LB> for Instruction

source§

fn from(op: LB) -> Self

Converts to this type from the input type.
source§

impl From<LDC> for Instruction

source§

fn from(op: LDC) -> Self

Converts to this type from the input type.
source§

impl From<LOG> for Instruction

source§

fn from(op: LOG) -> Self

Converts to this type from the input type.
source§

impl From<LOGD> for Instruction

source§

fn from(op: LOGD) -> Self

Converts to this type from the input type.
source§

impl From<LT> for Instruction

source§

fn from(op: LT) -> Self

Converts to this type from the input type.
source§

impl From<LW> for Instruction

source§

fn from(op: LW) -> Self

Converts to this type from the input type.
source§

impl From<MCL> for Instruction

source§

fn from(op: MCL) -> Self

Converts to this type from the input type.
source§

impl From<MCLI> for Instruction

source§

fn from(op: MCLI) -> Self

Converts to this type from the input type.
source§

impl From<MCP> for Instruction

source§

fn from(op: MCP) -> Self

Converts to this type from the input type.
source§

impl From<MCPI> for Instruction

source§

fn from(op: MCPI) -> Self

Converts to this type from the input type.
source§

impl From<MEQ> for Instruction

source§

fn from(op: MEQ) -> Self

Converts to this type from the input type.
source§

impl From<MINT> for Instruction

source§

fn from(op: MINT) -> Self

Converts to this type from the input type.
source§

impl From<MLOG> for Instruction

source§

fn from(op: MLOG) -> Self

Converts to this type from the input type.
source§

impl From<MOD> for Instruction

source§

fn from(op: MOD) -> Self

Converts to this type from the input type.
source§

impl From<MODI> for Instruction

source§

fn from(op: MODI) -> Self

Converts to this type from the input type.
source§

impl From<MOVE> for Instruction

source§

fn from(op: MOVE) -> Self

Converts to this type from the input type.
source§

impl From<MOVI> for Instruction

source§

fn from(op: MOVI) -> Self

Converts to this type from the input type.
source§

impl From<MROO> for Instruction

source§

fn from(op: MROO) -> Self

Converts to this type from the input type.
source§

impl From<MUL> for Instruction

source§

fn from(op: MUL) -> Self

Converts to this type from the input type.
source§

impl From<MULI> for Instruction

source§

fn from(op: MULI) -> Self

Converts to this type from the input type.
source§

impl From<NOOP> for Instruction

source§

fn from(op: NOOP) -> Self

Converts to this type from the input type.
source§

impl From<NOT> for Instruction

source§

fn from(op: NOT) -> Self

Converts to this type from the input type.
source§

impl From<OR> for Instruction

source§

fn from(op: OR) -> Self

Converts to this type from the input type.
source§

impl From<ORI> for Instruction

source§

fn from(op: ORI) -> Self

Converts to this type from the input type.
source§

impl From<RET> for Instruction

source§

fn from(op: RET) -> Self

Converts to this type from the input type.
source§

impl From<RETD> for Instruction

source§

fn from(op: RETD) -> Self

Converts to this type from the input type.
source§

impl From<RVRT> for Instruction

source§

fn from(op: RVRT) -> Self

Converts to this type from the input type.
source§

impl From<S256> for Instruction

source§

fn from(op: S256) -> Self

Converts to this type from the input type.
source§

impl From<SB> for Instruction

source§

fn from(op: SB) -> Self

Converts to this type from the input type.
source§

impl From<SCWQ> for Instruction

source§

fn from(op: SCWQ) -> Self

Converts to this type from the input type.
source§

impl From<SLL> for Instruction

source§

fn from(op: SLL) -> Self

Converts to this type from the input type.
source§

impl From<SLLI> for Instruction

source§

fn from(op: SLLI) -> Self

Converts to this type from the input type.
source§

impl From<SMO> for Instruction

source§

fn from(op: SMO) -> Self

Converts to this type from the input type.
source§

impl From<SRL> for Instruction

source§

fn from(op: SRL) -> Self

Converts to this type from the input type.
source§

impl From<SRLI> for Instruction

source§

fn from(op: SRLI) -> Self

Converts to this type from the input type.
source§

impl From<SRW> for Instruction

source§

fn from(op: SRW) -> Self

Converts to this type from the input type.
source§

impl From<SRWQ> for Instruction

source§

fn from(op: SRWQ) -> Self

Converts to this type from the input type.
source§

impl From<SUB> for Instruction

source§

fn from(op: SUB) -> Self

Converts to this type from the input type.
source§

impl From<SUBI> for Instruction

source§

fn from(op: SUBI) -> Self

Converts to this type from the input type.
source§

impl From<SW> for Instruction

source§

fn from(op: SW) -> Self

Converts to this type from the input type.
source§

impl From<SWW> for Instruction

source§

fn from(op: SWW) -> Self

Converts to this type from the input type.
source§

impl From<SWWQ> for Instruction

source§

fn from(op: SWWQ) -> Self

Converts to this type from the input type.
source§

impl From<TIME> for Instruction

source§

fn from(op: TIME) -> Self

Converts to this type from the input type.
source§

impl From<TR> for Instruction

source§

fn from(op: TR) -> Self

Converts to this type from the input type.
source§

impl From<TRO> for Instruction

source§

fn from(op: TRO) -> Self

Converts to this type from the input type.
source§

impl From<XOR> for Instruction

source§

fn from(op: XOR) -> Self

Converts to this type from the input type.
source§

impl From<XORI> for Instruction

source§

fn from(op: XORI) -> Self

Converts to this type from the input type.
source§

impl FromIterator<Instruction> for Vec<u32>

Available on crate feature std only.
source§

fn from_iter<I: IntoIterator<Item = Instruction>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Instruction> for Vec<u8>

Available on crate feature std only.
source§

fn from_iter<I: IntoIterator<Item = Instruction>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for Instruction

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Instruction> for Instruction

source§

fn eq(&self, other: &Instruction) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Instruction

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<[u8; 4]> for Instruction

§

type Error = InvalidOpcode

The type returned in the event of a conversion error.
source§

fn try_from([op, a, b, c]: [u8; 4]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<u32> for Instruction

§

type Error = InvalidOpcode

The type returned in the event of a conversion error.
source§

fn try_from(u: RawInstruction) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Instruction

source§

impl Eq for Instruction

source§

impl StructuralEq for Instruction

source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,