#[non_exhaustive]pub enum Instruction {
Show 49 variants
Halt,
Exit(Option<u8>),
ScrollUp(u4),
ScrollDown(u4),
ScrollRight,
ScrollLeft,
Clear,
Return,
ToggleLoadStoreQuirk,
LoRes,
HiRes,
CallMachineCode(u12),
Jump(u12),
Call(u12),
SkipIfEqual(Register, Byte),
SkipIfNotEqual(Register, Byte),
Add(Register, Byte),
Set(Register, Byte),
Or(Register, Register),
And(Register, Register),
Xor(Register, Register),
Sub(Register, Register),
ShiftRight(Register, Register),
ShiftLeft(Register, Register),
SubReverse(Register, Register),
SetIndex(u12),
SetIndexLong(u16),
JumpRelative(u12),
Random(Register, u8),
Draw(Register, Register, u4),
SkipKey(Register),
SkipNotKey(Register),
LoadAudio,
LoadDelay(Register),
BlockKey(Register),
SelectPlane(u4),
SetPitch(Register),
SetDelay(Register),
SetSound(Register),
AddRegisterToIndex(Register),
FontCharacter(Register),
BigFontCharacter(Register),
Bcd(Register),
Store(Register),
Load(Register),
StoreRange(Register, Register),
LoadRange(Register, Register),
StoreFlags(Register),
LoadFlags(Register),
}
Expand description
CHIP-8 instructions.
This instruction set is mostly based on what Octo supports, which comprises the specifications for CHIP-8, SUPER-CHIP and XO-CHIP.
However, there is also support for some more esoteric instructions, especially where there are no collisions in the opcode space.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Halt
Halt the CHIP-8 interpreter.
Based on Octo’s behavior when encountering 0000
.
Exit(Option<u8>)
Exit the CHIP-8 interpreter with an optional exit code.
Based on the following opcodes:
00FD
: Exit interpreter (from SUPER-CHIP 1.1)001N
: Exit with exit codeN
(fromchip8run
)
ScrollUp(u4)
Scroll the display up.
Based on the following opcodes:
00BN
: Scroll up by N pixels (from Massung’s SUPER-CHIP interpreter and Mega-Chip)00DN
: Scroll up by N pixels (from XO-CHIP)
ScrollDown(u4)
Scroll the display down.
Based on the following opcode:
00CN
: Scroll down by N pixels
ScrollRight
Scroll the display right.
ScrollLeft
Scroll the display left.
Clear
Clear the display.
Return
Return from subroutine.
ToggleLoadStoreQuirk
Toggle the behavior of Instruction::Load
and Instruction::Store
LoRes
Change display to low resolution (“lores”) mode, 64x32 pixels
HiRes
Change display to high resolution (“hires”) mode, 128x64 pixels
CallMachineCode(u12)
Call machine code routine.
Jump(u12)
Jump to memory address
Call(u12)
Call subroutine
SkipIfEqual(Register, Byte)
Skip the next instruction if
SkipIfNotEqual(Register, Byte)
Add(Register, Byte)
Set(Register, Byte)
Or(Register, Register)
And(Register, Register)
Xor(Register, Register)
Sub(Register, Register)
ShiftRight(Register, Register)
ShiftLeft(Register, Register)
SubReverse(Register, Register)
SetIndex(u12)
SetIndexLong(u16)
JumpRelative(u12)
Random(Register, u8)
Draw(Register, Register, u4)
Draw a sprite on the display.
SkipKey(Register)
SkipNotKey(Register)
LoadAudio
LoadDelay(Register)
BlockKey(Register)
SelectPlane(u4)
SetPitch(Register)
SetDelay(Register)
SetSound(Register)
AddRegisterToIndex(Register)
FontCharacter(Register)
BigFontCharacter(Register)
Bcd(Register)
Store(Register)
Load(Register)
StoreRange(Register, Register)
LoadRange(Register, Register)
StoreFlags(Register)
LoadFlags(Register)
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more