This is an assembler for the CHIP-8 instruction set written entirely in Emacs Lisp. Together with chip8.el, this means you can assemble and run CHIP-8 programs without the need of external tools.
Both CHIP-8 and Super Chip-48 instructions are implemented.
You can install this package with Quelpa, straight.el or by manually requiring the chip8-asm.el
file.
Use the chip8-asm
interactive function in order to assemble the current file. You will be asked for the path to the output binary.
For a list of available instructions and their synthax, look at Cowgod’s Chip-8 Technical Reference.
Labels are written with a colon separating them from the following instructions. Labels can be used in place of addresses.
label:
JP label
Any text following a semicolon is considered a comment
; This is a comment
In order to define where the following instructions and/or data are placed in memory, you can use the org
command.
org $200
There is no distinction between immediate values and addresses, since the instruction set uses them in completely separate instructions.
%
is used for binary integers.
%1111
No prefix is used for decimal integers.
15
$
is used for hexadecimal numbers.
$F
You can add bytes to the binary using the db
command followed by a list of numbers each representing a byte.
small_o: db %00000000
db %11110000
db %10010000
db %11110000
org $200
HIGH
LD I, sprite
LD V0, $32
LD V1, $16
DRW V0, V1, 0
end: JP end
sprite:
db $55 $55 $55 $55
db $55 $55 $55 $55
db $55 $55 $55 $55
db $55 $55 $55 $55