UTTORI ASM · IN DEVELOPMENT
Fill, reserve, and alignment
Write assembly using fill, reserve, and alignment, with examples and limits.
On this page
Details
Native Fill and Pad
fillbyte $12
fill 4 ; 12 12 12 12
padbyte $FF
pad $9000
Native syntax does not split fillbyte $12 : fill 4 into two statements. Put them on separate lines.
fill count emits count bytes from the current fill pattern. pad with a target fills until that address. With no address it fills to the next 64 KiB boundary (which, on a 16-bit target, is usually not what you wanted — prefer an explicit address or .res).
ca65 .res and .align
.res 2, $AA ; AA AA
.align 8, $FF ; pad to the next multiple of 8
.res count[, fill] emits count bytes of fill (default 0). .align boundary[, fill] pads with fill (default 0) until PC % boundary == 0. These write into the current image. They are not BSS in a RAM-only MEMORY region unless that region is the active load window.
NES Prefill
The NES lifecycle fills the entire PRG with fillByte (default $FF) before source runs. Unused PRG therefore reads as $FF without an explicit pad. fillByte also becomes session.outputFillByte.
On 65xx.ca65-raw, .segment "NAME" records the name and .pushseg / .popseg stack it, but bytes remain in source order in one flat image. Segment names are accepted so sources can keep their .segment lines. They do not create separate output regions.