pub enum Opcode {
Show 27 variants Nop, Stop, JumpRelative(ConditionCode), Inc8(Operand8), Dec8(Operand8), Load8 { dest: Operand8, source: Operand8, }, Inc16(Operand16), Dec16(Operand16), Load16 { dest: Operand16, source: Operand16, }, Add16(Operand16), Halt, AluOp { op: AluOp, operand: Operand8, }, AluUnary(AluUnaryOp), Call(ConditionCode), Jump(ConditionCode), Ret(ConditionCode), Push(Operand16), Pop(Operand16), PrefixCB, DisableInterrupts, EnableInterrupts, RetInterrupt, OffsetSp, AddressOfOffsetSp, JumpHL, Reset(u8), MissingInstruction(u8),
}
Expand description

Parsed Opcode, not including any arguments that may be loaded from immediates, nor any follow-up ops if the operation is a prefixed op.

Variants§

§

Nop

No operation.

§

Stop

Stop – not sure what this does or how this differs from Halt.

§

JumpRelative(ConditionCode)

Relative jump. Load a signed immediate for the jump destination, then check the condition, then jump if the condition is met.

§

Inc8(Operand8)

Increment the given 8 bit operand.

§

Dec8(Operand8)

Decrement the given 8 bit operand.

§

Load8

Fields

§source: Operand8

Load a value from on 8 bit operand to another.

§

Inc16(Operand16)

Increment the given 16 bit operand.

§

Dec16(Operand16)

Decrement the given 16 bit operand.

§

Load16

Fields

§source: Operand16

Load a 16 bit value from one operand to another.

§

Add16(Operand16)

Add the given 16 bit operand to HL.

§

Halt

Halt instruction. Pauses but still accepts interrupts.

§

AluOp

Fields

§operand: Operand8

Run the given operation on the ALU. The source is given by the operand, the destination is always A, the accumulator register.

§

AluUnary(AluUnaryOp)

Run the given unary operation on the ALU. These ops all affect only the accumulator and flags, or just the flags.

§

Call(ConditionCode)

Conditional call. Load unsigned 16 bit immediate, check condtion, then if condition matches push current PC and jump to the loaded address.

§

Jump(ConditionCode)

Conditional absolute jump. Load unsigned 16 bit immediate, check condition, then if condition matches, jump to the loaded address.

§

Ret(ConditionCode)

Conditional return. Check the condition, then pop the stack and jump to the address.

§

Push(Operand16)

Push a 16 bit register pair to the stack, moving the stack pointer.

§

Pop(Operand16)

Pop a 16 bit register pair from the stack, moving the stack pointer.

§

PrefixCB

Loads and executes a prefixed instruction code.

§

DisableInterrupts

Disable interrupt handling.

§

EnableInterrupts

Enable Interrupt handling.

§

RetInterrupt

Interrupt return, similar to unconditional return but also enables interrupts.

§

OffsetSp

Load an 8 bit signed immediate and add it to the stack pointer.

§

AddressOfOffsetSp

Load an 8 bit signed immediate and add it to the stack pointer, storing the result in HL.

§

JumpHL

Jump to the address stored in HL.

§

Reset(u8)

Reset with numeric arg.

§

MissingInstruction(u8)

The instruction decoded to an opcode the processor doesn’t actually have. This functions equivalently to Nop (I think????). Contained value is the raw opcode.

Implementations§

source§

impl Opcode

source

pub fn decode(opcode: u8) -> Self

Decodes a u8 to an Opcode. All possible u8 values are valid Opcodes, so this cannot fail.

Trait Implementations§

source§

impl Clone for Opcode

source§

fn clone(&self) -> Opcode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Opcode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Opcode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Opcode> for InstrDef

source§

fn from(value: Opcode) -> Self

Converts to this type from the input type.
source§

impl Ord for Opcode

source§

fn cmp(&self, other: &Opcode) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Opcode> for Opcode

source§

fn eq(&self, other: &Opcode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Opcode> for Opcode

source§

fn partial_cmp(&self, other: &Opcode) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Opcode

source§

impl Eq for Opcode

source§

impl StructuralEq for Opcode

source§

impl StructuralPartialEq for Opcode

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.