Log inGet started
Package

snes.package

Newest version

README.md

snes.spcasm — SPC700 assembler

A two-pass SPC700 assembler in Luau for Super Nintendo sound programs (the APU's IPL boot ROM and the homebrew sound driver are built with it).

local SpcAsm = require("snes.spcasm")
local bytes, symbols, base = SpcAsm.assemble(source, { org = 0x0200, blobs = { samples = "..." } })
  • Sony-style syntax: mov a,#$12, mov $12,a, mov !$1234,a, mov a,(x), mov a,(x)+, mov a,[$12+x], mov a,[$12]+y, mov a,$12+x, mov a,!table+y, mov $12,#$34, mov $12,$34 (dest, source), movw ya,$12, set1 $12.3, bbs $12.3,label, cbne $12,label, dbnz y,label, mov1 c,$1234.5, or1 c,/$1234.5, tcall 3, pcall $80, call label, jmp [!table+x], push psw, mul ya, div ya,x, every opcode of the set.
  • Operand sizes are decided in pass 1: !expr is absolute; otherwise a value known in pass 1 and <= $FF is direct page and anything else absolute.
  • Directives: org, db/byte, dw/word, ds n[,fill], align n, assert expr, incbin name (bytes from opts.blobs[name]), name equ expr / name = expr; labels name:, local .x. Expressions as in snes.asm (shares its evaluator).
  • Returns the bytes from the lowest to the highest address written, the symbol table and the lowest address.