asm6502 0.1.2

A basic 6502 assembler.
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 93.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 356.46 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • bgourlie/asm6502
    20 3 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bgourlie

asm6502

Build Status Crates.io

A work-in-progress 6502 assembler.

This assembler currently serves the immediate needs of my NES emulator. As such, it doesn't do anything except translate literal 6502 assembly into machine code. Not even labels are supported, and relative addresses must specify a numeric offset. Any contributions are welcome, however. I'd love for this to become a more fully-featured assembler.

Usage

use asm6502::assemble;

let asm = "LDA #1\nADC #1\nCMP #2".as_bytes();
let mut buf = Vec::<u8>::new();
if let Err(msg) = assemble(asm, &mut buf) {
     panic!("Failed to assemble: {}", msg);
}
 
assert_eq!(&[0xa9, 0x1, 0x69, 0x1, 0xc9, 0x2], &buf[..]);

The the input and output parameters of the assemble function are generic over the Read and Write traits, respectively. A more typical usage of this function would accept an input file and an output file.

Known Issues

If the assembly ends with an implied instruction, it will need to be followed by a newline in order to be parsed correctly, and will fail to parse otherwise. See my StackOverflow question here documenting the issue and the work-in-progress nom pull request addressing the underlying issue.