а сильно тяжело увеличить количество проходов?
мне кажется что 3 прохода это маловато для работы сложных генераторов кода
It's long term goal to make it N-pass assembler (I think we are pretty close, maybe even v1.14.0 or v1.15.0).
But `{ address }` will basically always return real value only in the last pass, again it's device memory, not script language.

I mean, there is already LUA, so as long as you will write the whole code generator in it, you are golden, even in current sjasmplus version, but you must do all the dynamic logic in the Lua, to emit only final stream of instructions without conditionals/dups/macros/etc.. = "blocks".

Of course it would be better if things like IF+ENDIF would work also in `_pc`, but it's problematic.

Basically I need to collect all `_pc()` calls into buffer, and **then** parse it similarly like "include", so if you have 100 lines of Lua script doing _pc(...), you would learn about 14th line using invalid instruction after the `endlua`, not at 14th `_pc(...)`, which is not good error reporting...

Or I need to rewrite whole internals to regular C++, where Lua script would be just another input stream like reading the file and the rest of assembler would have no idea the code is produced by Lua - I'm afraid this one will not happen due to my time (but maybe the sjasmplus/sjasmplus branch can make this one work, that source is now lot more proper C++ and better style quality, maybe there it needs only few changes)

Or maybe I can do another hack... add `_pc_buffered(...)` so people like you have at least some option, even if the error reporting will be delayed down to `endlua` line.

... still not much time, so I didn't study your ending example yet, sorry, will try to take a look during weekend or so.

- - - Updated - - -

I did take a quick look at the ending example, and I don't get it, can't tell which parts are unique and which can be calculated/generated... like why a1+5 in case of 3 vars and a1+10 in case of 200, and why do you even change those variables, if you don't repeat the whole block, etc...

Mind you, you can create dynamic amount 1..N of labels through a bit of hackery with DUP (with MAX_N repeats) and macros with partial name substitution, but those constant coefficients in those IF/ENDIF then has to be calculated or form some fixed array. But I guess the end result would be very difficult to read and maintain.

I'm still not sure why you don't use full Lua generator, if you need such complex stuff, I would expect it to be even easier to write, if you are experienced in Lua (unfortunately I am not, I'm just beginner).

- - - Updated - - -

And colons in _pc("nop : nop") are like different topic, that thing is maybe easiest to fix from this whole discussion ... (but still not that easy, even that may be complicated, probably not 2-3 lines fix).