pub enum Opcode {
Show 81 variants ADD(usizeusizeusize), ADDI(usizeusizeu16), AND(usizeusizeusize), ANDI(usizeusizeu16), DIV(usizeusizeusize), DIVI(usizeusizeu16), EQ(usizeusizeusize), EXP(usizeusizeusize), EXPI(usizeusizeu16), GT(usizeusizeusize), LT(usizeusizeusize), MLOG(usizeusizeusize), MROO(usizeusizeusize), MOD(usizeusizeusize), MODI(usizeusizeu16), MOVE(usizeusize), MUL(usizeusizeusize), MULI(usizeusizeu16), NOT(usizeusize), OR(usizeusizeusize), ORI(usizeusizeu16), SLL(usizeusizeusize), SLLI(usizeusizeu16), SRL(usizeusizeusize), SRLI(usizeusizeu16), SUB(usizeusizeusize), SUBI(usizeusizeu16), XOR(usizeusizeusize), XORI(usizeusizeu16), CIMV(usizeusizeusize), CTMV(usizeusize), JI(u32), JNEI(usizeusizeu16), RET(usize), RETD(usizeusize), CFEI(u32), CFSI(u32), LB(usizeusizeu16), LW(usizeusizeu16), ALOC(usize), MCL(usizeusize), MCLI(usizeu32), MCP(usizeusizeusize), MCPI(usizeusizeu16), MEQ(usizeusizeusizeusize), SB(usizeusizeu16), SW(usizeusizeu16), BAL(usizeusizeusize), BHSH(usizeusize), BHEI(usize), BURN(usize), CALL(usizeusizeusizeusize), CCP(usizeusizeusizeusize), CROO(usizeusize), CSIZ(usizeusize), CB(usize), LDC(usizeusizeusize), LOG(usizeusizeusizeusize), LOGD(usizeusizeusizeusize), MINT(usize), RVRT(usize), SLDC(usizeusizeusize), SRW(usizeusize), SRWQ(usizeusize), SWW(usizeusize), SWWQ(usizeusize), TR(usizeusizeusize), TRO(usizeusizeusizeusize), ECR(usizeusizeusize), K256(usizeusizeusize), S256(usizeusizeusize), XIL(usizeusize), XIS(usizeusize), XOL(usizeusize), XOS(usizeusize), XWL(usizeusize), XWS(usizeusize), NOOP, FLAG(usize), GM(usizeu32), 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(usizeusizeusize)

Adds two registers.

ADDI(usizeusizeu16)

Adds a register and an immediate value.

AND(usizeusizeusize)

Bitwise ANDs two registers.

ANDI(usizeusizeu16)

Bitwise ANDs a register and an immediate value.

DIV(usizeusizeusize)

Divides two registers.

DIVI(usizeusizeu16)

Divides a register and an immediate value.

EQ(usizeusizeusize)

Compares two registers for equality.

EXP(usizeusizeusize)

Raises one register to the power of another.

EXPI(usizeusizeu16)

Raises one register to the power of an immediate value.

GT(usizeusizeusize)

Compares two registers for greater-than.

LT(usizeusizeusize)

Compares two registers for less-than.

MLOG(usizeusizeusize)

The integer logarithm of a register.

MROO(usizeusizeusize)

The integer root of a register.

MOD(usizeusizeusize)

Modulo remainder of two registers.

MODI(usizeusizeu16)

Modulo remainder of a register and an immediate value.

MOVE(usizeusize)

Copy from one register to another.

MUL(usizeusizeusize)

Multiplies two registers.

MULI(usizeusizeu16)

Multiplies a register and an immediate value.

NOT(usizeusize)

Bitwise NOT a register.

OR(usizeusizeusize)

Bitwise ORs two registers.

ORI(usizeusizeu16)

Bitwise ORs a register and an immediate value.

SLL(usizeusizeusize)

Left shifts a register by a register.

SLLI(usizeusizeu16)

Left shifts a register by an immediate value.

SRL(usizeusizeusize)

Right shifts a register by a register.

SRLI(usizeusizeu16)

Right shifts a register by an immediate value.

SUB(usizeusizeusize)

Subtracts two registers.

SUBI(usizeusizeu16)

Subtracts a register and an immediate value.

XOR(usizeusizeusize)

Bitwise XORs two registers.

XORI(usizeusizeu16)

Bitwise XORs a register and an immediate value.

CIMV(usizeusizeusize)

Check relative timelock.

CTMV(usizeusize)

Check absolute timelock.

JI(u32)

Jump.

JNEI(usizeusizeu16)

Conditional jump.

RET(usize)

Return from context.

RETD(usizeusize)

Return from context with data.

CFEI(u32)

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

CFSI(u32)

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

LB(usizeusizeu16)

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

LW(usizeusizeu16)

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

ALOC(usize)

Allocate a number of bytes from the heap.

MCL(usizeusize)

Clear a variable number of bytes in memory.

MCLI(usizeu32)

Clear an immediate number of bytes in memory.

MCP(usizeusizeusize)

Copy a variable number of bytes in memory.

MCPI(usizeusizeu16)

Copy an immediate number of bytes in memory.

MEQ(usizeusizeusizeusize)

Compare bytes in memory.

SB(usizeusizeu16)

Write the least significant byte of a register to memory.

SW(usizeusizeu16)

Write a register to memory.

BAL(usizeusizeusize)

Get the balance of contract of an asset ID.

BHSH(usizeusize)

Get block header hash for height.

BHEI(usize)

Get current block height.

BURN(usize)

Burn coins of the current contract’s asset ID.

CALL(usizeusizeusizeusize)

Call a contract.

CCP(usizeusizeusizeusize)

Copy contract code for a contract.

CROO(usizeusize)

Get code root of a contract.

CSIZ(usizeusize)

Get code size of a contract.

CB(usize)

Get current block proposer’s address.

LDC(usizeusizeusize)

Load a contract’s code as executable.

LOG(usizeusizeusizeusize)

Log an event.

LOGD(usizeusizeusizeusize)

Log data.

MINT(usize)

Mint coins of the current contract’s asset ID.

RVRT(usize)

Halt execution, reverting state changes and returning a value.

SLDC(usizeusizeusize)

Load a static contract’s code as executable.

SRW(usizeusize)

Load a word from contract storage.

SRWQ(usizeusize)

Load 32 bytes from contract storage.

SWW(usizeusize)

Store a word in contract storage.

SWWQ(usizeusize)

Store 32 bytes in contract storage.

TR(usizeusizeusize)

Transfer coins to a contract unconditionally.

TRO(usizeusizeusizeusize)

Transfer coins to a variable output.

ECR(usizeusizeusize)

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

K256(usizeusizeusize)

The keccak-256 hash of a slice.

S256(usizeusizeusize)

The SHA-2-256 hash of a slice.

XIL(usizeusize)

Get the length in bytes of an input.

XIS(usizeusize)

Get the memory addess of the start of an input.

XOL(usizeusize)

Get the length in bytes of an output.

XOS(usizeusize)

Get the memory addess of the start of an output.

XWL(usizeusize)

Get the length in bytes of a witness.

XWS(usizeusize)

Get the memory addess of the start of a witness.

NOOP

Performs no operation.

FLAG(usize)

Set flag register to a register.

GM(usizeu32)

Get metadata from memory.

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 Opcode from a slice of bytes

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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 !=.

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 buf. 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

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.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.