[−][src]Enum rvm_opcode::Opcode
Defines various opcodes
Variants
NOP
No operation
ADD
Add the values of two registers
SUB
Subtract the value of one register from another
MPY
Multiply the values of two registers
DIV
Divide the value of one register by another
MOD
Calculates the value of one register modulus another
INS
Reads a string from stdin and puts it into memory pointed to by an argument register
OTS
Prints out a string pointed to by an argument register
INI
Reads an integer from stdin and puts it into memory pointed to by an argument register
OTI
Prints out an integer pointed to by an argument register
HLT
Stops execution of a program
LDI
Loads an immediate value into a register
MOV
Copies the value of one register into another
LDA
Loads the word at an address into a register
MVA
Loads the word pointed to by a register into another register
LRF
Loads the word in a register into memory
CPT
Copies the value pointed to by one register into memory pointed to by another
PSH
Pushes the value of a register onto the stack
POP
Pops the value on top of the stack into a register
INC
Increments the value of a register
DEC
Decrements the value of a register
ICP
Increments the value pointed to by a register
DCP
Decrements the value pointed to by a register
JMP
Unconditional jump
CMP
Compares the values of two registers and sets the proper flags
JNE
Jumps if the equals flag is not set
JE
Jumps if the equals flag is set
JLT
Jumps if the less-than flag is set
JGT
Jumps if the greater-than flag is set
CHK
Checks a register and sets the proper flags
JNZ
Jumps if the zero flag is not set
JZ
Jumps if the zero flag is set
CALL
Calls a subroutine
RET
Returns from a subroutine
SCMP
Compares two strings and sets the proper flags
SLEN
Takes the length of a string pointed to by a register and puts it into another register
ORG
Prints the value of a register to stdout
IRG
Reads a value from stdin and puts it into a register
DBG
Prints out the values of all registers
EXG
Exchanges the values of two registers
RAND
Puts a random integer into the argument register
Methods
impl Opcode
[src]
impl Opcode
pub fn from_id(id: u8) -> Self | [src] |
Returns an Opcode instance corresponding to a one-byte ID
Arguments
id
- The ID matching the desired opcode
Panics
This method will panic if the argument ID does not match any defined opcode.
pub fn from_name(name: &str) -> Self | [src] |
Returns an Opcode instance corresponding to a name string
Arguments
name
- The name of the desired opcode
Panics
This method will panic if the argument name does not match any defined opcode
pub fn get_id(&self) -> u8 | [src] |
Returns the ID of the Opcode
Trait Implementations
impl PartialEq<Opcode> for Opcode
[src]
impl PartialEq<Opcode> for Opcode
fn eq(&self, other: &Opcode) -> bool | [src] |
Compares two Opcodes and returns whether they are the same
Arguments
other
- The opcode to compareself
to
fn ne(&self, other: &Opcode) -> bool | [src] |
Compares two Opcodes and returns whether they are different
Arguments
other
- The opcode to compareself
to
impl Clone for Opcode
[src]
impl Clone for Opcode
fn clone(&self) -> Opcode | [src] |
fn clone_from(&mut self, source: &Self) | 1.0.0 [src] |
Performs copy-assignment from source
. Read more
impl Copy for Opcode
[src]
impl Copy for Opcode
impl Debug for Opcode
[src]
impl Debug for Opcode
impl FromStr for Opcode
[src]
impl FromStr for Opcode
type Err = String
Error type for the from_str method
fn from_str(s: &str) -> Result<Self, Self::Err> | [src] |
Parses a string and returns an Opcode instance matching the string wrapped in a Result instance
Arguments
s
- the string to parse
impl FromPrimitive for Opcode
[src]
impl FromPrimitive for Opcode
fn from_i64(n: i64) -> Option<Self> | [src] |
fn from_u64(n: u64) -> Option<Self> | [src] |
fn from_isize(n: isize) -> Option<Self> | [src] |
Convert an isize
to return an optional value of this type. If the value cannot be represented by this value, then None
is returned. Read more
fn from_i8(n: i8) -> Option<Self> | [src] |
Convert an i8
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_i16(n: i16) -> Option<Self> | [src] |
Convert an i16
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_i32(n: i32) -> Option<Self> | [src] |
Convert an i32
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_i128(n: i128) -> Option<Self> | [src] |
Convert an i128
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_usize(n: usize) -> Option<Self> | [src] |
Convert a usize
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_u8(n: u8) -> Option<Self> | [src] |
Convert an u8
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_u16(n: u16) -> Option<Self> | [src] |
Convert an u16
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_u32(n: u32) -> Option<Self> | [src] |
Convert an u32
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_u128(n: u128) -> Option<Self> | [src] |
Convert an u128
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_f32(n: f32) -> Option<Self> | [src] |
Convert a f32
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
fn from_f64(n: f64) -> Option<Self> | [src] |
Convert a f64
to return an optional value of this type. If the type cannot be represented by this value, then None
is returned. Read more
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |