Topics

UTTORI ASM ยท IN DEVELOPMENT

First raw 6502 image

Assemble a small raw 6502 program and inspect the exact output bytes.

The smallest useful 65xx program is a few documented NMOS instructions. Save this as tiny.asm:

Try a raw 6502 program

This small program starts at $8000. The same source also assembles as 65816, where LDA #$0012 takes a second immediate byte. Without JavaScript, the five 6502 bytes are shown.

Output bytes78 A9 12 85 34

Expected output

Build a file

; tiny.asm
; Headerless 6502 bytes starting at CPU $0000 / file offset 0.

org $0000

Reset:
  lda #$12        ; immediate
  sta $34         ; zero page
  lda $1234       ; absolute
  lda ($20),y     ; indirect indexed
  bne Reset
  brk #$42        ; optional signature byte
npx uttori-asm tiny.asm tiny.bin \
  --plugin @uttori/asm-plugin-65xx \
  --target 65xx.raw \
  --architecture 65xx.6502

The result is the thirteen-byte sequence A9 12 85 34 AD 34 12 B1 20 D0 F5 00 42.

For a program that should load at $8000 without a 32 KiB prefix, set "origin": 32768 in plugin options and org $8000. org $8000 with origin 0 really does emit 32,768 prefix bytes.

That is enough to prove the encoder, origin math, and .b/.w width forcing. A cartridge image still needs a header, vectors, and a picture. That is the next section.