Struct fuel_asm::Instruction
source · pub struct Instruction { /* private fields */ }
Expand description
A version of Opcode that can be used without unnecessary branching
Implementations§
source§impl Instruction
impl Instruction
sourcepub const fn ra(&self) -> RegisterId
pub const fn ra(&self) -> RegisterId
Register A
sourcepub const fn rb(&self) -> RegisterId
pub const fn rb(&self) -> RegisterId
Register B
sourcepub const fn rc(&self) -> RegisterId
pub const fn rc(&self) -> RegisterId
Register C
sourcepub const fn rd(&self) -> RegisterId
pub const fn rd(&self) -> RegisterId
Register D
sourcepub const fn imm06(&self) -> Immediate06
pub const fn imm06(&self) -> Immediate06
Immediate with 6 bits
sourcepub const fn imm12(&self) -> Immediate12
pub const fn imm12(&self) -> Immediate12
Immediate with 12 bits
sourcepub const fn imm18(&self) -> Immediate18
pub const fn imm18(&self) -> Immediate18
Immediate with 18 bits
sourcepub const fn imm24(&self) -> Immediate24
pub const fn imm24(&self) -> Immediate24
Immediate with 24 bits
sourcepub unsafe fn from_slice_unchecked(buf: &[u8]) -> Self
pub unsafe fn from_slice_unchecked(buf: &[u8]) -> Self
Create a Instruction
from a slice of bytes
Safety
The caller must ensure that the slice is has at least Self::LEN
bytes.
sourcepub const fn parse_word(word: Word) -> (Instruction, Instruction)
pub const fn parse_word(word: Word) -> (Instruction, Instruction)
Splits a Word into two Instruction
that can be used to construct crate::Opcode
sourcepub const fn into_inner(
self
) -> (OpcodeRepr, RegisterId, RegisterId, RegisterId, RegisterId, Word)
pub const fn into_inner(
self
) -> (OpcodeRepr, RegisterId, RegisterId, RegisterId, RegisterId, Word)
Convert the instruction into its internal representation
(repr, $ra, $rb, $rc, $rd, immediate)
source§impl Instruction
impl Instruction
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
Available on crate feature std
only.
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
std
only.Create a Instruction
from a slice of bytes
This function will fail if the length of the bytes is smaller than
Instruction::LEN
.
sourcepub fn from_bytes_iter<I>(bytes: I) -> Vec<Self>where
I: IntoIterator<Item = u8>,
Available on crate feature std
only.
pub fn from_bytes_iter<I>(bytes: I) -> Vec<Self>where
I: IntoIterator<Item = u8>,
std
only.Create a set of Instruction
from an iterator of bytes
If not padded to Self::LEN
, will consume the unaligned bytes but won’t try to parse an
instruction from them.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Instruction
impl<'arbitrary> Arbitrary<'arbitrary> for Instruction
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moresource§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl Default for Instruction
impl Default for Instruction
source§fn default() -> Instruction
fn default() -> Instruction
source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Instruction> for Opcode
impl From<Instruction> for Opcode
source§fn from(parsed: Instruction) -> Self
fn from(parsed: Instruction) -> Self
source§impl From<Instruction> for u32
impl From<Instruction> for u32
source§fn from(parsed: Instruction) -> u32
fn from(parsed: Instruction) -> u32
source§impl From<InstructionResult> for Instruction
impl From<InstructionResult> for Instruction
source§fn from(r: InstructionResult) -> Self
fn from(r: InstructionResult) -> Self
source§impl From<Opcode> for Instruction
impl From<Opcode> for Instruction
source§impl From<u32> for Instruction
impl From<u32> for Instruction
source§impl FromIterator<Instruction> for Vec<Opcode>
Available on crate feature std
only.
impl FromIterator<Instruction> for Vec<Opcode>
std
only.source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
source§impl FromIterator<Instruction> for Vec<u8>
Available on crate feature std
only.
impl FromIterator<Instruction> for Vec<u8>
std
only.source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
source§impl Hash for Instruction
impl Hash for Instruction
source§impl PartialEq<Instruction> for Instruction
impl PartialEq<Instruction> for Instruction
source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
self
and other
values to be equal, and is used
by ==
.