The most awesomest 6502 assembler you've ever seen in your life!
nyasm is a toy 6502 assembler I made in order to learn Rust. It's currently pretty early on and there will probably be breaking changes in the future. Right now it's in a state where it can successfully assemble a valid NES ROM file, although some features might still be incomplete or missing entirely (including external binary files is possible now, but including other assembly files isn't for example).
nyasm can be built using
$ cargo build --release
The resulting binary will appear at
To assemble a file using nyasm, give the input and output filenames to the
nyasm binary like this:
$ nyasm input.asm -o output.nes
You can also pipe data into and out of the assembler without accessing the filesystem directly:
$ nyasm < input.asm > output.nes
See the demos folder for examples of what nyasm can do currently.
You can use the
label_name: syntax to declare a label:
my_label: jmp my_label
If you want, you can also use the
.label directive instead, with no
difference in behavior:
.label my_label jmp my_label
Comments can be written using a semicolon:
; This is where the magic begins... reset: lda #$2a ; 42 in hex!
Directives with multiple parameters have them separated with a comma:
reset: .addr reset,reset,reset ; Writes the address of the reset label 3 times .pad $4000,$2a
Directives with string values should have them wrapped in quotes to preserve casing:
dialog_text: .incbin "includes/dialog.txt"
Normal instructions and directives are case insensitive:
RESET: .BYTE $01,$23,$AB,$CD
Here's a list of the assembler directives that nyasm currently supports:
Places one or more 8-bit values into the assembled binary:
.byte, but for 16-bit values:
An alternative syntax for declaring labels:
Sets the "origin point" for labels, or where the first byte in the assembled file would map to in the CPU's address space:
.org $7ff0 ; The beginning of the NES PRG-ROM minus the 16-byte header
Pads the assembled file with zeros up until the specified address:
You can also provide a custom byte to pad with by setting the second parameter:
Includes the specified file as binary data in the assembled file:
All paths given are relative to the currently navigated directory in the terminal emulator.