pub enum Opcode {
Show 41 variants
NOP = 0,
ADD = 1,
SUB = 2,
MPY = 3,
DIV = 4,
MOD = 5,
INS = 6,
OTS = 7,
INI = 8,
OTI = 9,
HLT = 10,
LDI = 11,
MOV = 12,
LDA = 13,
MVA = 14,
LRF = 15,
CPT = 16,
PSH = 17,
POP = 18,
INC = 19,
DEC = 20,
ICP = 21,
DCP = 22,
JMP = 23,
CMP = 24,
JNE = 25,
JE = 26,
JLT = 27,
JGT = 28,
CHK = 29,
JNZ = 30,
JZ = 31,
CALL = 32,
RET = 33,
SCMP = 34,
SLEN = 35,
ORG = 36,
IRG = 37,
DBG = 38,
EXG = 39,
RAND = 40,
}
Expand description
Defines various opcodes
Variants§
NOP = 0
No operation
ADD = 1
Add the values of two registers
SUB = 2
Subtract the value of one register from another
MPY = 3
Multiply the values of two registers
DIV = 4
Divide the value of one register by another
MOD = 5
Calculates the value of one register modulus another
INS = 6
Reads a string from stdin and puts it into memory pointed to by an argument register
OTS = 7
Prints out a string pointed to by an argument register
INI = 8
Reads an integer from stdin and puts it into memory pointed to by an argument register
OTI = 9
Prints out an integer pointed to by an argument register
HLT = 10
Stops execution of a program
LDI = 11
Loads an immediate value into a register
MOV = 12
Copies the value of one register into another
LDA = 13
Loads the word at an address into a register
MVA = 14
Loads the word pointed to by a register into another register
LRF = 15
Loads the word in a register into memory
CPT = 16
Copies the value pointed to by one register into memory pointed to by another
PSH = 17
Pushes the value of a register onto the stack
POP = 18
Pops the value on top of the stack into a register
INC = 19
Increments the value of a register
DEC = 20
Decrements the value of a register
ICP = 21
Increments the value pointed to by a register
DCP = 22
Decrements the value pointed to by a register
JMP = 23
Unconditional jump
CMP = 24
Compares the values of two registers and sets the proper flags
JNE = 25
Jumps if the equals flag is not set
JE = 26
Jumps if the equals flag is set
JLT = 27
Jumps if the less-than flag is set
JGT = 28
Jumps if the greater-than flag is set
CHK = 29
Checks a register and sets the proper flags
JNZ = 30
Jumps if the zero flag is not set
JZ = 31
Jumps if the zero flag is set
CALL = 32
Calls a subroutine
RET = 33
Returns from a subroutine
SCMP = 34
Compares two strings and sets the proper flags
SLEN = 35
Takes the length of a string pointed to by a register and puts it into another register
ORG = 36
Prints the value of a register to stdout
IRG = 37
Reads a value from stdin and puts it into a register
DBG = 38
Prints out the values of all registers
EXG = 39
Exchanges the values of two registers
RAND = 40
Puts a random integer into the argument register
Implementations§
Trait Implementations§
Source§impl FromPrimitive for Opcode
impl FromPrimitive for Opcode
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moreSource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more