About LUA approach: if it's "complete" block of code, you can extract the if/def logic into lua, emitting only instructions
I guess I have some idea why it fails like this, and I think I was already fixing similar case for something else? Can't remember... I may take a look later if it's possible to make similar LUA code generator work, your idea seems valid to me.
About defarray: I really don't want to, that feels like can of worms being opened ... defines feel to me more like C preprocessor than actual script language
when you write "the_array[1] = 4", the line is substituted very early right after reading buffered input into "3 = 4", then are the directives/instructions being parsed. What you propose would require to parse this array-assignment directive ahead of substitution, adding like whole new step in the compiling "pipeline". Maybe it would work well (or maybe it would backfire later), but it really feels like changing defines into something what they are not.
About memory approach: {0} = 3 is `ORG 0 : DW 3`, so this part is not a problem, but the `IF` part is problem, because pass1 and pass2 will see {$4000} as 0, only in pass3 there will be real value... Thinking what you did want to achieve originally, this will not work either.
As long as only fixed control variables are involved like "aaa", you can do that in the asm like:
But if you want "array" of control variables, then I'm afraid currently you must elevate *all* the logic into Lua, and write full code generator in Lua, can't think of good hack how to do that in asm/define way.Код:aaa = 3 bbb = $c0 dup 10 if aaa = 5 : db $ff : endif db bbb+aaa aaa = aaa + 1 bbb = bbb - $10 edup
I will take a look if there's a way to fix IF/ENDIF emitted by _pc from Lua script ... that sounds like something what "should" work, if you don't know the sjasmplus internals, and you just follow the documentation, so fixing this would be good. But it may be too difficult.
I believe you can actually make that work if you will emit whole IF->ENDIF block into _pc/_pl, i.e. _pc("if aaa = 0 : db 1,2,3,4 : endif") -> that MAY work?
But I'm not sure if it is enough for you to resolve all your issues.
EDIT: the colons will actually break _pc, right? sorry, I don't have time to try it now, I have really urgent work project upon me, so sorry if my advice is broken. Will take second look later, when I will be more free from work.
- - - Updated - - -
https://github.com/z00m128/sjasmplus...es/tag/v1.13.2
v1.13.2 changelog:
- OPT has now also "listoff" and "liston" commands
- added to --syntax option: case insensitive instructions, "bBw" added/changed
- new macro examples, minor fixes and refactoring
- SAVETRD implementation refactored (more checks, less bugs, "replace" file feature)
- operators "{address}" and "{b address}" are now official and documented
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).




Ответить с цитированием