Topics

UTTORI ASM · IN DEVELOPMENT

NMOS 6502

Use nmos 6502 in 6502-family and NES projects, with syntax and limits.

The default encoder accepts the 151 documented NMOS opcodes plus the current-ca65-guide BRK signature extension (BRK, BRK #$nn, BRK $nn). Pinned ca65 V2.19 rejects the signature forms. This encoder keeps them for guide compatibility.

arch 6502
org $8000

lda #$12
sta $34
lda.w $12          ; force absolute: AD 12 00
lda.b $12          ; force zero page: A5 12
jmp ($1234)        ; NMOS: the high-byte fetch wraps in-page when the pointer ends in $FF
bne Reset

Append .b or .w to force zero-page or absolute selection where the instruction has both. An explicit suffix cannot invent an addressing mode the processor does not possess: lda.w #$12 is an error, and stx.w $12,y cannot become STX abs,y because that form does not exist. Parentheses still decide indirect forms, and branches still enforce their signed displacement range.

Zero-page versus absolute is otherwise inferred from the operand's resolved width. A symbol equated to $00–$FF encodes as zero page. $100 and up encode as absolute. That is deterministic across passes only when the equate is static.

JMP ($xxFF) is encoded as the documented $6C form. NMOS hardware wraps the high-byte fetch within the same page. CMOS and later chips do not. The encoder emits the byte. It does not rewrite the addressing mode.