[−][src]Enum pir_8_emu::binutils::pir_8_as::AssemblerDirective
An assembler directive, extending the normal assembly syntax
Variants
SetOrigin(u16)
Start writing the code at the specified address, 0-padding thereupto
Using this directive the second time or after processing an instruction is an error
Syntax: :origin [address]
SaveLabel(&'s str)
Save the current output address to recall later
Syntax: :label save [name]
LoadLabel(&'s str, i16, LabelFragment)
Load the specified part of the label with the specified name, or wait for it to be saved later, adding the specified offset
Not having saved all previously loaded labels by the end of input is an error
Attempting to load a full label when the current instruction doesn't expect 2-byte data is an error, and attempting to load a partial label when the current instruction doesn't expect 1-byte data is an error.
Syntax: :label load [full|high|low] [name]
Syntax: :label load-offset [full|high|low] [name] [offset]
InsertLiteral(&'s str)
Blindly write the specified literal
Attempting to insert a literal when the current instruction is expecting data is an error
Syntax: :literal "UwU"
Methods
impl<'s> AssemblerDirective<'s>
[src]
pub fn from_str(s: &'s str) -> Result<Option<Self>, ParseInstructionError>
[src]
Parse a directive as found among other assembly
If the specified string doesn't start with a colon, Ok(None)
is returned
Examples
assert_eq!(AssemblerDirective::from_str(":origin 0x0110"), Ok(Some(AssemblerDirective::SetOrigin(0x0110)))); assert_eq!(AssemblerDirective::from_str(": label load full OwO"), Ok(Some(AssemblerDirective::LoadLabel("OwO", 0, LabelFragment::Full)))); assert_eq!(AssemblerDirective::from_str(": label load-offset high OwO -1"), Ok(Some(AssemblerDirective::LoadLabel("OwO", -1, LabelFragment::High)))); assert_eq!(AssemblerDirective::from_str("label save uwu"), Ok(None));
pub fn obey(
&self,
next_output_address: &mut Option<u16>,
labels: &mut BTreeMap<String, u16>
) -> Result<Option<Result<LabelLoad, &'s str>>, AssemblerDirectiveObeyError<'s>>
[src]
&self,
next_output_address: &mut Option<u16>,
labels: &mut BTreeMap<String, u16>
) -> Result<Option<Result<LabelLoad, &'s str>>, AssemblerDirectiveObeyError<'s>>
Obey this directive, updating the output address and labelset as required
Examples
let mut next_output_address = None; let mut labels = BTreeMap::new(); assert_eq!(AssemblerDirective::SetOrigin(0x0110) .obey(&mut next_output_address, &mut labels), Ok(None)); assert_eq!(AssemblerDirective::LoadLabel("owo", 0, LabelFragment::Full) .obey(&mut next_output_address, &mut labels), Ok(Some(Ok(LabelLoad::WaitFor("owo".to_string(), 0, LabelFragment::Full))))); assert_eq!(AssemblerDirective::SaveLabel("owo") .obey(&mut next_output_address, &mut labels), Ok(None)); assert_eq!(AssemblerDirective::LoadLabel("owo", 0, LabelFragment::High) .obey(&mut next_output_address, &mut labels), Ok(Some(Ok(LabelLoad::HaveImmediately(0x0110, LabelFragment::High))))); assert_eq!(AssemblerDirective::LoadLabel("owo", 0x0F, LabelFragment::Low) .obey(&mut next_output_address, &mut labels), Ok(Some(Ok(LabelLoad::HaveImmediately(0x011F, LabelFragment::Low))))); assert_eq!(AssemblerDirective::InsertLiteral("EwE") .obey(&mut next_output_address, &mut labels), Ok(Some(Err("EwE")))); assert_eq!(next_output_address, Some(0x0110)); assert_eq!(labels, vec![("owo".to_string(), 0x0110)].into_iter().collect());
Trait Implementations
impl<'s> Clone for AssemblerDirective<'s>
[src]
fn clone(&self) -> AssemblerDirective<'s>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'s> Copy for AssemblerDirective<'s>
[src]
impl<'s> Debug for AssemblerDirective<'s>
[src]
impl<'s> Eq for AssemblerDirective<'s>
[src]
impl<'s> Hash for AssemblerDirective<'s>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'s> Ord for AssemblerDirective<'s>
[src]
fn cmp(&self, other: &AssemblerDirective<'s>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'s> PartialEq<AssemblerDirective<'s>> for AssemblerDirective<'s>
[src]
fn eq(&self, other: &AssemblerDirective<'s>) -> bool
[src]
fn ne(&self, other: &AssemblerDirective<'s>) -> bool
[src]
impl<'s> PartialOrd<AssemblerDirective<'s>> for AssemblerDirective<'s>
[src]
fn partial_cmp(&self, other: &AssemblerDirective<'s>) -> Option<Ordering>
[src]
fn lt(&self, other: &AssemblerDirective<'s>) -> bool
[src]
fn le(&self, other: &AssemblerDirective<'s>) -> bool
[src]
fn gt(&self, other: &AssemblerDirective<'s>) -> bool
[src]
fn ge(&self, other: &AssemblerDirective<'s>) -> bool
[src]
impl<'s> StructuralEq for AssemblerDirective<'s>
[src]
impl<'s> StructuralPartialEq for AssemblerDirective<'s>
[src]
Auto Trait Implementations
impl<'s> RefUnwindSafe for AssemblerDirective<'s>
impl<'s> Send for AssemblerDirective<'s>
impl<'s> Sync for AssemblerDirective<'s>
impl<'s> Unpin for AssemblerDirective<'s>
impl<'s> UnwindSafe for AssemblerDirective<'s>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,