Struct fuel_asm::Instruction
source · [−]pub struct Instruction { /* private fields */ }
Expand description
A version of Opcode that can be used without unnecessary branching
Implementations
sourceimpl 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)
sourceimpl 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
sourceimpl<'arbitrary> Arbitrary<'arbitrary> for Instruction
impl<'arbitrary> Arbitrary<'arbitrary> for Instruction
sourcefn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moresourcefn 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 moresourceimpl Clone for Instruction
impl Clone for Instruction
sourcefn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for Instruction
impl Debug for Instruction
sourceimpl Default for Instruction
impl Default for Instruction
sourcefn default() -> Instruction
fn default() -> Instruction
sourceimpl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
sourcefn 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>,
sourceimpl From<[u8; 4]> for Instruction
impl From<[u8; 4]> for Instruction
sourceimpl From<Instruction> for Opcode
impl From<Instruction> for Opcode
sourcefn from(parsed: Instruction) -> Self
fn from(parsed: Instruction) -> Self
sourceimpl From<Instruction> for u32
impl From<Instruction> for u32
sourcefn from(parsed: Instruction) -> u32
fn from(parsed: Instruction) -> u32
sourceimpl From<InstructionResult> for Instruction
impl From<InstructionResult> for Instruction
sourcefn from(r: InstructionResult) -> Self
fn from(r: InstructionResult) -> Self
sourceimpl From<Opcode> for Instruction
impl From<Opcode> for Instruction
sourceimpl From<u32> for Instruction
impl From<u32> for Instruction
sourceimpl FromIterator<Instruction> for Vec<Opcode>
Available on crate feature std
only.
impl FromIterator<Instruction> for Vec<Opcode>
std
only.sourcefn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Instruction>,
sourceimpl FromIterator<Instruction> for Vec<u8>
Available on crate feature std
only.
impl FromIterator<Instruction> for Vec<u8>
std
only.