Enum mosis::Instruction [−][src]
MOSIS
instruction type.
All instructions are 16-bits. The first 4 bits represent the opcode, and the remaining 12 bits are used in an instruction-dependent way. Instructions have between 0 and 3 parameters. Most of the instruction names are fixed, except the conditional jump instruction (Jcc).
Variants
Copy the contents of the src
register to the dst
register.
Move a number encoded in the instruction (imm
)into the dst
register.
Add two registers x
and y
, and store the result in the dst
register.
Subtract register y
from register x
, (x - y
), and store the result in the dst
register.
Jump if a certain condition is true (based on the result of a Cmp
).
The conditional jump instruction’s name can be rendered differently depending on the
condition (e.g. it becomes JLT
when checking for "less than" or JNE
when checking for
"not equal").
If condition is true, jump to the offset; otherwise, execute the next instruction. The
offset is an instruction count, positive or negative based on the sign bit. Offset is from
the beginning of the Jcc
instruction.
Jump to a fixed address.
Fields of Jmp
address: Address
Call a function at a fixed address.
More specifically, push the address of the following instruction onto the call stack, then
Jmp
to the address specified.
Fields of Call
address: Address
Return from a function.
More specifically, pop the address off the call stack, and Jmp
there.
No operation. Do nothing.
Read from external memory or device and store in dst
register.
Fields of In
dst: Register
Write contents of src
register to external memory or device.
Fields of Out
src: Register
Multiply two registers x
and y
and store the result in the dst
register.
Implementations
impl Instruction
[src]
pub fn assemble(&self) -> u16
[src]
Assemble an instruction to u16
.
pub fn disassemble(inst: u16) -> Result<Self, MOSISError>
[src]
All MOSIS instructions are 16 bits, but endianness is not specified in the documentation,
so disassembly simply takes a u16
to skirt around this ambiguity.
Trait Implementations
impl Debug for Instruction
[src]
impl Display for Instruction
[src]
impl Eq for Instruction
[src]
impl PartialEq<Instruction> for Instruction
[src]
fn eq(&self, other: &Instruction) -> bool
[src]
fn ne(&self, other: &Instruction) -> bool
[src]
impl StructuralEq for Instruction
[src]
impl StructuralPartialEq for Instruction
[src]
impl TryFrom<u16> for Instruction
[src]
Auto Trait Implementations
impl RefUnwindSafe for Instruction
[src]
impl Send for Instruction
[src]
impl Sync for Instruction
[src]
impl Unpin for Instruction
[src]
impl UnwindSafe for Instruction
[src]
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,
pub 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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
pub 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>,