Enum chip8_vm::instructions::Instruction
[−]
[src]
pub enum Instruction { Sys(Addr), Clear, Return, Jump(Addr), Call(Addr), SkipEqualK(Vx, Byte), SkipNotEqualK(Vx, Byte), SkipEqual(Vx, Vy), SetK(Vx, Byte), AddK(Vx, Byte), Set(Vx, Vy), Or(Vx, Vy), And(Vx, Vy), XOr(Vx, Vy), Add(Vx, Vy), Sub(Vx, Vy), ShiftRight(Vx, Vy), SubInv(Vx, Vy), ShiftLeft(Vx, Vy), SkipNotEqual(Vx, Vy), LoadI(Addr), LongJump(Addr), Rand(Vx, Byte), Draw(Vx, Vy, Nibble), SkipPressed(Vx), SkipNotPressed(Vx), GetTimer(Vx), WaitKey(Vx), SetTimer(Vx), SetSoundTimer(Vx), AddToI(Vx), LoadHexGlyph(Vx), StoreBCD(Vx), StoreRegisters(Vx), LoadRegisters(Vx), Unknown, }
High-level instruction
A valid instruction that can be executed as-is.
Variants
Sys(Addr)
Jumps to machine subroutine at Addr
.
Note that this is intentionally not implemented in the Vm
.
Clear
Clears the screen.
Sets all pixels to the unlit state.
Return
Returns from a subroutine
Jump(Addr)
Jumps to Addr
Call(Addr)
Calls subroutine at Addr
SkipEqualK(Vx, Byte)
Skips the next instructions if Vx
equals Byte
SkipNotEqualK(Vx, Byte)
Skips the next instruction if Vx
does not equal Byte
SkipEqual(Vx, Vy)
Skips the next instruction if Vx
and Vy
are equal
SetK(Vx, Byte)
Sets Vy
to Byte
AddK(Vx, Byte)
Adds Byte
to Vx
, then stores the result in Vx
Set(Vx, Vy)
Stores Vy
in Vx
Or(Vx, Vy)
Performs a bitwise OR (|
) of Vx
and Vy
, then stores the result in Vx
And(Vx, Vy)
Performs a bitwise AND (&
) of Vx
and Vy
, then stores the result in Vx
XOr(Vx, Vy)
Performs a bitwise XOR (^
) of Vx
and Vy
, then stores the result in Vx
Add(Vx, Vy)
Adds Vx
and Vy
, then stores the result in in Vx
.
VF
is set to 1
on overflow, 0
otherwise.
Sub(Vx, Vy)
Subtracts Vy
from Vx
, then stores the result in Vx
.
VF
is set to 1
if Vx
is larger than Vy
prior subtraction, 0
otherwise.
ShiftRight(Vx, Vy)
Shifts Vy
right by one bit, then stores the result in Vx
.
Stores the least-significant bit prior shift of Vy
in VF
.
SubInv(Vx, Vy)
Subtracts Vx
from Vy
, then stores the result in Vx
.
VF
is set to 1
if Vx
is larger than Vy
prior subtraction, 0
otherwise.
Note that this is the same as Sub
with inverted register operands.
ShiftLeft(Vx, Vy)
Shifts Vy
left by one bit, then stores the result in Vx
.
Stores the most-significant bit prior shift of Vy
in VF
.
SkipNotEqual(Vx, Vy)
Skips the next instruction if Vx
and Vy
are not equal
LoadI(Addr)
Sets the I
register to Addr
LongJump(Addr)
Jumps to V0 + Addr
Rand(Vx, Byte)
Sets Vx
to a random byte ANDed with Byte
Draw(Vx, Vy, Nibble)
Draws the sprite with Nibble
bytes of data from the I
register at position (Vx, Vy)
.
Sets VF
to 1
if any pixels are set to unlit state, 0
otherwise.
Note that sprites wrap around onto the opposite side of the screen.
SkipPressed(Vx)
Skips the next instruction if key Vx
is pressed
SkipNotPressed(Vx)
Skips the next instruction if key Vx
is not pressed
GetTimer(Vx)
Stores the value of the delay timer
in Vx
WaitKey(Vx)
Stops execution until a key is pressed, then stores that key in Vx
SetTimer(Vx)
Sets the delay timer
to Vx
SetSoundTimer(Vx)
Sets the sound timer
to Vx
AddToI(Vx)
Adds Vx
and the I
register, then stores the result in I
LoadHexGlyph(Vx)
Stores the address of the hexadecimal digit Vx
in the I
register
StoreBCD(Vx)
Stores the binary-coded decimal representation of Vx
at address I
, I + 1
and I + 2
StoreRegisters(Vx)
Stores the registers V0
to Vx
inclusive at address I
.
Register I
is set to I + Vx + 1
afterwards.
LoadRegisters(Vx)
Reads the registers V0
to Vx
inclusive from address I
.
Register I
is set to I + Vx + 1
afterwards.
Unknown
Placeholder for an unknown or illegal instruction.
Note that this is not a real CHIP-8 instruction.
Methods
impl Instruction
[src]
fn from_raw(raw: &RawInstruction) -> Instruction
Creates a new instruction from raw bits,
or Instruction::Unknown
if no valid match could be found
Trait Implementations
impl Clone for Instruction
[src]
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more