pub enum Instruction {
Show 25 variants
CLS,
RET,
JMP(JmpData),
CALL(CallData),
SKIP(SkipData),
MOV(MovData),
ADD(AddData),
OR(OrData),
AND(AndData),
XOR(XorData),
SUB(SubData),
SHR(ShrData),
SUBN(SubnData),
SHL(ShlData),
JPC(JpcData),
RAND(RandData),
DRAW(DrawData),
GDL(GdlData),
KEY(KeyData),
SDL(SdlData),
SND(SndData),
SCH(SchData),
BCD(BcdData),
RDP(RdpData),
RLD(RldData),
}Expand description
A Chip-8 instruction. All instructions that execute a calculation store the result in their first argument.
Variants§
CLS
Clears the screen
RET
Returns from a subroutine
JMP(JmpData)
Unconditionally jumps to an address
CALL(CallData)
Calls a subroutine
SKIP(SkipData)
Skips the next instruction if
a SkipType condition is met
MOV(MovData)
Assigns values to registers or moves one register’s value into another
ADD(AddData)
Adds two registers, or
a register and a value.
When both operands are
registers, VF is set to 1
when the result
exceeds the size of the
destination register, and 0
otherwise.
OR(OrData)
Bitwise ORs two registers
AND(AndData)
Bitwise ANDs two registers
XOR(XorData)
Bitwise XORs two registers
SUB(SubData)
Subtracts one register
from another, with the
second register subtracted
from the first. VF is
set to 0 when there’s
a borrow, and 1 if
there isn’t.
SHR(ShrData)
Stores the least significant
bit of a register in VF
and shifts that register
to the right 1 bit
SUBN(SubnData)
Subtracts one register
from another, with the
first register subtracted
from the second. VF is
set to 0 when there’s
a borrow, and 1 when
there isn’t.
SHL(ShlData)
Stores the most significant
bit of a register in VF
and shifts that register
to the left one bit
JPC(JpcData)
Unconditionally jumps to
an address defined by
a constant plus the
V0 register
RAND(RandData)
Stores a random 8-bit integer bitwise ANDed with a given constant in a register
DRAW(DrawData)
Draws a sprite at
coordinates defined
by two registers with
a width of 8 pixels
and a given height. The
sprite is read as bits
from memory starting at
address I. VF is set
to 1 if any pixels are
flipped from on to off, and
to 0 if not.
GDL(GdlData)
Sets a register to the current value of the delay timer
KEY(KeyData)
Stops execution until a key is pressed, then stores that key in a register
SDL(SdlData)
Sets the delay timer to the value of a register
SND(SndData)
Sets the sound timer to the value of a register
SCH(SchData)
Puts the memory location
of the hex character
corresponding to the value
of a register into I
BCD(BcdData)
Stores the binary-coded decimal
representation of a register
in memory location I, with
the hundreds digit in the lowest
byte.
RDP(RdpData)
Dumps the contents of all registers
up to and including a specified register
into memory starting at location I
RLD(RldData)
Loads all registers up to and including
a specified register from data starting
at location I