[−][src]Enum lasm::asm::Instruct
This enum represents a single instruction that can be assembled. The majority of the work to implement Target for a target programming language is defining how to convert an instruction to a properly formatted string for the target.
Variants
Refer(Register)
The refer
instruction takes a register and pushes a
pointer to that register onto the stack. The motivation
for only allowing registers to be referenced is very
simple to explain. Values on the stack are meant to be
temporary. Literals pretty much exclusively exist on the
stack. Allowing references to literals promotes bad practices.
The deref_ld
instruction takes no arguments. This instruction
pops an address off the stack and pushes the value stored at the
cell the address points to.
Essentially, this derefences the pointer as a double precision float pointer.
The deref_st
instruction takes no arguments. This instruction
pops an address cell and a value cell off the stack. The value cell is stored
as a double precision float at the location the pointer points to.
This is equivalent to *(double*)address = value
Load(Register)
The ld
instruction takes a register as an argument. This instruction
loads the value stored in the register and pushes it onto the stack.
Store(Register)
The st
instruction takes a register as an argument. This instruction
pops a value off of the stack and stores it in the register.
This is equivalent to register = value
Push(Literal)
The push
instruction takes either a literal as an argument. This literal
can either be a character or a double precision float. This instruction pushes
the literal onto the stack.
The pop
instruction pops a value off of the stack and stores it in the ACC register.
This is equivalent to ACC = value
Alloc(Register)
The alloc
instruction takes a register as an argument, and pops a size
value
off of the stack. Then, alloc
stores a pointer size
number of consecutive free cells.
This is equivalent to register = (double*)malloc(size)
Free(Register)
The free
instruction takes a register as an argument, and pops a size
value
off of the stack. Then, free
frees size
number of values at the location the
register points to.
The dup
instruction takes no argument, and simply duplicates the top item on
the stack.
The add
instruction pops two cells off the stack and pushes their sum
The sub
instruction pops two cells off the stack and pushes the first minus the second
The mul
instruction pops two cells off the stack and pushes their product
The div
instruction pops two cells off the stack and pushes the first divided by the second
The outc
instruction pops a cell off the stack and prints cell % 256
as a character to STDOUT
The outn
instruction pops a cell off the stack and prints the cell as a number to STDOUT
The inc
instruction pushes a character from STDIN onto the stack
The inn
instruction pushes a double precision float from STDIN onto the stack
The cmp
instruction compares two cells on the stack.
If the first popped value is less than the second, -1 is pushed.
If the first popped value is equal to the second, 0 is pushed.
If the first popped value is greater than to the second, 1 is pushed.
The loop
instruction the start of a loop. At the start of each iteration, a test value is popped from the stack. While the value is not zero, the loop continues. Else, the loop jumps to the matching endloop
The endloop
instruction marks the end of a loop
Trait Implementations
impl Clone for Instruct
[src]
impl Debug for Instruct
[src]
impl PartialEq<Instruct> for Instruct
[src]
impl PartialOrd<Instruct> for Instruct
[src]
fn partial_cmp(&self, other: &Instruct) -> Option<Ordering>
[src]
fn lt(&self, other: &Instruct) -> bool
[src]
fn le(&self, other: &Instruct) -> bool
[src]
fn gt(&self, other: &Instruct) -> bool
[src]
fn ge(&self, other: &Instruct) -> bool
[src]
impl StructuralPartialEq for Instruct
[src]
Auto Trait Implementations
impl RefUnwindSafe for Instruct
impl Send for Instruct
impl Sync for Instruct
impl Unpin for Instruct
impl UnwindSafe for Instruct
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> 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 = !
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>,