pub struct Instruction {
pub op: Opcode,
pub rd: Reg,
pub rs1: Reg,
pub rs2: Reg,
pub imm: Imm,
}Expand description
A decoded instruction.
Fields not used by the opcode’s Format are zero, both here and in the
encoded word.
Fields§
§op: OpcodeThe operation.
rd: RegDestination register, or Reg::ZERO if unused.
rs1: RegFirst source register, or Reg::ZERO if unused.
rs2: RegSecond source register, or Reg::ZERO if unused.
imm: ImmImmediate, or Imm::ZERO if unused.
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub const fn r(op: Opcode, rd: Reg, rs1: Reg, rs2: Reg) -> Instruction
pub const fn r(op: Opcode, rd: Reg, rs1: Reg, rs2: Reg) -> Instruction
An R-format instruction.
Sourcepub const fn i(op: Opcode, rd: Reg, rs1: Reg, imm: Imm) -> Instruction
pub const fn i(op: Opcode, rd: Reg, rs1: Reg, imm: Imm) -> Instruction
An I-format instruction.
Sourcepub const fn n(op: Opcode) -> Instruction
pub const fn n(op: Opcode) -> Instruction
An N-format (no operand) instruction.
Sourcepub fn encode(self) -> Word
pub fn encode(self) -> Word
Encodes to a 27-trit word.
Unused fields are written as zero regardless of what the struct holds, so the encoding is always canonical.
Sourcepub fn decode(word: Word) -> Result<Instruction, DecodeError>
pub fn decode(word: Word) -> Result<Instruction, DecodeError>
Decodes a 27-trit word.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Instruction
Source§impl Debug for Instruction
impl Debug for Instruction
Source§impl Display for Instruction
impl Display for Instruction
impl Eq for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
Source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnsafeUnpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more