Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage snes.package·originates fromworld 47b50fcd-5…

asm

A two-pass 65C816 assembler in Luau, for Super Nintendo homebrew built inside the engine (also fine for any 65816 / 6502-family target).

by◐Deata·posted 2d ago
What it does

snes.asm — 65C816 assembler

A two-pass 65C816 assembler in Luau, for Super Nintendo homebrew built inside the engine (also fine for any 65816 / 6502-family target).

local Asm = require("snes.asm")
local bin, symbols = Asm.assemble(source, { map = "lorom", size = 0x40000, fill = 0xFF, blobs = { tiles = "..." } })
  • Addresses are 24-bit. org $808000 sets the full address; the file offset comes from the map: lorom = (bank & $7F) * $8000 + (addr & $7FFF), running past $FFFF continues at the next bank's $8000; hirom = addr & $3FFFFF; flat = addr - org of the first org.
  • Immediate widths: .a8 .a16 .i8 .i16 (also .smart-style tracking: rep #$20/$10/$30 and sep with a constant switch the widths for the lines after them), or a .b/.w suffix on the mnemonic.
  • Operand sizes are decided in pass 1 so the layout never moves: <expr direct page, !expr or |expr absolute, >expr long; a mnemonic suffix .b .w .l does the same. Without a prefix: a value known in pass 1 that is <= $FF is direct page, a plain number literal > $FFFF is long, everything else is absolute (labels are absolute: their bank comes from DBR/PBR). jsl/jml are always long.
  • Every 65816 addressing mode: #, dp, dp,x, dp,y, (dp), (dp,x), (dp),y, [dp], [dp],y, abs, abs,x, abs,y, long, long,x, sr,s, (sr,s),y, (abs) / (abs,x) for jmp/jsr, [abs] for jml, rel8, rel16 (brl, per), mvn src,dst / mvp src,dst (bank numbers or #bank, written in WLA/ca65 source order: source first).
  • Directives: org, db/byte, dw/word, dl/long (24-bit), ds n[,fill], align n, assert expr, incbin name (bytes from opts.blobs[name]), name equ expr / name = expr.
  • Expressions: $FF, 0xFF, %0101, 'c', * (here), + - * / % << >> & | ^ ~ ( ), lo() hi() bank() and ^label (bank byte).
  • Labels name:, local .x scoped to the last global label. Errors name the line.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict

fail(ctx: Ctx, msg: string) → never

argtypedescription
ctxCtx
msgstring

tokenize(s: string) → void

expressions

argtypedescription
sstring

number(t: string) → number

argtypedescription
tstring

symName(ctx: Ctx, t: string) → string

argtypedescription
ctxCtx
tstring

eval(ctx: Ctx, s: string) → number

argtypedescription
ctxCtx
sstring

peek( ) → string

take( ) → string

atom( ) → number

mul( ) → number

add( ) → number

sh( ) → number

bitand( ) → number

bitxor( ) → number

expr( ) → void

group(base: number, nm: string) → void

argtypedescription
basenumber
nmstring

baseMnem(k: string) → string

argtypedescription
kstring

isMnemonic(k: string) → boolean

argtypedescription
kstring

splitOperands(s: string) → void

argtypedescription
sstring

stripComment(s: string) → string

argtypedescription
sstring

wrapped(s: string) → void

argtypedescription
sstring

assemble(src: string, opts: any?) → void

assemble

argtypedescription
srcstring
optsany?

fileOff(pc: number) → number

argtypedescription
pcnumber

emit(b: number) → void

argtypedescription
bnumber

ev(x: string) → number

argtypedescription
xstring

define(name: string, v: number) → void

argtypedescription
namestring
vnumber

w8(v: number) → void

argtypedescription
vnumber

w16(v: number) → void

argtypedescription
vnumber

w24(v: number) → void

argtypedescription
vnumber

sizeOf(x: string, force: string?) → void

operand size, decided once in pass 1: "dp" | "abs" | "long"

argtypedescription
xstring
forcestring?

relTo(x: string, nextPc: number, wide: boolean) → number

argtypedescription
xstring
nextPcnumber
wideboolean

encode(mnem: string, args: { string }) → void

argtypedescription
mnemstring
args{ string }

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.