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>
impl<L> LoadOperand<L>
Sourcepub fn map<F, M>(self, f: F) -> LoadOperand<M>where
F: FnMut(L) -> M,
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>
impl<L: Clone> Clone for LoadOperand<L>
Source§fn clone(&self) -> LoadOperand<L>
fn clone(&self) -> LoadOperand<L>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more