Skip to content

as65: implement -n properly (currently an accepted no-op) #118

Description

@relmer

-n is accepted by CassoCli in as65 mode and does nothing. It is parsed, stored
in disableOpt, copied into AssemblerOptions, and read by no code.

In real as65 it is not a no-op:

-n — "Disable optimizations. When this option is specified no
optimizations will be done, even when the OPT pseudo-instruction is used."

Source: as65 1.42 manual, https://raw.githubusercontent.com/Ludoclt/as65_142/master/as65.man

So it has to override OPT, not merely skip a default.

The optimization it has to disable

Operand mode selection picks zero page when the address fits — AssemblySession.cpp,
the expr candidate list, "a branch target, a jump target, then zero page if it
fits". Nothing there consults disableOpt.

Measured on the built binary:

        ORG $6000
        LDA $0010
        RTS
bytes
without -n A5 10 60 — zero page
with -n A5 10 60 — identical

Acceptance

  • -n suppresses the zero-page selection, so LDA $0010 assembles to AD 10 00.
  • It does so even where OPT asks for optimization.
  • Covered by a test that fails when the behavior is removed.

-i needed no work and has been closed out

This issue used to cover -i as well. It does not any more, because the
behavior as65 documents was already unconditional here.

-i — "Ignore case in opcodes. In this way, the assembler does not
differentiate between adc and ADC, for example. Labels are still case
sensitive.
"

Measured with no flags given at all: lda #$42, LDA #$42 and Lda #$42
assemble to identical bytes, and a label defined Foo and referenced FOO is
an undefined symbol with or without -i. That is exactly the asymmetry as65
specifies, so -i is a no-op because the requested behavior is already the
default — not because it is missing.

Done on 020-disk-file-access:

  • The help said "not implemented" and now reads
    Case-insensitive opcodes. Already the default; accepted as a no-op.
  • ignoreOpcodeCase is deleted. Nothing read it and nothing could; a stored
    true in two structs invited somebody to build a conditional case-folding the
    assembler does not need. -i is still accepted and still concatenates.
  • AssemblerTests pins the opcode behavior against the assembler, so the help
    and the code cannot drift apart on it.

Also closed out since this was filed

  • caseSensitive rename. The field was renamed to ignoreOpcodeCase and has
    now been removed entirely.
  • --cpu removed in favor of as65's -x. Done on 020-disk-file-access.
    This has a known cost on spec 019, which pins --cpu in as65 mode with its
    own tests and refuses --cpu by name on its Merlin path; whoever merges the two
    branches owns retargeting those at -x.
  • Exit code 4. Now documented in the assembler's exit-code list as as65's
    out-of-memory status, which this tool never returns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions