Enum Instruction

Source
pub enum Instruction {
Show 19 variants ADD { dst: i16, src1: i16, src2: i16, }, ADDi { dst: i16, src: i16, immd: i16, }, AND { dst: i16, src1: i16, src2: i16, }, ANDi { dst: i16, src: i16, immd: i16, }, BR { cond: Condition, offset: i16, }, JMP { base: i16, }, JSR { offset: i16, }, JSRR { base: i16, }, LD { dst: i16, offset: i16, }, LDI { dst: i16, offset: i16, }, LDR { dst: i16, base: i16, offset: i16, }, LEA { dst: i16, offset: i16, }, NOT { dst: i16, src: i16, }, RTI, ST { src: i16, offset: i16, }, STI { src: i16, offset: i16, }, STR { src: i16, base: i16, offset: i16, }, RESERVED, TRAP { vect: i16, },
}
Expand description

A single LC-3 instruction. Except condition codes and is_immd values, all fields are set to i16 type for convenience.

Variants§

§

ADD

Fields

§dst: i16
§src1: i16
§src2: i16
§

ADDi

Fields

§dst: i16
§src: i16
§immd: i16
§

AND

Fields

§dst: i16
§src1: i16
§src2: i16
§

ANDi

Fields

§dst: i16
§src: i16
§immd: i16
§

BR

Fields

§offset: i16
§

JMP

Fields

§base: i16
§

JSR

Fields

§offset: i16
§

JSRR

Fields

§base: i16
§

LD

Fields

§dst: i16
§offset: i16
§

LDI

Fields

§dst: i16
§offset: i16
§

LDR

Fields

§dst: i16
§base: i16
§offset: i16
§

LEA

Fields

§dst: i16
§offset: i16
§

NOT

Fields

§dst: i16
§src: i16
§

RTI

§

ST

Fields

§src: i16
§offset: i16
§

STI

Fields

§src: i16
§offset: i16
§

STR

Fields

§src: i16
§base: i16
§offset: i16
§

RESERVED

§

TRAP

Fields

§vect: i16

Implementations§

Source§

impl Instruction

Source

pub fn from_u16(data: u16) -> Instruction

Converts a single u16 value to LC-3 instruction. Note that for some instructions that can be interpreted in multiple types (e.g. JSR/JSRR), every field will be initialized to defined bit array slice values even if it won’t be used.

Trait Implementations§

Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Instruction

Source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.