Struct Instruction
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§
§impl Instruction
impl Instruction
pub const fn u(op: Opcode, rd: Reg, rs1: Reg) -> Instruction
pub const fn u(op: Opcode, rd: Reg, rs1: Reg) -> Instruction
A U-format (unary) instruction.
pub const fn b(op: Opcode, rs1: Reg, imm: Imm) -> Instruction
pub const fn b(op: Opcode, rs1: Reg, imm: Imm) -> Instruction
A B-format (branch) instruction.
pub const fn j(op: Opcode, rd: Reg, imm: Imm) -> Instruction
pub const fn j(op: Opcode, rd: Reg, imm: Imm) -> Instruction
A J-format instruction.
pub const fn n(op: Opcode) -> Instruction
pub const fn n(op: Opcode) -> Instruction
An N-format (no operand) instruction.
pub 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.
pub fn decode(word: Word) -> Result<Instruction, DecodeError>
pub fn decode(word: Word) -> Result<Instruction, DecodeError>
Decodes a 27-trit word.
Trait Implementations§
§impl Clone for Instruction
impl Clone for Instruction
§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
§impl Debug for Instruction
impl Debug for Instruction
§impl Display for Instruction
impl Display for Instruction
impl Eq for Instruction
§impl PartialEq for Instruction
impl PartialEq for Instruction
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