Skip to content

Shrink assembler with more homogenous SAN notation? #128

@patricksurry

Description

@patricksurry

While working on #127 I wondered about refactoring the assembler as a set of base mnenomic forth words plus separate qualifiers which could be parsed directly by the assembler.

From a user perspective that would mean writing $42 adc .# rather than $42 adc.# but would shrink the assembler-wordlist significantly (about 64 base mnemonics vs current 177) with a big associated saving in lookup table, header and repeated text storage (e.g. one copy of the string ".zx" rather than eighteen now).

I think this would save another 1.5-2Kb on binaries that include the assembler/disassembler. One challenge is that SAN 16 bit addressing doesn't have an explicit 16bit address qualifier, e.g. adc in SAN means adc llhh so it would be hard to distinguish between $42 adc .# and $42 adc.

A possible solution would be to require an explicit 16 bit address qualifier like .w which would make SAN more homogenous and (imho) more readable. See below for adc example. Each base mnemonic would either always (e.g. adc) or never (e.g. phx) include a qualifier. The full list of possible qualifiers would be something like .#, .a, .w, .wi, .wxi, .wx, .wy, .z, .zi, .ziy, .zx, .zy, .zxi.

Traditional | SAN
adc #dd     | adc.#  
adc llhh    | adc   => adc.w
adc llhh,x  | adc.x => adc.wx
adc llhh,y  | adc.y => adc.wy
adc zp      | adc.z 
adc (zp)    | adc.zi 
adc (zp),y  | adc.ziy
adc zp,x    | adc.zx
adc (zp,x)  | adc.zxi

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