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

Instruction representation for the interpreter.

Memory Opcodes

All these opcodes advance the program counter $pc by 4 after performing their operation. Every instruction is guaranteed to fit in u32 representation.

Arithmetic/Logic (ALU) Opcodes

All these opcodes advance the program counter $pc by 4 after performing their operation.

If the F_UNSAFEMATH flag is unset, an operation that would have set $err to true is instead a panic.

If the F_WRAPPING flag is unset, an operation that would have set $of to a non-zero value is instead a panic. ## Contract Opcodes

All these opcodes advance the program counter $pc by 4 after performing their operation, except for CALL and REVERT.

Cryptographic Opcodes

All these opcodes advance the program counter $pc by 4 after performing their operation.

Variants

ADD(RegisterIdRegisterIdRegisterId)

Adds two registers.

ADDI(RegisterIdRegisterIdImmediate12)

Adds a register and an immediate value.

AND(RegisterIdRegisterIdRegisterId)

Bitwise ANDs two registers.

ANDI(RegisterIdRegisterIdImmediate12)

Bitwise ANDs a register and an immediate value.

DIV(RegisterIdRegisterIdRegisterId)

Divides two registers.

DIVI(RegisterIdRegisterIdImmediate12)

Divides a register and an immediate value.

EQ(RegisterIdRegisterIdRegisterId)

Compares two registers for equality.

EXP(RegisterIdRegisterIdRegisterId)

Raises one register to the power of another.

EXPI(RegisterIdRegisterIdImmediate12)

Raises one register to the power of an immediate value.

GT(RegisterIdRegisterIdRegisterId)

Compares two registers for greater-than.

LT(RegisterIdRegisterIdRegisterId)

Compares two registers for less-than.

MLOG(RegisterIdRegisterIdRegisterId)

The integer logarithm of a register.

MROO(RegisterIdRegisterIdRegisterId)

The integer root of a register.

MOD(RegisterIdRegisterIdRegisterId)

Modulo remainder of two registers.

MODI(RegisterIdRegisterIdImmediate12)

Modulo remainder of a register and an immediate value.

MOVE(RegisterIdRegisterId)

Copy from one register to another.

MOVI(RegisterIdImmediate18)

Copy immediate value into a register

MUL(RegisterIdRegisterIdRegisterId)

Multiplies two registers.

MULI(RegisterIdRegisterIdImmediate12)

Multiplies a register and an immediate value.

NOT(RegisterIdRegisterId)

Bitwise NOT a register.

OR(RegisterIdRegisterIdRegisterId)

Bitwise ORs two registers.

ORI(RegisterIdRegisterIdImmediate12)

Bitwise ORs a register and an immediate value.

SLL(RegisterIdRegisterIdRegisterId)

Left shifts a register by a register.

SLLI(RegisterIdRegisterIdImmediate12)

Left shifts a register by an immediate value.

SRL(RegisterIdRegisterIdRegisterId)

Right shifts a register by a register.

SRLI(RegisterIdRegisterIdImmediate12)

Right shifts a register by an immediate value.

SUB(RegisterIdRegisterIdRegisterId)

Subtracts two registers.

SUBI(RegisterIdRegisterIdImmediate12)

Subtracts a register and an immediate value.

XOR(RegisterIdRegisterIdRegisterId)

Bitwise XORs two registers.

XORI(RegisterIdRegisterIdImmediate12)

Bitwise XORs a register and an immediate value.

JI(Immediate24)

Jump.

JNEI(RegisterIdRegisterIdImmediate12)

Conditional jump.

JNZI(RegisterIdImmediate18)

Conditional jump against zero.

JMP(RegisterId)

Dynamic jump.

JNE(RegisterIdRegisterIdRegisterId)

Conditional dynamic jump.

RET(RegisterId)

Return from context.

RETD(RegisterIdRegisterId)

Return from context with data.

CFEI(Immediate24)

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

CFSI(Immediate24)

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

LB(RegisterIdRegisterIdImmediate12)

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

LW(RegisterIdRegisterIdImmediate12)

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

ALOC(RegisterId)

Allocate a number of bytes from the heap.

MCL(RegisterIdRegisterId)

Clear a variable number of bytes in memory.

MCLI(RegisterIdImmediate18)

Clear an immediate number of bytes in memory.

MCP(RegisterIdRegisterIdRegisterId)

Copy a variable number of bytes in memory.

MCPI(RegisterIdRegisterIdImmediate12)

Copy an immediate number of bytes in memory.

MEQ(RegisterIdRegisterIdRegisterIdRegisterId)

Compare bytes in memory.

SB(RegisterIdRegisterIdImmediate12)

Write the least significant byte of a register to memory.

SW(RegisterIdRegisterIdImmediate12)

Write a register to memory.

BAL(RegisterIdRegisterIdRegisterId)

Get the balance of contract of an asset ID.

BHSH(RegisterIdRegisterId)

Get block header hash for height.

BHEI(RegisterId)

Get current block height.

BURN(RegisterId)

Burn coins of the current contract’s asset ID.

CALL(RegisterIdRegisterIdRegisterIdRegisterId)

Call a contract.

CCP(RegisterIdRegisterIdRegisterIdRegisterId)

Copy contract code for a contract.

CROO(RegisterIdRegisterId)

Get code root of a contract.

CSIZ(RegisterIdRegisterId)

Get code size of a contract.

CB(RegisterId)

Get current block proposer’s address.

LDC(RegisterIdRegisterIdRegisterId)

Load a contract’s code as executable.

LOG(RegisterIdRegisterIdRegisterIdRegisterId)

Log an event.

LOGD(RegisterIdRegisterIdRegisterIdRegisterId)

Log data.

MINT(RegisterId)

Mint coins of the current contract’s asset ID.

RVRT(RegisterId)

Halt execution, reverting state changes and returning a value.

SMO(RegisterIdRegisterIdRegisterIdRegisterId)

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

SCWQ(RegisterIdRegisterIdRegisterId)

Clear a series of slots from contract storage.

SRW(RegisterIdRegisterIdRegisterId)

Load a word from contract storage.

SRWQ(RegisterIdRegisterIdRegisterIdRegisterId)

Load a series of 32 byte slots from contract storage.

SWW(RegisterIdRegisterIdRegisterId)

Store a word in contract storage.

SWWQ(RegisterIdRegisterIdRegisterIdRegisterId)

Store a series of 32 byte slots in contract storage.

TIME(RegisterIdRegisterId)

Get timestamp of block at given height.

TR(RegisterIdRegisterIdRegisterId)

Transfer coins to a contract unconditionally.

TRO(RegisterIdRegisterIdRegisterIdRegisterId)

Transfer coins to a variable output.

ECR(RegisterIdRegisterIdRegisterId)

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

K256(RegisterIdRegisterIdRegisterId)

The keccak-256 hash of a slice.

S256(RegisterIdRegisterIdRegisterId)

The SHA-2-256 hash of a slice.

NOOP

Performs no operation.

FLAG(RegisterId)

Set flag register to a register.

GM(RegisterIdImmediate18)

Get metadata from memory.

GTF(RegisterIdRegisterIdImmediate12)

Get transaction fields.

Undefined

Undefined opcode, potentially from inconsistent serialization.

Implementations

Size of the struct when serialized into bytes

Create a new Opcode given the internal attributes

Create a Opcode from a slice of bytes

Safety

Reflects the requirements of bytes::from_slice_unchecked

Convert the opcode to bytes representation

Transform the Opcode into an optional array of 4 register identifiers

Return the underlying immediate value, if present

Create a new Opcode::GM instruction from its args

Create a new Opcode::GTF instruction from its args

Available on crate feature std only.

Create a Opcode from a slice of bytes

This function will fail if the length of the bytes is smaller than Opcode::LEN.

Available on crate feature std only.

Create a set of Opcode from an iterator of bytes

If not padded to Self::LEN, will consume the unaligned bytes but won’t try to parse an opcode from them.

Trait Implementations

Generate an arbitrary value of Self from the given unstructured data. Read more
Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
Read the exact number of bytes required to fill buf. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Serialize this value into the given Serde serializer. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.