Crate rustasm6502[][src]

Expand description

A MOS6502 assembler implemented as a macro.

Note: Due to limitations in Rust macros, there are two deviations from a typical 6502 assembly syntax:

  • For absolute addressing mode, you need to use abs after the mnemonic (eg. lda abs 0xffff).
  • For accumulator addressing mode, you need to use a after the mnemonic (eg. lsr a).

Example

#[macro_use] #[no_link]
extern crate rustasm6502;

fn main() {
    let machine_code = assemble6502! {
        lda #0x00
        ldx #0x00
        ldy #0x00
        txs

    main:
        adc 0xff        // Zero-Page
        adc abs 0x1234  // Absolute address 0x1234
        ror a           // Rotate the accumulator
        beq main
    end:
        jmp end
    };

    assert_eq!(machine_code, [
        0xA9, 0x00,
        0xA2, 0x00,
        0xA0, 0x00,
        0x9A,

        0x65, 0xff,
        0x6D, 0x34, 0x12,   // Little-endian
        0x6A,
        0xF0, (-8i8) as u8,

        0x4C, 15, 0,
    ]);
}

Macros

Entry point for the macro-based MOS6502 assembler.