Tniasm compatible assembler

Page 2/2
1 |

By Ped7g

Supporter (7)

Ped7g's picture

01-11-2019, 15:33

yes, I fully agree, the source has to target the *one* assembler and it's actually impossible to create one universal assembler (the different syntax does often "clash" between assemblers, using the same syntax for completely different feature and machine code result).

It makes sense to convert it when the author does decide to migrate to the other assembler.

What I'm offering is to take a look how painful (difficult) the migration to sjasmplus would be.

For me personally if it can be solved by few `sed` commands and 0.5-2% of LoC manual fixing, it's feasible (if I want to migrate to that new assembler).

Of course then it depends if such migration makes sense, i.e. what the new assembler does provide. The sjasmplus does provide sources under BSD 3-clause license and linux/BSD on ARM CPU actively supported.

I don't know Tniasm or Glass, so I have no idea how sjasmplus stands in features comparison, what is lacking (from head I can easily tell there are two bigger areas - string operators and floating point values expressions - which are completely missing in sjasmplus, and for such type of expressions one has to fall-back into built-in Lua support and write small part of source as Lua script, but IMO most of the other common features of assemblers are present, at least in some basic form).

By NYYRIKKI

Enlighted (5399)

NYYRIKKI's picture

01-11-2019, 18:52

Actually Tniasm 1.0 is the one that is most close to "universal assembler" out of what I've seen. It does not care that much to what CPU the source is written for or for what CPU it outputs binary. You can make it compile even your shopping list if you need. The default Z80 syntax that it uses is quite weird to my eyes, but there are some compatibility files delivered with it that can make it work ie. pretty much like sjasm. (Edit: I just checked and there are compatibility files also for asmsx, Wbass2 and naturally for tniasm 0.45) Practically all of it is just macros including the Z80 definition by it self (there are alternative include files for few other CPUs as well) Even the internal commands can be defined to do something else if that is needed for some reason.

IIRC the price was 20€ and if you are willing to pay that, I think you may even get ARM version if you ask for it.

By MsxKun

Paladin (924)

MsxKun's picture

02-11-2019, 10:00

NYYRIKKI wrote:

Actually Tniasm 1.0 is the one that is most close to "universal assembler" out of what I've seen. It does not care that much to what CPU the source is written for or for what CPU it outputs binary. You can make it compile even your shopping list if you need.

I'm using the 1.0 beta since some time ago and it works fine.
It's really configurable. Still didn't use even a 25% of what it can do. And it works on linux. So i'm happy with it Smile
But never tought to make the shopping list with it Running Naked in a Field of Flowers

By Daemos

Paragon (1672)

Daemos's picture

04-11-2019, 15:15

@ped7g can you send me a email? I am interested in what your sjasmplus can do.

By Ped7g

Supporter (7)

Ped7g's picture

17-11-2019, 16:50

The migration to sjasmplus is now done.

I have to thank Daemos for this opportunity, as I learned some new things about `sed`, found few minor bugs in sjasmplus and added new option `--longptr` to support his way of producing large binaries (beyond 16bit address space of Z80).

I did write down a blog about how the migration was done and what kind of problems I did run into:
tniASM-to-sjasmplus

Also as a result of this effort the new sjasmplus v1.14.3 is now released. B-)

By Manuel

Ascended (15822)

Manuel's picture

17-11-2019, 21:25

Interesting read and great to hear there is progress on that project.
It's not very important, but how long does your modern PC take to assemble half a million lines of Z80 assembly code?

By Grauw

Ascended (8515)

Grauw's picture

17-11-2019, 22:08

Very nice write-up about differences between assemblers! Smile

Particularly interesting how some extensions to the standard syntax can lead to diverging interpretations of the same code (the sub a,7 case).

And about labels with and without colons vs. indentation of labels and statment, yeah that’s a tricky parsing problem for which there’s no solution if you don’t wanna dive into behaviour which parses an identifier differently based on whether it’s in an instruction & macro list (which may possibly be defined later). On the one hand I like the consistency of labels requiring a :, but Z80 assemblers have been accepting colon-less labels since forever so I think it’s important to support. Also I’m not a big fan of not-indented statements, however I do like to indent labels in nested contexts in particular. Not actually sure how old assemblers (Gen80, M80, Compass) treat that. For portable assembly I guess best to just stick to 1. don’t indent labels, 2. always indent statements, and 3. always suffix labels with a :.

By Ped7g

Supporter (7)

Ped7g's picture

17-11-2019, 22:43

Manuel wrote:

Interesting read and great to hear there is progress on that project.
It's not very important, but how long does your modern PC take to assemble half a million lines of Z80 assembly code?

Around two seconds when "warmed up" (all source files already cached in memory from previous runs). Not sure about "cold" variant (too lazy to reboot), but I guess it should be around 3-5s.

For comparison: the sjasmplus itself (about 25k LoC) does build in 4s on my machine, but using four threads, single thread would be around 15s ... when doing `time make tests` to run build + whole test suite, it takes about 10s (25s single thread).

Edit - Grauw:
I joined the z00m's branch of sjasmplus after v1.10.4, i.e. after more than a decade this assembler exists and is used by some users. While I would personally prefer few changes in the syntax, overall the sjasmplus syntax is on my scale quite "nice", like seven or eight out of ten. Definitely nice-enough to avoid writing my own assembler from scratch, so I rather adjust my source style a bit (and added those few extra options to slightly modify sjasmplus).

I did collect few ideas how I would want to change syntax of sjasmplus for "v2.x", while I was fixing the bugs, but there's very little incentive in it for me right now. The last ~10 months of fixing the sjasmplus the incentive was to have solid Z80 assembler for myself, for some ZX Next projects, but for that the current state is enough. I know there's lot of code which I find of not a good quality and it would be probably easy to rewrite it better, but regular sjasmplus user probably doesn't care if the implementation is pretty, as long as it works correctly.

By Daemos

Paragon (1672)

Daemos's picture

18-11-2019, 16:31

Quote:

Interesting read and great to hear there is progress on that project.
It's not very important, but how long does your modern PC take to assemble half a million lines of Z80 assembly code?

Pass 3 complete
Errors: 0, warnings: 0, compiled: 465480 lines, work time: 1.466 seconds

thats on a ARM64 running on 2,84 Ghz

Page 2/2
1 |