Enum LoadOperand

Source
pub enum LoadOperand<L> {
    Pop,
    Imm(i32),
    FrameAddr(u32),
    ImmLabel(LabelRef<L>, u8),
    DerefLabel(LabelRef<L>),
    Branch(L),
}
Expand description

An operand indicating where to get a value from.

For variants that accept a label+offset, it is unsupported to provide a label in RAM with an offset that points backward into ROM. This will return an overflow error when you try to assemble it.

Variants§

§

Pop

Pop the value from the stack.

§

Imm(i32)

Use the immediate value of the operand.

§

FrameAddr(u32)

Load the value from the stack at the given offset from the frame pointer.

§

ImmLabel(LabelRef<L>, u8)

Use the address corresponding to the given label+offset and right-shift as an immediate value.

Generating an operand with a right-shift of 1 or 2 is useful with the array load/store instructions, allowing an unaligned access to an aligned array, as opposed to the usual pattern of an aligned access to an unaligned array. The shift is computed after the offset, i.e., the offset is still given in bytes. Shifting a label by more than its alignment will produce an error at assembly time.

§

DerefLabel(LabelRef<L>)

Load the value from the address at the given label+offset.

§

Branch(L)

Compute an offset in order for a branch instruction to jump to the given label.

When this label is resolved, the computed offset will be relative to the end of the operand. Jumps are computed relative to the end of the instruction. Fortunately, these are one-in-the-same, because every operand that Glulx interprets as an offset is the last operand of the instruction in which it occurs. The assembler won’t stop you from using this variant in other locations. If you do, you’ll get a nonsensical result, but you were already doing something nonsensical so GIGO.

Implementations§

Source§

impl<L> LoadOperand<L>

Source

pub fn map<F, M>(self, f: F) -> LoadOperand<M>
where F: FnMut(L) -> M,

Applies the given mapping function to the label (if any) within the operand.

Trait Implementations§

Source§

impl<L: Clone> Clone for LoadOperand<L>

Source§

fn clone(&self) -> LoadOperand<L>

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<L: Debug> Debug for LoadOperand<L>

Source§

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

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

impl<L> Display for LoadOperand<L>
where L: Display,

Source§

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

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

impl<L: Hash> Hash for LoadOperand<L>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<L: PartialEq> PartialEq for LoadOperand<L>

Source§

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

Source§

impl<L: Eq> Eq for LoadOperand<L>

Source§

impl<L> StructuralPartialEq for LoadOperand<L>

Auto Trait Implementations§

§

impl<L> Freeze for LoadOperand<L>
where L: Freeze,

§

impl<L> RefUnwindSafe for LoadOperand<L>
where L: RefUnwindSafe,

§

impl<L> Send for LoadOperand<L>
where L: Send,

§

impl<L> Sync for LoadOperand<L>
where L: Sync,

§

impl<L> Unpin for LoadOperand<L>
where L: Unpin,

§

impl<L> UnwindSafe for LoadOperand<L>
where L: UnwindSafe,

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> 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.