Не могу понять что не так с if not exist. Без модулей все в порядке, в модуле не совсем. Проверял с 18.2 и 19
Не могу понять что не так с if not exist. Без модулей все в порядке, в модуле не совсем. Проверял с 18.2 и 19
Наверное ped7g сюда больше не заходит, сделал иссуе на гитхабе, очень уж охота переопределяемость в асме без дефайнов.
sorry, busy with a newborn baby, so I didn't notice there's new post. Github surely works better. ( https://github.com/z00m128/sjasmplus/issues/177 )
But this issue is a bit puzzling to me, not sure what to do about it, technically it works "as designed", but in your example it is very counter-intuitive and feels wrong...
Also I'm a bit confused what you mean "Без модулей все в порядке"
If I do in empty asm file this:
it will do the conditional block only in first pass, creating the label "non_mod_l1", but not doing `ds 1` in pass 2 and 3, so this is broken logic even without modules.Код:IF !exist non_mod_l1 non_mod_l1 ds 1 ENDIF
(but the `exist` was not meant to be used like this, for conditional "linking" there is `IFUSED` which works a bit differently, and for replacing default definitions with external code I would suggest DEFINE + IFDEF)
LW (06.05.2022)
Поздравляю с приятными хлопотами, рад за вас.
У меня была идея использовать в виде именно переопределяемых процедур и данных, возможно я немного не так подошел к функционалу. Допустим есть тематический модуль, но мы хотим изменить процедуру или данные в нем не переписывая его. Раньше я делал такое через define но exist показался прямо предназначенным для этого.
Возможно тут применима логика когда фактически exist проверяется только на первом проходе, слежение за ссылками вперед оставим на писателя, тут мне кажется это не применимо. Но в целом я понял, буду использовать define, если есть обходной путь овчинка не стоит выделки.
То что у меня сработало без модуля перепроверю, вполне возможно я ошибся.
Ped7g (07.05.2022)
I have been thinking about the issue for few more hours, and I think it will stay as is.
While your example is quite logical on first read, and I would sweat a bit to explain to new assembler users why this is a problem, it *is* a problem.
Generally assemblers collect symbol values over several passes, before they start emitting machine code, at that point the symbol values should be stable. So it's impossible to reset values before each pass, and EXIST targets symbols. (contrary to that DEFINEs are reset before each pass, and are re-created each pass, so IFDEF + DEFINE works the way how you expect).
Thinking about it, the assembler working like mdlz80optimizer doing lazy evaluation of labels and "single pass" (I think, not sure about how exactly it works, but it's not N-pass) would probably work for your example, but that's completely different architecture, not going there with sjasmplus.
(and for general library, the IFUSED can be used, although I personally prefer to have full source of project together, so even when I use some "library", I first copy the library source to the project, so I can then easily modify it only for the particular project and I don't need to worry about other projects using the same base library)
Ограничение на длину строки в 128 байт для BYTE/DB/DC является очень важным, или лимит можно увеличить?
Your life is REAL. Change it UNREAL!
All internal buffers are fixed size. read-line is 2048, define-substitution two buffers 2048, emit-bytes-values inside BYTE/DB/DC/DZ directive is 128+2, etc...
You can raise limits of all those buffers (and hope that you did find all relevant ones) and build version which will accept more, but there will be always some hard limit unless you rewrite the code to use dynamic memory allocation per line.
But even to reach 128 items in DB it must be super long source-code line which is difficult to read+edit in text editor, so I don't see 128 limit as an issue (in my own source I'm often limiting number values to 16 or 32 per line and quoted text to 64 chars).
For binary data like gfx consider `INCBIN` instead of converting it to source code, or patch the convertor to split it into multiple lines.
https://github.com/z00m128/sjasmplus...es/tag/v1.20.0
- Lua: upgrade to 5.4, replacing tolua++ bindings with LuaBridge2.6 library, extending some bindings
- Lua: bindings slightly modified (required by upgrade), refreshed docs, added test coverage
- Lua: the 3rd party extensions (BTW not working for many years) are obsolete in 5.4 and removed
- Lua: more accurate errors/warning location reported even in complex cases
- warnings: added -Wall, --help=warnings shows on/off status, rdlow off by default
- Added HIGH mode to relocation data generator (MSB-only relocation mode)
- many open-file "fatal" errors become "non-fatal", assembling will continue
- deprecated features removed: --syntax=m, label abs in expressions
- --color=auto will stay no-color when env.var. NO_COLOR is defined
- refactorings, improving some error messages and parsing, small fixes in parsing logic
- fix listing of Lua's sj.parse_code (eol-comments), minor memory leaks fixed
- fix relocation of temporary labels in expressions
- invalid CLI options are reported as regular errors (also changing exit code)
- errors are colored similarly to gcc (only keyword has color), console input name is <stdin>
Please be aware the upgrade of Lua may break some older scripts:
- the sjasmplus bindings had been restricted to only documented API, removing some of the secret optional arguments (hopefully not used by many people, in case you did use them, use instead the _pl/_pc function producing required asm line as string and letting sjasmplus to parse it as regular piece of code).
- Lua 5.4 has several incompatible syntax changes compared to 5.1, some stuff is quite subtle (for example _pc("ld a," .. 4/2) will produce string "ld a,2.0" which will cause "Unexpected: .0" error in parser)
- check the docs and tests to see how I adjusted old source to assemble again in similar cases
Dart Alver (15.06.2022), Dr.OM (15.06.2022)
вопрос: можно ли как то переназначать переменную компилятора __DATE__. её формат YYYY-MM-DD не удобен.
https://devrant.com/rants/1791863/a-...r-a-programmer
I can't imagine which else format would you want, the YYYY-MM-DD is perfect.
If you need different format, there are no string operators in sjasmplus, so Lua for the rescue:
but that's just wrong.Код:LUA ALLPASS date = sj.get_define("__DATE__") year = date:sub(2,5) month = date:sub(7,8) day = date:sub(10,11) wrong_format = "\""..day.."."..month.."."..year.."\"" sj.insert_define("WRONG_FORMATTED_DATE", wrong_format) ENDLUA DISPLAY WRONG_FORMATTED_DATE
Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)