Enum Opcode

Source
pub enum Opcode {
Show 16 variants OP_BR = 0, OP_ADD = 1, OP_LD = 2, OP_ST = 3, OP_JSR = 4, OP_AND = 5, OP_LDR = 6, OP_STR = 7, OP_RTI = 8, OP_NOT = 9, OP_LDI = 10, OP_STI = 11, OP_JMP = 12, OP_RES = 13, OP_LEA = 14, OP_TRAP = 15,
}
Expand description

Represents the LC3 opcodes

Variants§

§

OP_BR = 0

Branch Conditional branch based on condition codes (N, Z, P) Format: 0000 NZP PCoffset9

§

OP_ADD = 1

Add Add two values and store the result Format: 0001 DR SR1 000 SR2 (register mode) 0001 DR SR1 1 imm5 (immediate mode)

§

OP_LD = 2

Load Load a value from memory into a register Format: 0010 DR PCoffset9

§

OP_ST = 3

Store Store a value from a register into memory Format: 0011 SR PCoffset9

§

OP_JSR = 4

Jump to Subroutine Jump to a subroutine and save the return address Format: 0100 1 PCoffset11 (JSR) 0100 000 BaseR 000000 (JSRR)

§

OP_AND = 5

Bitwise AND Perform bitwise AND operation Format: 0101 DR SR1 000 SR2 (register mode) 0101 DR SR1 1 imm5 (immediate mode)

§

OP_LDR = 6

Load Register Load a value from memory using a base register and offset Format: 0110 DR BaseR offset6

§

OP_STR = 7

Store Register Store a value to memory using a base register and offset Format: 0111 SR BaseR offset6

§

OP_RTI = 8

Return from Interrupt Unused in LC3 Format: 1000 000000000000

§

OP_NOT = 9

Bitwise NOT Perform bitwise NOT operation Format: 1001 DR SR 111111

§

OP_LDI = 10

Load Indirect Load a value from memory using an address stored in memory Format: 1010 DR PCoffset9

§

OP_STI = 11

Store Indirect Store a value to memory using an address stored in memory Format: 1011 SR PCoffset9

§

OP_JMP = 12

Jump Jump to an address specified by a register Format: 1100 000 BaseR 000000

§

OP_RES = 13

Reserved Unused opcode Format: 1101 000000000000

§

OP_LEA = 14

Load Effective Address Load a memory address into a register Format: 1110 DR PCoffset9

§

OP_TRAP = 15

Execute Trap Execute a system call Format: 1111 0000 trapvect8

Implementations§

Source§

impl Opcode

Source

pub fn from_u16(value: u16) -> Option<Self>

Convert a u16 to an Opcode

Source

pub fn to_u16(self) -> u16

Convert an Opcode to a u16

Trait Implementations§

Source§

impl Clone for Opcode

Source§

fn clone(&self) -> Opcode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Opcode

Source§

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

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

impl PartialEq for Opcode

Source§

fn eq(&self, other: &Opcode) -> 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 Copy for Opcode

Source§

impl Eq for Opcode

Source§

impl StructuralPartialEq for Opcode

Auto Trait Implementations§

§

impl Freeze for Opcode

§

impl RefUnwindSafe for Opcode

§

impl Send for Opcode

§

impl Sync for Opcode

§

impl Unpin for Opcode

§

impl UnwindSafe for Opcode

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.