CHIP-8 Assembler/Disassembler

Source Code Machine Code

=== Assembler Syntax ===

Code   Assembly           Description - All numbers are hexadecimal
----   --------           -----------------------------------------
       lbl:               A label - must not match any other string in the program!
nnnn - DATA nnnn          Initialize a data word (all values in hex)

0nnn - SYS addr           Jump to a machine code routine at nnn.
00E0 - CLS                Clear the display.
00EE - RET                Return from a subroutine.
1nnn - JP addr            Jump to location nnn.
2nnn - CALL addr          Call subroutine at nnn.
3xkk - SE Vx, byte        Skip If Equal Immediate: Skip next instruction if Vx = kk.
4xkk - SNE Vx, byte       Skip If Not Equal Immediate: Skip next instruction if Vx != kk.
5xy0 - SE Vx, Vy          Skip If Equal Register: Skip next instruction if Vx = Vy.
6xkk - LD Vx, byte        Load Immediate: Set Vx = kk.
7xkk - ADD Vx, byte       Add Immediate: Set Vx = Vx + kk.
8xy0 - LD Vx, Vy          Load Register: Set Vx = Vy.
8xy1 - OR Vx, Vy          Or Register: Set Vx = Vx OR Vy.
8xy2 - AND Vx, Vy         And Register: Set Vx = Vx AND Vy.
8xy3 - XOR Vx, Vy         XOR Register: Set Vx = Vx XOR Vy.
8xy4 - ADD Vx, Vy         Add Register: Set Vx = Vx + Vy, set VF = carry.
8xy5 - SUB Vx, Vy         Sub Register: Set Vx = Vx - Vy, set VF = NOT borrow.
8xy6 - SHR Vx {, Vy}      Shift Right: Set Vx = Vx SHR 1.
8xy7 - SUBN Vx, Vy        Sub Negative Register: Set Vx = Vy - Vx, set VF = NOT borrow.
8xyE - SHL Vx {, Vy}      Shift Left: Set Vx = Vx SHL 1.
9xy0 - SNE Vx, Vy         Skip If Not Equal: Skip next instruction if Vx != Vy.
Annn - LD I, addr         Load I Immediate: Set I = nnn.
Bnnn - JP V0, addr        Jump to V0 with offset nnn.
Cxkk - RND Vx, byte       Rand: Set Vx to a random number (0 to 255) AND byte value
Dxyn - DRW Vx, Vy, n      Draw: Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision.
Ex9E - SKP Vx             Skip if Key[Vx]: Skip next instruction if key with the value of Vx is pressed.
ExA1 - SKNP Vx            Skip if !Key[Vx]: Skip next instruction if key with the value of Vx is not pressed.
Fx07 - LD Vx, DT          Load Vx from Delay Timer: Set Vx = delay timer value.
Fx0A - LD Vx, K           Load Vx from next Key: Wait for a key press, store the value of the key in Vx.
Fx15 - LD DT, Vx          Load Delay Timer from Vx: Set delay timer = Vx.
Fx18 - LD ST, Vx          Load Sound Timer from Vx: Set sound timer = Vx.
Fx1E - ADD I, Vx          Add Vx to I: Set I = I + Vx.
Fx29 - LD F, Vx           Load I from Sprite location: Set I = location of sprite for digit Vx.
Fx33 - LD B, Vx           Load BCD from X into Memory[I]: Store BCD representation of Vx in memory locations I, I+1, and I+2.
Fx55 - LD [I], Vx         Save Registers: Store registers V0 through Vx in memory starting at location I.
Fx65 - LD Vx, [I]         Restore Register: Read registers V0 through Vx from memory starting at location I.

Note: You can convert a binary .ch8 file to hex for the Machine Code window with:

$ od -v -tx1 -An filename

For example:

$ od -v -tx1 -An bin/chip8/games/Maze.ch8
a2 1e c2 01 32 01 a2 1a d0 14 70 04 30 40 12 00
60 00 71 04 31 20 12 00 12 18 80 40 20 10 20 40
80 10