z00m128 / sjasmplus

Command-line cross-compiler of assembly language for Z80 CPU.
http://z00m128.github.io/sjasmplus/
BSD 3-Clause "New" or "Revised" License
383 stars 54 forks source link

merging labels #234

Closed DeadlyKom closed 4 months ago

DeadlyKom commented 4 months ago

there are two shorter label declarations with the same main declaration in different files

first image

second image

It would be nice if sjasmplus would combine them, and I could access them freely, without duplication errors

ped7g commented 4 months ago

You can achieve the desired result by using MODULE, either in both cases, or you can even "abuse" it to extend namespace defined by main label earlier:

; a bit dirty way (module was not meant to be used like this), but works:
Collision:       ; defines Collision symbol
.Prepare        EQU 123  ; defines Collision.Prepare symbol
.Handler        EQU 234 ; defines Collision.Handler symbol

 ... other file ...

        MODULE Collision
Initialize      EQU 345  ; defines Collision.Initialize symbol
        ENDMODULE

or using Collision only as module (not as main symbol):

        MODULE Collision
Prepare         EQU 123
Handler         EQU 234
        ENDMODULE

 ... other file ...

        MODULE Collision
Initialize      EQU 345  ; defines Collision.Initialize symbol
        ENDMODULE

Doing second time Collision: is duplicate label and I don't see how to enable your proposal without causing havoc with accidental errors of adding duplicate labels by accident. Those should be reported as errors, as they are now.

I hope this helps.

DeadlyKom commented 4 months ago

печально!

ped7g commented 4 months ago

Sorry, but I don't share your sentiment. As far as I can tell the module enables you to do exactly what you want, yet it doesn't break regular assembler functionality, so it's like win-win situation IMHO?

I understand it's different syntax, so the source will looks slightly different, but otherwise it's almost 1:1 what you asked for.

If you have issues to use sjasmplus in your project, you can always try to post some example project with the problem, or email me full project privately (see email in commits in git or check file asm-z80-sj.xml ). Happy coding! :)