tebe6502 / Mad-Assembler

6502, 65816 assembler (Atari XE/XL)
MIT License
78 stars 16 forks source link

Option -u warns about unused labels from included ASM file #13

Open mirao opened 1 year ago

mirao commented 1 year ago

I use the handy option -u so that I don't keep useless labels in my code But it doesn't seem to be working as expected when including labels from external ASM file.

Let's have a shared library for a work with keyboard

keys.asm:

KEY_M = $25
KEY_U = $0b
KEY_D = $3a
KEY_SPACE = $21
KEY_F = $38
KEY_H = $39

CH = $2fc

.macro get_key
    lda CH
    ; Accept even upper case
    and #%1011 1111
.endm

.macro reset_key
    mva #$ff CH
.endm

and an application using only KEY_SPACE, KEY_F and KEY_H from it

gtia_gr0.asm:

    icl "../common/keys.asm"
    mva #KEY_F LAST_SHIFT_KEY

    ; ... and some other usage of KEY_SPACE, KEY_F and KEY_H

There is also another application using different keys: KEY_M, KEY_U, KEY_D.

Now if I assemble gtia_gr0.asm, I'm getting warnings :x:

$ mads -u gtia_gr0.asm
keys.asm (1) WARNING: Unused label KEY_M
keys.asm (2) WARNING: Unused label KEY_U
keys.asm (3) WARNING: Unused label KEY_D
Writing object file...
189 lines of source assembled in 3 pass
184 bytes written to the object file

Or is there a way how to "Import only some labels and don't notice others" so that I won't get those warnings? Or another solution? I don't want to separate keys into extra libraries. I just want to share some keys from one library.

Used SW: mads 2.1.5, Ubuntu 22.10

dfbg commented 1 year ago

It sounds like you want "OPT u" added so you can turn the warnings on and off where you want them.

mirao commented 1 year ago

Not sure if "OPT u" could make the process easier. I just need to skip check of unused labels from included asm files (external labels) when using -u. Now I'm getting many warnings and some of them are useless (external labels, I can't do anything with such warnings) and only some useful (internal labels that are not used. Typically I forgot to remove them from my application and it's good that MADS reports it).

dfbg commented 1 year ago

I was thinking you would put OPT u- at the top of the include file and OPT u+ at the bottom. This is how I use OPT l-/+ to keep those same files out of the .lst file.

mirao commented 1 year ago

I see. It could work.