Instructions are divided by Nibble.
Structure
- First Nibble: Instruction type
- Second Nibble (
X): one of the registersV0-VF - Third Nibble (
Y): one of the registersV0-VF - Fourth Nibble (
N): A 4-bit number - Fourth + Fifth Nibble (
NN): A 8-bit immediate number - Fourth + Fifth + Sixth Nibble (
NNN): A 12-bit memory address
Instructions Table
| Code | Description |
|---|---|
00E0 | Clear screen |
1NNN | Jump, or set PC to NNN |
6XNN | Set register VX |
7XNN | Add value to register VX. Overflow Flag not affected |
ANNN | Set memory register I to NNN |
DXYN | Display/Draw N pixel tall sprite from memory location at Index Register I at coordinate VX,VY.All pixels that are 1 in the original sprite will turn the same pixels on at the memory location. If any pixels were turned off, set VF flag to 1.Sprite image should not wrap. |
0NNN | Execute subroutine at address NNN |
00EE | Return from subroutine by popping last address from stack |
2NNN | Call subroutine at memory location NNN |
3XNN | Branch statement if VX = NN |
4XNN | Branch statement if VX != NN |
5XY0 | Branch statement if VX = VY |
9XY0 | Branch statement if VX != VY |
8XY0 | Set the value VX to VY |
8XY1 | Set VX to Bitwise OR of VX, VY |
8XY2 | Set VX to Bitwise AND of VX, VY |
8XY3 | Set VX to Bitwise XOR of VX, VY |
8XY4 | Set VX to addition of VX, VY. Affects Carry Flag |
8XY5 | Set VX to subtraction VX - VY. Set VF to 1 if we have a natural remainderSet VF to 0 if we underflow |
8XY7 | Set VX to subtraction VY - VXSet VF to 1 if we have a natural remainderSet VF to 0 if we underflow |
8XY6 | Put value of VY into VX, then Bitwise Right Shift by oneSet VF to the bit that was shifted out. |
8XYE | Put value of VY into VX, then Bitwise Left Shift by oneSet VF to the bit that was shifted out. |
BNNN | Jump with offset NNN + V0 used as Jump Table |
CXNN | Generate a random number, Bitwise AND with NN and store result in VX |
EX9E | Skip instruction (increment PC by 2) if pressing a key corresponding to VX |
EXA1 | Skip instruction (increment PC by 2) if key in VX is not pressed. |
FX07 | Set VX to current value of CHIP-8 Delay Timer |
FX15 | Set CHIP-8 Delay Timer to value in VX |
FX18 | Set CHIP-8 Sound Timer to value in VX |
FX1E | Set Index Register I adds value in VX. Triggers Overflow Flag |
FX0A | Yield until key at VX is pressed. Decrements PC if PC is incremented during fetch of Sec-Fetch-Dest |
FX29 | Index register I set to address of hexadecimal character in VX |
FX33 | Binary-coded decimal conversion. Takes number in VX and converts it into 3 decimal digits at Index Register I.E.g: VX = 153. Then, I = 1, I+1 = 5, I+2 = 3 |
FX55 | Store all register values up to VX (V0-VX) at I. So:I : V0I+1 : V1… I+X : VX |
FX65 | Load all register values up to VX (V0-VX) starting from I. So:V0 : I… VX : I+X |