Topics

UTTORI ASM ยท IN DEVELOPMENT

SNES fill, pad, and freespace

Use snes fill, pad, and freespace in SNES projects, with syntax and behavior notes.

On this page

SNES behavior

Fill Patterns

fillbyte  $12 : fill 4   ; 12 12 12 12
fillword  $1234 : fill 4 ; 34 12 34 12
filllong  $123456
filldword $12345678

fillbyte, fillword, filllong, and filldword tile a little-endian value into a 12-byte repeating fill pattern. fill count emits exactly count bytes from that pattern. Zero is a no-op. Negative and malformed counts fail through numeric or write validation.

Padding

padbyte, padword, padlong, and paddword choose a little-endian pad unit. With a target, pad fills until that mapped logical address:

padbyte $FF
pad $018000

With no address, pad fills to the next 64 KiB boundary. A target at or behind the current output position is a no-op. An unmapped target is an error.

Freespace & RATS

freespacebyte $FF
freecode
InjectedRoutine:
  rtl

freecode, freedata, and freespace currently share one allocator. It chooses max($080000, current base/output length), expands the output to at least 1 MiB, writes an eight-byte STAR RATS header, and places content immediately afterward. During finalization it fills the RATS length and complement from the bytes written in the active block.

This is deterministic append-style allocation, not a general scanner that hunts every island of free bytes in an arbitrary ROM. Multiple sophisticated allocations, shrinking old blocks, alignment settings, and SA-1/Super FX-specific freespace policies remain outside the supported contract.

freespacebyte value sets both the expansion fill byte and the active output fill byte. Freespace is unavailable in norom and inside spcblock.

prot label[,label...] emits an Asar-style PROT record containing 24-bit label addresses. Unresolved labels are temporarily encoded as zero during early stages and resolved during emission. autoclean and autoclear are accepted no-ops. They do not reclaim an earlier RATS block.