Просмотр полной версии : SjASMPlus от z00m
Альтернативная ветка от чехов нашего любимого кросс-асма.
https://github.com/z00m128/sjasmplus/releases
Достаточно часто обновляется со вкусными релиз нотами.
sjasmplus v1.11.0
Added ZX Spectrum Next instructions support
Added --msg option, directives DG and DH
Changed listing layout to fixed-width type
Errors, Warnings and similar are now channeled to STDERR
Fixed string literal parser, added two apostrophes and escaped zero
Fixed docs templates (HTML is now more valid)
Fixed nesting DUP issue
Fixed CRLF handling in parser
Fixed -D option for multiple asm files
Fixed address display when the 64kB limit exceeded
Fixed lost code when current memory leaves device slot in "disp" mode
Fixed IF inside MACRO, DUP and REPT
Fixed ALIGN behavior and docs wording
Fixed INCHOB/INCBIN (offset / length)
Fixed INCLUDE/INCLUDELUA system path priority ("" vs <>)
Fixed END behavior
Fixed DEFARRAY to work as documented
Fixed and refactored WORD/DWORD/D24
Fixed and extended STRUCT
Multiple bugfixes in listing generation
Multiple bugfixes of internal code
Refactored options parser, instruction parser and Warning/Error system
C++14 standard is now required minimum (to compile sjasmplus sources)
Added automated-testing scripts, with 50+ tests
GitHub connected with Cirrus Continuous Integration service
sjasmplus v1.11.1
Fixed global labels in MACRO and in IFUSED/IFNUSED
Fixed nested IF-DUP-IF
Fixed local labels fail when amount of lines did change between passes
Fixed Makefile to build when path to project contains space
Added macro-example: turn "DJNZ ." into "DJNZ $" (to fix Zeus syntax source)
Added --msg=lst and --msg=lstlab options to produce listing file to STDERR
Added options to read input file from STDIN and output "raw" binary to STDOUT
хы, .SCL без ошибок компилит. Уже нравиЦЦа.
NEO SPECTRUMAN
03.04.2019, 22:39
печально что не отечественная ветка
Bedazzle
04.04.2019, 00:49
печально что не отечественная ветка
Какая разница, кто поднял упавший флаг, если несёт достойно?
NEO SPECTRUMAN
04.04.2019, 01:01
Какая разница, кто поднял упавший флаг, если несёт достойно?
некому писать пожилания и угрозы
а ищо вроде есть жо наша отечественная ветка (которая должна была фсех победить)
- - - Добавлено - - -
и вообще будем надеятсо что настанет тот день
когда sjasm ВНЕЗАПНО закомпилирует сорцы аласма
Bedazzle
04.04.2019, 07:07
Альтернативная ветка от чехов нашего любимого кросс-асма.
ld a, '\\'
В других верисиях ок, эта вываливает предупреждение (полученный бинарник, правда, правильный)
https://i.imgur.com/xnghq3Q.png
все повторы по старинке через DUP/REPT
в Storm'e было после .4 - удобнее.
с системными переменными та же шляпа со 128
mastermind
05.04.2019, 18:20
Печально что эти парни взяли за основу древнейший код, незаметив "основную", более новую ветку, которую правил Vitamin и позже я. Во многом заново наступают на/правят те же самые грабли, древнейший код.
- - - Добавлено - - -
некому писать пожилания и угрозы
а ищо вроде есть жо наша отечественная ветка (которая должна была фсех победить)
Да вот действительно, вспоминается анекдот про "ты хотя бы лотерейный билет купи". Уж сколько раз я предлагал писать запросы/багрепорты в issues (https://github.com/sjasmplus/sjasmplus/issues). Один asve79 что-то пишет иногда (https://github.com/sjasmplus/sjasmplus/issues?q=is%3Aissue+is%3Aclosed), а больше никому ничего не нужно судя по всему.
- - - Добавлено - - -
и вообще будем надеятсо что настанет тот день
когда sjasm ВНЕЗАПНО закомпилирует сорцы аласма
А это зачем нужно? Аласмовские сорцы токенизированные же? Чем их редактировать на PC?
А это зачем нужно? Аласмовские сорцы токенизированные же? Чем их редактировать на PC?
А ничем. От специфического синтаксиса можно чокнуться
не понравилось, что при компиляции вылезает сообщение об include/incbin
NEO SPECTRUMAN
06.04.2019, 01:54
Уж сколько раз я предлагал писать запросы/багрепорты в issues.
ну дык это нужно регатся на каком то сомнительном сайте
кто это будет лишний раз делать?
да и обновления привычней скачивать с форума
и обсуждать тут же...
- - - Добавлено - - -
Чем их редактировать на PC?
есть всякие конвертилки в текст
которые не все успешно конвертят...
а так куча старых сорцов
чисто в оригинальном формате на образах дискет
которые фиг посмотришь...
пушо нужно знать что тыкать в асме
а мануалов к ним тожо нету...
хотя в аласме легко разобраться методом научного тыка ВНЕЗАПНО
но все равно листать в эмуляторе не удобно
копипастить нельзя...
сорцы вроде бы есть
но толку от них столько
будто их нет... (не только аласм)
mastermind
06.04.2019, 02:11
Мануалов нету, ничего нету, конвертилки какие-то есть, но где они непонятно (где ссылки?), гитхаб - сомнительный сайт... В общем с "покупкой лотерейного билета" все напрочь запущено :v2_dizzy_facepalm:
NEO SPECTRUMAN
06.04.2019, 02:36
ничего нету, конвертилки какие-то есть, но где они непонятно (где ссылки?), гитхаб -
Да втопку аласм
большое пожелание
в sjasm-е никакая морально устаревшая lua
+полное отсутствие списка всех имеющихся команд
приходиться все делать методом научного тыка
находить команды (по разным сайтекам)
и проверять работают ли они
большая часть проверенного не работает
или же написание отличается от принятых
...ну и да
найденные и куда то выписанные списки
куда то теряются...
нет очень нужных переходов goto (хотя при ошибках изза них может быть зависание на бесконечном цикле)
и приходится лепить неимоверное *****кодобезобразие из for говна и палок
чтоб получить желаемый результат
и хотелось бы чтоб оно подправили
ну и да
макросы с несколькими переменными
наше все!
в sjasm-е никакая морально устаревшая lua
https://www.meme-arsenal.com/memes/d223b233d1c8ba4a179f7babe58eb511.jpg
даже такому нубу как я хватило lua для решения 2-3 задач.
local fp = assert(io.open("demovars.inc", "wb"))
local ss=tostring( sj.get_label("curpage") )
ss=string.gsub(ss , "%s", "")
fp:write("curpage =")
fp:write(string.format("#%x",ss) )
fp:write("\r\n")
local ss=tostring( sj.get_label("notecnt") )
ss=string.gsub(ss , "%s", "")
fp:write("notecnt =")
fp:write(string.format("#%x",ss) )
fp:write("\r\n")
NEO SPECTRUMAN
06.04.2019, 05:34
даже такому нубу как я хватило lua для решения 2-3 задач.
:v2_dizzy_facepalm:
морально устаревшая lua
:v2_dizzy_facepalm:
ийё используют при написании современнейших игр. На форуме . том, сравнивали с JS, и не все так однозначно. Так что видимо еще долго будет устаревать и устаревать.
ийё используют при написании современнейших игр. На форуме . том, сравнивали с JS, и не все так однозначно.
в отладчиках lua попу лярен. Язык не торт, конечно же.
NEO SPECTRUMAN
06.04.2019, 15:53
ийё используют при написании современнейших игр.
имею ввиду что дремучая версия lua
которая не тянет большей части команд
которые как бы нужны...
а так да язык дубовый
и кто дjдумалcя завершать все команды при помощи одного и того же end ?
но возможности при компиляции дает просто неимоверные
Hello everyone, let me introduce myself... and apologize for writing in English, but my Russian knowledge is extremely limited (like 10 words), so I'm reading your forum mostly through google translator, which may be sometimes a bit inaccurate, bear with me.
I'm Ped ("7 Gods" demo group, active on ZX scene around 1992-1997), and currently I happened to be contributor to z00m's branch of sjasmplus.
I will try to help you with any issues or explain what is happening with the project, and where I'm heading with it.
First things first, this one is probably most important to explain:
Печально что эти парни взяли за основу древнейший код, незаметив "основную", более новую ветку, которую правил Vitamin и позже я. Во многом заново наступают на/правят те же самые грабли, древнейший код.
- - - Добавлено - - -
Да вот действительно, вспоминается анекдот про "ты хотя бы лотерейный билет купи". Уж сколько раз я предлагал писать запросы/багрепорты в issues (https://github.com/sjasmplus/sjasmplus/issues). Один asve79 что-то пишет иногда (https://github.com/sjasmplus/sjasmplus/issues?q=is%3Aissue+is%3Aclosed), а больше никому ничего не нужно судя по всему.
А это зачем нужно? Аласмовские сорцы токенизированные же? Чем их редактировать на PC?
This is very unlucky coincidence, and I have no idea why the guys originally followed the older branch (I think the first commit from z00m is around May 2016, so he was either unaware of the new progress, or he had things on his disk for many month, or .. I don't know). I personally ran into this branch by following ZX Spectrun Next group, where somebody forked it and added ZXN extra instructions to it. After doing review of this change set and fixing it a bit more, I was contacted by some .sk demo sceners (I know some of them personally - back from the ~1995 era, when 7 Gods did write few ZX demos) participating on this project, and asked to become a contributor.
At this point I did somewhat deeper review of the "current" z00m's version of sjasmplus, and found out it was basically full of bugs, and almost nothing was working as documented in the (well written, thanks to Aprisobal) documentation. So instead of following my original plans (more about that at end of this message), I started just fixing bugs... somewhere half into it (around v1.12.0) I found out about your sjasmplus/sjasmplus branch on github, wasn't aware of it before.
So I did check how it looks, and unfortunately the code diverted considerably in the meantime, so there's no simple way to sync between the source code directly, but I was able to at least run some of your tests and fix few more bugs, thank you.
In the end I'm afraid it will be like this, two separate branches, two separate developments, and maybe we can share at least some ideas, tests and designs (but I don't feel any huge urge to sync+merge into one branch, having two versions of almost the same thing may be sort of redundant, but it already happened, so the "wasted time" is already gone, merging now would take lot of extra effort, which I don't feel currently like wanting to work on that).
My part on this mistake is insufficient research before jumping into the project, I was not even aware of your and Vitamin's hard work, I'm sorry for this mistake on my side.
:v2_dizzy_drink: about my plans with z00m's sjasmplus brach (and what happened so far since I jumped into it):
the bugfixing phase is now mostly finished, i.e. v1.13.0 should mostly behave in sync with Documentation (need further reports of issues, especially problems with real projects are very welcome and would be sort of refreshing, because most of my work was done by theoretical reasoning, which sometimes doesn't reflect real world problems very well)
ZX Spectrum Next device support is simple, but finished (I may revisit it after working on my Next projects, or if somebody reports particular problem)
when I was fixing bugs or adding new things, I was trying hard to stay backward compatible as much as possible, but some of my changes may have broken old sources. If such change is documented in What's new (http://z00m128.github.io/sjasmplus/documentation.html#idp7) chapter, it means I had some serious reasons to prefer the change over compatibility and it is not an accident. If you are affected by such change, please consider if you may "fix" your source in the new way.
if you can't find any change describing things which are broken for you, open an Issue and I will check what is going on, it may be new bug introduced by my code modifications (you can actually open even Issues for thing in previous point, so I get better feedback from real world, how sjasmplus is being used, and I may try then to convince you that my reasons are good enough to require that change, or I may think more about how to make it work in future)
PLAN: add more power (adding some operators for labels, improving listing files, etc) to work with large device memory in more convenient way (my personal interest is ZX Spectrum Next, but most of these things do apply already for ZX128 and other extended Spectrums)
PLAN: syntax option to switch-on more strict syntax parsing (probably configurable a lot, because when I tried to collect personal preferences of current sjasmplus contributors and friends, each of us has different expectations what the assembler should report as error/warning), as most of my bugs while writing ZX Next test suite few months back were coming from relaxed syntax, when I wrote something into source and didn't realize it will be assembled in other way than I expect. ( `ld a,(flag1|flag2)` being probably most painful for me, hitting me like three times at least, hehe)
Add more automated tests to cover ideally all functionality of sjasmplus, to find out more bugs, and prevent simple regressions when changing the code. (currently I have almost 150 tests, covering probably about 1/3 to 1/2 of sjasmplus functionality (as documented))
I will add (at least) two more replies, one trying to cover things reported in previous posts, and finally the v1.13.0 announcement... (to be continued) .. and maybe post some design ideas in greater detail, so you can share your opinions about the planned changes, and help to asses which change will actually help you with Speccy projects, or what is missing for you, to make it better.
- - - Updated - - -
ld a, '\\'
The parser was fixed to be in sync with the old documentation, and only strings in "quotes" support escaping. Your '\\' is now in new version really value 0x5C5C. To get value 0x5C it is enough to write '\' (or "\\"). The only "escaped" thing in single apostrophe is the apostrophe itself, and to "escape" it you have to put two consecutive of them, for example four apostrophes in source '''' form value 0x27 (ASCII apostrophe).
While this is unfortunately breaking some older sources, it's not my idea, I just fixed the sjasmplus to follow the old documentation (and I believe it's trivial to update your sources, if you want to use newer version actively). (my idea was to add double-apostrophe in apostrophes parsing)
Also I have seen somewhere report of ` ex af,af' : ...some code : ex af,af' ` not working properly, which I'm pretty sure should work OK in recent versions (probably even since v1.11.0, or when I did fix the parser).
все повторы по старинке через DUP/REPT
в Storm'e было после .4 - удобнее.
I don't understand this one, sjasmplus did already support something like
label .5 add a,a - which will produce five times repeated instruction ADD. Maybe I misunderstood it? (for larger block you must do DUP 5 : ... block : EDUP, but this seems to me like trifle.
с системными переменными та же шляпа со 128
Sysvars are "correct" pretty much only in ZX48 device case, and I have no detailed knowledge of 128 or other clones (and sysvars for ZX Next are kinda too many and too spread into different banks, and of little interest to me, as my projects take full control over machine and don't need any sysvars at all, but I may work on these in case I will run into some problem with particular project).
If you can provide particular project which needs different sysvars pre-filed (and in which bank), and you can describe what changes are required to make sjasmplus better, add Issue on github with detailed description of changes needed, I will gladly take a look on it, but my 128+ Speccy knowledge is very limited, as I met in real life in my Speccy-era only with 48k machines and various Didaktik clones, so I know very little about other machines and I need detailed description of everything.
не понравилось, что при компиляции вылезает сообщение об include/incbin check --msg new options, it was annoying to me too, with level set to warnings or errors only the incbin is silent.
***
About support of different assemblers (and their syntax) - I have very little experience with other ZX assemblers ... ok, not very little, just "none". Back in nineties I was either using BASIC DATA with POKE and translating machine code on paper, or later I was using MRS on the device itself. Also I generally dislike the idea of universal assembler which has so relaxed syntax, that it can parse any source, there are then too many ambiguities (I already tried to read documentation of Pasmo, nsasm and Zeus, and there's no sane way to support all of that syntax in one project, as they clash with sjasmplus syntax and between them - what was reasonably compatible like DG/DH/HEX, was added, but generally in my opinion you are expected to pick assembler for particular source and adjust to syntax of that assembler .. it's often just few lines to modify, for example I managed to modify Manic Miner commented source (for Zeus) to assemble with sjasmplus with only few modifications (replacing the zeus keyboard macro with constants being the most invasive change needed)).
I'm still trying from time to time to assemble Nirvana+ with sjasmplus, so far every try resulted into new bugfixing round of macros and similar stuff, I will probably try again with v1.13.0 in following weeks, this one is really tricky... :)
***
About LUA: I'm not judging its inclusion, although I'm trying to make sjasmplus itself powerful enough to not need Lua at all (normally), but having it available for extra cases... I don't see problem with that, or any benefit gained by removal of it.
About upgrading particular version of Lua - I will try to take a look and see if it's possible to update it, but it better should compile also on mac and even in windows, so it will require some time, as I have only Linux machines available to myself and I can't test these things easily (almost every release preparation I get reports of z00m about breaking the windows or mac build, and those are usually just "innocent" small changes). But I like to have all libraries up to date in my projects, so this is of some medium priority.
I was even making fun of JS to M.Borik (who works with JS a lot, I personally can't stand it), and he did show me actually very small libraries which may provide support of JS in similar way how Lua is supported now, so I'm also considering about adding this. I will probably never use it personally, but some people may...
части команд которые как бы нужны...
You can check project's TODO.txt (https://github.com/z00m128/sjasmplus/blob/master/TODO.txt) to see what I am thinking about, and what may be added somewhere in the future (as time will permit, as I already spend ridiculous amount of time on this project, and I'm somewhat missing that time in my life and professional work now, so sadly, I will have to slow down a bit with sjasmplus).
You can always open Issues with particular proposals, what would help you with writing Speccy projects (or even posting it here, but opening issue on github will make it harder to get lost over time, at worst it will be just ignored). I'm especially interested into real problems of particular real projects, as I have already lot of feedback from "theory" people (working on new tools, debuggers, or just trying to push limits of sjasmplus), but almost no feedback from real projects.
- - - Updated - - -
(oh, the new posts gets merged automatically, which will make this a very long post about many different things, but you are probably used to it on this forum)
Just recently the v1.13.0 was released: https://github.com/z00m128/sjasmplus/releases/tag/v1.13.0
Changelog (including version v1.12.0 missing in this thread):
v1.12.0:
- Fixed parsing of expressions starting with string literal
- Fixed listing of DS directive with negative values, added value check warning
- Fixed possible wrong indexing of some arrays internally
- Fixed parsing of single-word instructions in colon-packed-no-space macros
- Making macro arguments substitution a bit more aggressive, to work also with
DEFINE/IFDEF/IFNDEF/DEFARRAY directives inside macro (this gives the coder
more macro power and freedom, but the error reporting may get lot more confused)
- Refactoring substring substitution for macro-arguments and defines, now it
should work always. To prohibit some macro/define to substitute into middle
of the string, start its name with underscore, like "_VERSION".
- THIS MAY BREAK SOME OLDER SOURCES, SORRY. Also the rules for substitutions
will be in the future further modified and documented, to make them more
intuitive and predictable, so there may be more breakage even later.
- Adding fake instructions break and exit for CSpect emulator (--zxnext=cspect)
v1.13.0
- [may break old sources] DEVICE: each assembling pass resets also
"device". To work with "device" memory (savesna/savetap/...) you
must select the device (and slot and pages) before producing machine
code which you want to work with (SAVESNA/SAVETAP/...).
If only single DEVICE is used in whole source batch, then the setting
is "global" and will be applied to all lines of source (in 2nd+ pass).
- [may break old sources] ZXSPECTRUM128 based devices map into slots
by default banks {7, 5, 2, 0}. (was {0, 5, 2, 7} in older versions)
- [may break old sources] ZXSPECTRUM128 based devices have sysvars and
stack set up as in "USR 0" mode (ZXSPECTRUM48 system variables and
default stack content).
- [may break old sources] MAP+FIELD directives removed (STRUCT is better and working)
- MMU directive (fusing SLOT + PAGE and extending them)
- SAVEDEV directive (similar to SAVEBIN)
- SAVENEX directive (for ZX Spectrum Next)
- INCBIN: support for negative offset/length values, support for MMU wrapping
- INCBIN: support for file chunks of 64+ki size (usable with MMU)
- Fixed: INCTRD offset, binary STDOUT on windows, SAVETRD/SAVEHOB filenames
- Fixed: LUA used inside macros, LUA get_word, LUA error reporting
- parser: added C++(like) numeric literals
- ZXSPECTRUMNEXT device added
- refactoring of label/define implementation = less memory leaks, more correct
"label.mem_page" values, "Unreal" labels dump is more correct too
- docs: now the CSS file is actually used, and default style modified a bit
- new MACRO examples, syntax-highlight file for KDE5 editors (Kate)
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
Хорошо конечно что стараются, у меня лично на эту ветку были надежды до этого:
- [may break old sources] MAP+FIELD directives removed (STRUCT is better and working)
Структуры конечно хорошо, но теперь придется прибавлять <char>. там где это совсем не нужно и делать структуру там где она совсем не нужна. Да можно equ понатыкать, вот удобство так удобство считать вручную. Можно еще disp 0 сделать. Но нафига все эти извраты?
Жаль конечно.
...но теперь придется прибавлять <char>...
...Но нафига все эти извраты?
1) not sure what is your issue, some example? (is it about doing few more keystrokes while writing source? That can be it, as that is usually very low priority for me, as that is usually very small part of SW development - compared to reading and debugging)
2) why changes? Because v1.10.4 is too bugged and it's lacking some functions I need for my own projects.
If you by some luck managed to have working source in older version - my respect! - you can still use the older binary to assemble that particular old source, if you don't want to update it.
For new projects you can decide yourself, but I had huge issues with v1.10.4 when I tried to use it somewhat more, beyond trivial instruction assembling. More than half of the examples from documentation didn't work as it was described, and some features of sjasmplus were not described in documentation at all, so I was not even sure if those were bugs or secret features.
But in the end it is very simple. I need assembler for my own projects, and my idea of good assembler is something reliable and predictable - so I don't have to babysit the assembler itself checking the resulting machine code, and I can focus on my programming and debugging my bugs. V1.10.4 was very far from this goal, unfortunately. Originally I did want just to add Next instructions and few more small changes, but then I did read through the source of it, and there was some kind of bug and inaccuracy almost everywhere. So instead of few changes I spend months (!) just fixing it.
I still put backward compatibility as very high priority item, and I believe, considering I made 300+ commits already, I broke minimal amount of old things. But at some points I had some reasons to believe the change is better option.
In case of MAP removal it was mostly it's poor implementation and lack of documentation (and I still believe STRUCT is as good), so instead of spending another week fixing MAP, I removed it (I was keeping it "as is" as long as it was possible, but due to it's implementation it was getting into my way too much lately, clashing with planned changes, and fixing it was too much of work).
Sorry. Still thank you for this feedback, I'm actually surprised anyone was using MAP in their projects, when I was asking in the cz/sk community, nobody had it (but each of us is very different, some prefer EQU and manual adjusting of everything, some write code generators in JavaScript and I did want functional STRUCT producing correct machine code...). So it's good to know this change was more problematic then I expected.
Bedazzle
16.05.2019, 18:19
1) not sure what is your issue, some example?
Downloaded sjasmplus v1.13.0 from git, unpacked.
Trying to start it from cmd - just hangs, doesnät matter if I start it with asm source as parameter, or without parameters.
Win 7 home.
Downloaded sjasmplus v1.13.0 from git, unpacked.
Trying to start it from cmd - just hangs, doesnät matter if I start it with asm source as parameter, or without parameters.
Win 7 home.
Ouch. Can you please try also some older versions like v1.12.0 and older? Where the issue did start?
(just running the exe from command line should print out the help page)
Or is here somebody else who has Win 7 and can try it? (It is tested by z00m in "Win 7 pro 32b", that should work)
Can you maybe try also decompress the executable (it's compressed with upx: https://upx.github.io/ ), if it still hangs?
BTW, do you have some antivirus? Doesn't it interfere with it, check maybe some logs or "quarantine" or how these things works (I haven't seen windows for like 12 or 13 years, so I'm not sure how to debug these problems in best way)?
Bedazzle
17.05.2019, 23:51
Can you maybe try also decompress the executable
Decompressed, and it starts ok.
BTW, do you have some antivirus? Doesn't it interfere with it
Yes, Avast.
Tried again original compressed exe, and it showed sandbox. Yesterday it didn't jumped.
So seems it is ok for now.
But.
Tried to compile source, and
https://i.imgur.com/9So09J8.png
And same source with another branch
https://i.imgur.com/Igeiwg8.png
I think it was already reported for another branch, and problem was with includes inside include file:
core.a80 file:
....
INCLUDE "known/_7EC7-7F5F___print_situation.a80"
...
_7EC7-7F5F___print_situation.a80 file:
...
INCLUDE "txt/_7ED5-7EDC___situation.a80"
...
But.
По русски написали, если используешь ' кавычки будь готов что экраны не нужны. Это нормально и правильно, и меня кстати пару раз бесило что раньше было не так.
Про MAP согласен что используется редко. Понадобилось всего 2 раза, просто второй раз совсем недавно, поэтому и заворчал.
Удобно использовать для задания общего массива переменных с адресацией через индексный регистр.
mastermind
18.05.2019, 01:56
Хорошо конечно что стараются, у меня лично на эту ветку были надежды до этого:
Структуры конечно хорошо, но теперь придется прибавлять <char>. там где это совсем не нужно и делать структуру там где она совсем не нужна. Да можно equ понатыкать, вот удобство так удобство считать вручную. Можно еще disp 0 сделать. Но нафига все эти извраты?
Жаль конечно.
MAP/FIELD были выпилены из "основной" ветки тоже давным давно, см. https://zx-pk.ru/threads/447-sjasmplus-z80-kross-assembler.html?p=1002128&viewfull=1#post1002128 (в той же теме далее есть пример как с помощью макросов можно делать то же самое)
MAP/FIELD were removed from the "main" branch years ago as well, see https://zx-pk.ru/threads/447-sjasmplus-z80-kross-assembler.html?p=1002128&viewfull=1#post1002128 (in one of the following messages there is an example of how macros can be used to do the same, at least for some use cases)
I have no idea from that post, what is wrong, I see the FREE RAM output is different, but I don't know this project (are the sources available somewhere or can you create some small example just demonstrating the problem?).
Generally include inside include should be NOT a problem, but maybe there's some bug I am not aware of. If you will manage to help it identify, it would be very nice, thank you.
(the changes in code [I am aware of] were about include search paths, the "" paths start search in current source directory first, while <> paths go through provided include paths first and ends in current source dir, just as the docs specs says.
But in your case, unless you have two different files "txt/_7ED5-7EDC___situation.a80" in different folders, this shouldn't affect your code in any way, because either the correct file is found and included+assembled, or error about opening file would show ... anything else about include-in-include shouldn't be of any special significance, and the assembling state should be pretty much identical as if one big source file was provided, so there's some bug somewhere
There were some changes about auto-wrap of addresses, which affect behaviour around 0x10000 address, maybe that's affecting it?)
(Also I see difference in "compiled lines", but that calculation was slightly modified recently, so this is not conclusive, still same amount of lines may have been assembled by both assemblers, it's just the 1.13.0 does count it differently in some cases, probably around multiple instructions on same line, etc.. so this one doesn't bother me, but the 0x10000 vs 0x0000 is worth attention of course)
(the warning about 0x5C5C is very likely the '\\' thing and as there *was* warning, the final code is identical, would be different in case of no warning.. like ld hl,'\\' is now ld hl,0x5C5C but the warning says that the value was truncated, so only 5C was used of it .... hmm... maybe I should add extra warning about backslash used inside apostrophes for a version or two, so users can check all their source and adjust to quotes or remove escaping backslash?)
Bedazzle
18.05.2019, 13:50
По русски написали, если используешь ' кавычки будь готов что экраны не нужны.
Какие экраны? Нет бэкслэшей в путях, которые в двойных кавычках.
I'm afraid I completely do NOT understand what is the issue, and how it relates to include. Obviously all your files were included and assembled (otherwise there would be error about being unable to open file), and from the screenshots I see only some ("DISPLAY" output maybe?) different "free RAM" value, but that gives me zero context, what is that number and which code is producing it.
The warning is probably produced by constant '\\' in source _7EC7-7F5F___print_situation.a80 at line 106, but you didn't show that one either.
Can you try to explain the problem in some "source -> machine code" way, i.e. showing part of source, and part of listing what machine code was produced, and explain where you see the problem?
Because as is, I see only different DISPLAY output, and you didn't explain what code is producing that and where the difference starts. So at this moment I have no idea how to help you, and what is the problem, sorry.
Какие экраны? Нет бэкслэшей в путях, которые в двойных кавычках.
Тфу ты, перепутал.
В исходнике '\\' или "\\"?
Bedazzle
18.05.2019, 22:34
Тфу ты, перепутал.
В исходнике '\\' или ""?
https://i.imgur.com/KMts7Zf.png
Is this line 106, or why do you show this part of source? I still don't understand why do you think there is some problem with include.
I need you to show the actual failure, like what result is wrong, is there some invalid machine code, or missing machine code, etc?
Maybe switch listing file on (--lst option), and see yourself, how the code is assembled, and if there is something wrong about it, then post the part where you have problem.
https://i.imgur.com/KMts7Zf.png
Я тебя не понимаю человек.
# file opened: test.a80
1 0000 org 0x8000
2 8000 5C db "\\"
3 8001 5C 5C db '\\'
4 8003 3E 5C ld a, "\\"
test.a80(5): warning: Bytes lost (0x5C5C)
5 8005 3E 5C ld a, '\\'
# file closed: test.a80
Value Label
------ - -----------------------------------------------------------
Все правильно, что тебе не нравится?
- - - Добавлено - - -
Для порядка дока
https://i.imgur.com/D9Bxz5T.png
- - - Добавлено - - -
АААА я понял, асм ругается не на инклюд, как ты подумал, а предупреждает что в этом инклюде в 106 строке ты пытаешься два байта загрузить в аккумулятор, и один, естественно, будет отброшен.
- - - Добавлено - - -
Пример одного из применений MAP
org 0x8000
MAP 0
sub1
var1 # 1
ld a, (vars+var1)
ret
sub2
var2 # 2
ld hl, (vars+var2)
ret
sub3
var3 # 4
ld ix, vars
ld c, (ix+var3)
ld b, (ix+var3+1)
ret
vars
Надеюсь Ped7g вернет его в ветку.
Пример одного из применений MAP
org 0x8000
MAP 0
sub1
var1 # 1
ld a, (vars+var1)
ret
sub2
var2 # 2
ld hl, (vars+var2)
ret
sub3
var3 # 4
ld ix, vars
ld c, (ix+var3)
ld b, (ix+var3+1)
ret
vars
Надеюсь Ped7g вернет его в ветку.
Thank you for the example. Now this is like highly subjective opinion (feel free to disagree, hehe), but I don't see anything special about it, like that I would prefer MAP way over STRUCT, actually I personally find this more chaotic and harder to read, because map fields are all over the place in code. Imagine longer code, where "var3" is 100 lines below original MAP 0, then IMO your only chance to quickly mind-map all fields is to actually assemble the file and check the labels table in listing, because looking through the code will be prone to missing other field statements, while struct has all fields defined together in one block of code (maybe in some special case that interleaved field definition inside code is actually better, but IMO for 90% of use cases it is not).
You finish with "vars" without anything after it, not clear if you intentionally left it like that (i.e. for example INCBIN "vars_init_values.bin" follows), which would made usage of structure somewhat more ugly, let's do the struct examples:
STRUCT S_VARS, 0 ; struct has also initial offset if needed (0 here)
var1 # 1
var2 # 2
var3 # 4
ENDS
org 0x8000
sub1
ld a, (vars+S_VARS.var1)
ret
sub2
ld hl, (vars+S_VARS.var2)
ret
sub3
ld ix, vars
ld c, (ix+S_VARS.var3)
ld b, (ix+S_VARS.var3+1)
ret
vars ; INCBIN "init_values.bin" ; can't use "vars S_VARS" easily then
So this is basically 1:1 rewrite of your example, the "+S_VARS.var1" is maybe a bit verbose, but in my personal taste, I find this actually easier to read and understand, and even if you prefer the more brief MAP variant, this should be still "edible" even in this struct form?
But I can see the MAP may feel somewhat more natural especially in cases when you are "mapping" some block of data which exists outside of context of the source, like that INCBIN.
But if you are in case where you are actually also generating the data, the STRUCT will quickly give you lot more power, consider this variant:
STRUCT S_VARS, 0 ; struct has also initial offset if needed (0 here)
var1 DB 'x'
var2 DW 0x4000
var3 DD 'taef' ; = "feat" in bytes
ENDS
org 0x8000
sub1
ld a, (vars.var1) ; direct access to var1 is similar to "vars+var1"
ret
sub2
ld hl, (vars.var2)
ret
sub3
ld ix, vars
ld c, (ix+S_VARS.var3) ; just-offset still needs "S_VARS." prefix
ld b, (ix+S_VARS.var3+1)
ret
vars S_VARS {,0x6000} ; use default values to init except vars2 = 0x6000
so.. I can also understand the reluctance to edit old sources, as they were "correct", and that's a real pain for user.
But also I want to advance the assembler a bit and for contributor the view is quite different, some things which in ASM source may look almost identical (like this MAP vs STRUCT, i find the differences in these examples minimal), pose in the C++ source of sjasmplus quite some difference (MAP-field parsing+detection code was copied on three different places in the code, while STRUCT implementation is lot more self-contained and isolated from regular parsing = easier to understand/maintain/test).
... thinking about it, I probably miss some way to init some label as "struct" type, but yet not to emit the default values, just setting up address. Maybe something like `vars S_VARS = 0x1234` -> that would make `ld a,(vars.var1)` point to 0x1234 ... if I would add something like this, I really can't think of any further major MAP vs STRUCT difference (that "ix+S_VARS.var3" is for me like syntax sugar difference, and if you pick struct name and field name well, such syntax will still produce easy-to-read source line). (EDIT: with such feature the example with INCBIN above would be possible to write as `vars S_VARS = $ : INCBIN ...` and then `ld a,(vars.var1)` would be possible too)
So at this moment I have no plans to add MAP back, it really feels redundant to STRUCT, which can be used to produce identical machine code with very similar ASM source, but STRUCT has also extra features (struct nesting, default values) and in my (subjective) opinion STRUCT leads to better (easier to read) ASM source.
В том и дело что расположение полей будет хаотичным и не нужно следить где именно в коде они распологаются. Это некий аналог сегментов. Лично мне просто не понятно зачем удалать функционал, пусть и не используемый достаточно часто, но иногда нужный. Воспринимать MAP как аналог STRUCT, по моему, не совсем правильно.
В любом случае хозяин барин и для пользователей всегда есть выбор, весь вопрос лишь в совокупности необходимого функционала.
I think this is mostly matter of personal taste, what is "pretty source", so I will definitely keep your comment on mind as +1 for MAP return (in my personal view it is like on -3, so you are balancing it toward zero), thank you for the feedback, it's very important for me, because otherwise I'm in my own world only, not even aware of others.
(it's just low priority at this moment for *me*, because I can fix all your sources from MAP to STRUCT within few minutes if you will send me some "zip", while implementing MAP back into sjasmplus AND fixing any bugs in it, and creating tests to cover it = would take probably couple of hours ... but maybe one day, it's just SW, it can be amended any way any time, if there's time and will to do it)
I'm working on the designed address setup of struct, i.e. `vars S_VARS = $` will be possible (creating only labels vars.<field_label>, but not emitting bytes of the structure) ... that will be in github in few minutes (code and tests are done, need to add documentation).
Also maybe somebody can check how the MAP was resolved by macro in Mastermind's thread, maybe it works as 1:1 replacement and would work as compatibility-helper for old sources, although by thinking about 30s about it, I can't see how macros can catch # and ## in source? So it probably requires some small changes to source any way, and if you are editing old source, the modification to struct is very likely same effort).
(probably this one: https://zx-pk.ru/threads/447-sjasmplus-z80-kross-assembler.html?p=1002203&viewfull=1#post1002203 - that requires old source edits too, so I would rather consider just using STRUCT, but you can definitely do macros similar to this, even taking second argument with size of new field)
NEO SPECTRUMAN
19.05.2019, 23:45
А если я хочу запихнуть в defarray 16K значений
то что мне их запихивать в одну строку?
defarray the_array $0000,$0001,.. ...$3FFD,$3FFE,$3FFF
надо бы как то так
defarray the_array $0000,$0001... ...$000E,$000F
$0010,$0011... ...$001E,$001F
...
$3FF0,$3FF1... ...$3FFE,$3FFF
edefarray
или хотя бы
defarray**** the_array $0000,$0001... ...$000E,$000F
defarray**** the_array $0010,$0011... ...$001E,$001F
...
defarray**** the_array $3FF0,$3FF1... ...$3FFE,$3FFF
edefarray****
или так
defarray the_array $0000,$0001... ...$000E,$000F
addarray the_array $0010,$0011... ...$001E,$001F
...
addarray the_array $3FF0,$3FF1... ...$3FFE,$3FFF
есть еще какието варианты как еще можно сделать подобное?
...
так же нужен fillarray <array_id> <from>, <to>, <value>
Bedazzle
19.05.2019, 23:59
А как правильно делать проверку на версию?
В документации
IF _VERSION = "1.07"
;code for 1.07
ELSE
;code for other version
ENDIF
пробую распечатать при помощи
display "version:", _VERSION
IF _VERSION = "1.13.0"
DEFINE X
ENDIF
IF _VERSION = "20190306.1"
DEFINE Y
ENDIF
получаю переполнение:
https://i.imgur.com/k4uhGLd.png
https://i.imgur.com/CvYTI3g.png
https://i.imgur.com/9oJFd8b.png
NEO SPECTRUMAN
20.05.2019, 01:21
такое тоже не работает
defarray fcknsht_tab /*
*/1,1,1,/*
*/0,0,0,/*
*/0,5,0
ничья ветка sjasm-a не взяла...
а жаль...
- - - Добавлено - - -
ld /*
but this won't be ld a,3!
*/ a,3
ТАК КАКОГО ХРЕНА ДОСИХ ПОР?
NEO SPECTRUMAN:
16ki defarray... hmm... Well, this breaks multiple limits (line limit is 2048 characters and defarray ... defarray is actually linked list with O(N) access time, so defarray itself would work, it would be just a bit slow for large operations O(N*N) for 16ki data created from 16ki defarray, which is still only about ~250mil iterations, so it would very likely still assemble faster then Android Studio edits text).. ok, so this breaks line(parser) limit only, not multiple limits.
From your proposals something like "defarrayadd" seems quite reasonable.
But overall it feels to me like pushing the defarray a bit too far... it's more like string collection (being substituted in early phase of assembling similar way like any other DEFINE), i.e. quite heavy on memory storage and processing, I wouldn't think of it for 16ki array of int16_t.
Although reading your source example again, there's nothing particularly wrong about it from the coder perspective (I have just skewed perspective by knowing the implementation).
How you can work around it in current sjasmplus:
One option is to use device memory as table:
DEVICE ZXSPECTRUM1024 ; some large memory device
MMU 0 1, 62 ; map last memory pages into 0000-7FFF range (16ki of words = 32kiB)
ORG 0
; define values as you wish (has also "fill" in the "BLOCK" (DS) pseudo instruction)
ORG 0x8000 ; now regular code follows, using the table values
ld bc,{1234*2} ; = ld bc,word from address 1234*2 (i.e. index 1234 into word table)
; but the value read from device memory is correct only at the last pass (enough for instructions)
; so this will not work for early pass assembling branching like: IF {1234*2}=4
The {} operator is undocumented "read word from device memory at assembly time" (seems like it's available long time, probably before 1.07, but nobody documented it, and me neither, because I'm not 100% sure it will stay precisely like this in the future, although some similar form will surely remain, because sometimes it's handy). This one is pretty close to O(1) complexity when accessing values, so even the assembling of such source will be probably a bit faster than defarray. And after you are done with the part of code needing the table, you can reuse the device memory/slots for normal parts.
Other option depends what are the data, if you can somehow calculate them by formula, it may be possible to create some FOR loop with formula (how to create FOR-like loops: https://github.com/z00m128/sjasmplus/blob/master/tests/macro_examples/fake_for2.asm
Or finally the Lua is probably powerful enough to just generate the final result you are after (i.e. whether you can calculate values by formula, or you need 16ki table of data and you can produce the final code instead of just doing the table work).
Or obviously you can use any other language to generate "asm" file for you, for more complex code generators it may be simpler to use language you are familiar with.
... I will think about some kind of "defarrayadd", but it still feels slightly "misused" to me at this moment, but that's maybe just a feel. Although I'm not sure about final performance of such code... probably no big issue with modern CPUs with O(N*M). Hm, I will probably add it (should be easy to implement, and it will help to produce shorter lines even with "small" defarray tables = easier to read source = good).
------
Bedazzle:
That's good question, and from my head I would guess there's no good way to work with strings in bare sjasmplus.
You can (similarly as above) work around it by putting the string into device memory (DZ _VERSION = zero terminated string in memory) and then read WORDs of it by {} operator, or you can process it in LUA script (Lua can read defines, i.e. _VERSION too).
I have in my TODO "operators for string manipulation", so maybe in future there will be new tools for this, but at this moment you can compare only last four characters in v1.13.0 (as if comparing numbers):
IF _VERSION = "13.0" ; or: IF _VERSION = 0x31332E30
DISPLAY "version \"13.0\" detected (_VERSION=\"", _VERSION, "\")"
ENDIF
output:
test_version.asm(1): warning: String literal truncated to 0x31332E30: "1.13.0"
> version "13.0" detected (_VERSION="1.13.0")
(it will produce also that warning, but I don't see any simple way to suppress it)
This feels like some unfinished business on the sjasmplus side, thank you for pointing it out.
(you can suppress those overflow warnings to minimum by doing "VERSIONNUM = _VERSION" very early in the source = creating symbol/label with that last-four-chars numeric value, then you can use it in remaining IF blocks: IF VERSIONNUM = "13.0" will produce no more warnings ... so only the initial conversion from string to numeric symbol will do warnings)
Bedazzle
20.05.2019, 11:00
you can process it in LUA script
...
This feels like some unfinished business on the sjasmplus side
I'll better go without LUA - thus way source is more portable.
Thank you for your efforts!
About being portable... even if I add string operators later, it will not compile in any older/other version of sjasmplus, so as long as we are talking about _VERSION define, the double-warning about overflow seems to be best compromise at this moment
(or putting the string into memory first and read it from there per words, but that feels to me a bit more ugly than initial warnings... although if you do such processing only at start of source, and set up your own defines to distinguish between versions, and you are allergic to warnings, this is still viable option (I think {} works also in other version of sjasmplus? Was already part of Aprisobal's source if I recall it correctly)).
EDIT: the real issue is, that sjasmplus assembly has no data types and pretty much everything is 32bit number except "DB/DZ/.." directives, which will break down strings into separate bytes. So giving user pre-defined _VERSION="1.13.0" is sort of bad joke, because there're very limited ways how to process such value, but that's now "legacy", so there's no simple way out of it.
NEO SPECTRUMAN
20.05.2019, 11:25
The {} operator is undocumented "read word from device memory at assembly time"
Сколько раз он мне был нужен раньше...
проверил работает в 3-х разных sjasm-ах
разных производителей
очень даже полезная вешь
- - - Добавлено - - -
Ped7g, а как насчет разделение коментарием через перенос?
defarray jgvbn 0,1,2,3,4,5 /*
*/5,4,3,2,1,0
Ped7g, а как насчет разделение коментарием через перенос?
defarray jgvbn 0,1,2,3,4,5 /*
*/5,4,3,2,1,0
I don't like it, both in style way, and in the internal implementation way.
I was already checking few weeks back, if it would make sense to add the common C/shellscript/.. way of using backslash at end of line, and I can't recall the details now, but the implementation with current sjasmplus internals wouldn't be particularly easy. The block comment proposal is pretty much the same thing, so it would run into the same problems, and it's even less intuitive than backslash (at least for C programmers), seems like bigger "hack".
So some way to "add" to DEFARRAY is lot more preferred, long multi-line feature is more complicated. There are fixed-size 2048 chars buffers all around the code, and even if you overcome that, there are some things like macro/dup reading the source into string-linked-list buffers of their own, so adding backslash for multi-line would need changes on several places of code, while adding "DEFARRAYADD" is almost single short new-block of code, without risk of breaking some complex state in parsing... Actually I'm mentally still in the process of trying to simplify the line parsing / file reading (to have less code paths and fewer code duplicities), maybe after I will give up on that, I will check again for adding backslash feature, but I don't see much pressure for it. This DEFARRAY is first clear case where it would really help, but most of the other cases can be avoided in reasonable way.
So at this moment the "add" variant has much higher chance, I will maybe try it today if I will find some time along work.
"DEFARRAY+" in github (for next release or if you are building from sources)...
docs: http://z00m128.github.io/sjasmplus/documentation.html#po_defarray_plus
Example:
DEFARRAY myarray 'A', 'B', 'C'
DEFARRAY+ myarray 'D', 'E' ; now "myarray" has 5 items
DUP 3 : DEFARRAY+ myarray '!' : EDUP ; "DEFARRAYFILL" adding 3x '!'
As expected, implementing this was quite simple... (for "FILL", if you really need it, just create macro like that DUP in example, but I don't expect it to be needed by 99% of users, so I didn't add it natively)
(but precise targetted overwrite on "from-to" indices would be quite a pain, as internally it's not array, but one direction linked list ... and I don't believe you truly need that, need to see real world case like that, but it sounds like typical "code smell")
Незнаю зачем этот дефарей, мне точно не нужен, для подобного есть луа. Но я тут чутка подумал правильно работающий struct важнее map. Если бы еще убить тупые инфо об incbin то будет вообще отлично.
NEO SPECTRUMAN
29.05.2019, 06:32
для подобного есть луа
ну и как запилить массив в луа?
на встроенную луа инструкции то нет...
мне и там нужны заранне просчитанные таблицы на 64К значений
из которых потом выбирать нужные значения
так как проще будет проинтегрировав функцию сначала просмотреть результат в excell-е
чем тыкаться в lua не имея возможности нормально проверить результат графически... (тк нужно много знаков посля запятой)
Незнаю зачем этот дефарей
а я не знаю зачем и кому нужны твои структуры и мапы и как их можно применить...
для снижения читаемости кода?
- - - Добавлено - - -
ну и как запилить массив в луа?
ссылки на левые статьи не нужно
давай примеры которые переваривает луа в sjasm-е
(которая обычно не берет большую часть команд из lua по ГОСТ-у)
Структуры используются во всех играх, 100%, без них только имитацией тех же структур.
Данные через луа можно загонять прям из той же csv что и в экселе, с парсингом текста луа более менее справляется.
Вообще да, массивы могут пригодится, но не 64к значений, я как то перестал мыслить разложенным кодом, не интересно.
NEO SPECTRUMAN
29.05.2019, 21:41
Данные через луа можно загонять прям из той же csv что и в экселе, с парсингом текста луа более менее справляется.
а пример?
- - - Добавлено - - -
Структуры используются во всех играх, 100%
чот не уверен :)
- - - Добавлено - - -
Вообще да, массивы могут пригодится, но не 64к значений,
ну да это многовато
обычно нужно или совсем мало до 30
или 256...2К
хотя мне ВНЕЗАПНО для одной задачи нужно именно 64К
и чтоб знаков 8 после запятой
или же в луа должно работать goto которого щас нету
тогда можно будет без извращений написать все на луа и даже точнее чем приближенной функцией в екселе...
хотя для єтого все равно было бы лучше если бы были массивы...
идея считать отдельно в бейсике :) мне не нравится
люблю когда можно поменять параметры
и чтоб быстро все пересчиталось самим сджасмом
Если бы еще убить тупые инфо об incbin то будет вообще отлично.
Did you try various levels of `--msg` option? I'm personally using `sjasmplus --nologo --msg=war --lst --lstlab` for almost everything.
-------
About LUA vs DEFARRAY vs anything:
This is kinda pointless discussion, I personally don't like to use Lua in my asm sources, but if somebody does, it's good they can.
If somebody likes to use DEFARRAY instead, why not, it is already part of sjasmplus.
If you hit real world problem with it, like for example the max-line length limit, maybe it can be fixed/improved (I'm not really proud of the "DEFARRAY+" fix, feels a bit like "hack", but it does solve real problem, so whatever... there are many other "hacks" in sjasmplus already, one more doesn't change the situation much).
Similarly the integrated Lua is somewhat outdated now (I guess?), and it would be probably good to update it, there's nothing wrong about it in principle (just needs somebody with time to develop it, not a priority for me at this moment, maybe later).
And finally the integration of Lua into sjasmplus can be also improved (by adding new operators/etc), again I don't see anything wrong about that, except that it must be developed = somebody must invest their life time into it. (and *I* will still like to avoid Lua, even if it will be updated and improved, but it should work)
I.e. if you can provide example of particular problem, it may get fixed/improved. Real problems get usually more attention than theoretical. :smile:
а я не знаю зачем и кому нужны твои структуры и мапы и как их можно применить...
для снижения читаемости кода?
:biggrin: IMO struct can make often source easier to read, but that's just personal preference.
.. anyway v1.13.1 "soon" ... (the current master on github is IMO ready to be released, just doing final checks and tests - if you are building sjasmplus from github, trying it now on your projects and reporting any issue may be good idea, otherwise 1.13.1 will go out as it is now)
NEO SPECTRUMAN
30.05.2019, 14:33
I personally don't like to use Lua in my asm sources, but if somebody does, it's good they can.
для лучшего понимания для чего нужна lua
вот для примера небольшой кусочек моего raycast-ера
как такое можно написать руками?
рассчитывать на самом спектруме не вариант...
(тк точности после запятой в самой lua уже не хватает...)
в оригинале процедура на 48К :)
427 1242 ;================================================= =====
427 1242 RAY_12_ROUTINE
427 1242 ;================================================= =====
427 1242 ray12hit1
427 1242 67 ld h,a
427 1243 2E 01 ld l,1
427 1245 E5 push hl
427 1246 C3 43 14 jp castray13
427 1249 ray12hit2
427 1249 67 ld h,a
427 124A 2E 02 ld l,2
427 124C E5 push hl
427 124D C3 43 14 jp castray13
427 1250 ray12hit3
427 1250 67 ld h,a
427 1251 2E 03 ld l,3
427 1253 E5 push hl
427 1254 C3 43 14 jp castray13
427 1257 ray12hit4
427 1257 67 ld h,a
427 1258 2E 04 ld l,4
427 125A E5 push hl
427 125B C3 43 14 jp castray13
427 125E ray12hit5
427 125E 67 ld h,a
427 125F 2E 05 ld l,5
427 1261 E5 push hl
427 1262 C3 43 14 jp castray13
427 1265 ray12hit6
427 1265 67 ld h,a
427 1266 2E 07 ld l,7
427 1268 E5 push hl
427 1269 C3 43 14 jp castray13
427 126C ray12hit7
427 126C 67 ld h,a
427 126D 2E 07 ld l,7
427 126F E5 push hl
427 1270 C3 43 14 jp castray13
427 1273 ray12hit8
427 1273 67 ld h,a
427 1274 2E 09 ld l,9
427 1276 E5 push hl
427 1277 C3 43 14 jp castray13
427 127A ray12hit9
427 127A 67 ld h,a
427 127B 2E 0A ld l,10
427 127D E5 push hl
427 127E C3 43 14 jp castray13
427 1281 ray12hit10
427 1281 67 ld h,a
427 1282 2E 0B ld l,11
427 1284 E5 push hl
427 1285 C3 43 14 jp castray13
427 1288 ray12hit11
427 1288 67 ld h,a
427 1289 2E 0C ld l,12
427 128B E5 push hl
427 128C C3 43 14 jp castray13
427 128F ray12hit12
427 128F 67 ld h,a
427 1290 2E 0E ld l,14
427 1292 E5 push hl
427 1293 C3 43 14 jp castray13
427 1296 ray12hit13
427 1296 67 ld h,a
427 1297 2E 0F ld l,15
427 1299 E5 push hl
427 129A C3 43 14 jp castray13
427 129D ray12hit14
427 129D 67 ld h,a
427 129E 2E 10 ld l,16
427 12A0 E5 push hl
427 12A1 C3 43 14 jp castray13
427 12A4 ray12hit15
427 12A4 67 ld h,a
427 12A5 2E 11 ld l,17
427 12A7 E5 push hl
427 12A8 C3 43 14 jp castray13
427 12AB ray12hit16
427 12AB 67 ld h,a
427 12AC 2E 12 ld l,18
427 12AE E5 push hl
427 12AF C3 43 14 jp castray13
427 12B2 ;================================================= =====
427 12B2 castray12
427 12B2 0D dec c
427 12B3 CA 10 C5 jp z,raycast_end
427 12B6 AF xor a
427 12B7 62 ld h,d
427 12B8 6B ld l,e
427 12B9 24 inc h
427 12BA B6 or (hl)
427 12BB 20 85 jr nz,ray12hit1
427 12BD 2C inc l
427 12BE 24 inc h
427 12BF B6 or (hl)
427 12C0 20 87 jr nz,ray12hit2
427 12C2 2C inc l
427 12C3 24 inc h
427 12C4 B6 or (hl)
427 12C5 20 89 jr nz,ray12hit3
427 12C7 2C inc l
427 12C8 B6 or (hl)
427 12C9 20 8C jr nz,ray12hit4
427 12CB 2C inc l
427 12CC 24 inc h
427 12CD B6 or (hl)
427 12CE 20 8E jr nz,ray12hit5
427 12D0 2C inc l
427 12D1 24 inc h
427 12D2 B6 or (hl)
427 12D3 20 90 jr nz,ray12hit6
427 12D5 2C inc l
427 12D6 B6 or (hl)
427 12D7 20 93 jr nz,ray12hit7
427 12D9 2C inc l
427 12DA 24 inc h
427 12DB B6 or (hl)
427 12DC 20 95 jr nz,ray12hit8
427 12DE 2C inc l
427 12DF 24 inc h
427 12E0 B6 or (hl)
427 12E1 20 97 jr nz,ray12hit9
427 12E3 2C inc l
427 12E4 B6 or (hl)
427 12E5 20 9A jr nz,ray12hit10
427 12E7 2C inc l
427 12E8 24 inc h
427 12E9 B6 or (hl)
427 12EA 20 9C jr nz,ray12hit11
427 12EC 2C inc l
427 12ED 24 inc h
427 12EE B6 or (hl)
427 12EF 20 9E jr nz,ray12hit12
427 12F1 2C inc l
427 12F2 B6 or (hl)
427 12F3 20 A1 jr nz,ray12hit13
427 12F5 2C inc l
427 12F6 24 inc h
427 12F7 B6 or (hl)
427 12F8 20 A3 jr nz,ray12hit14
427 12FA 2C inc l
427 12FB 24 inc h
427 12FC B6 or (hl)
427 12FD 20 A5 jr nz,ray12hit15
427 12FF 2C inc l
427 1300 B6 or (hl)
427 1301 20 A8 jr nz,ray12hit16
427 1303 2C inc l
427 1304 24 inc h
427 1305 B6 or (hl)
427 1306 20 54 jr nz,ray12hit17
427 1308 2C inc l
427 1309 24 inc h
427 130A B6 or (hl)
427 130B 20 56 jr nz,ray12hit18
427 130D 2C inc l
427 130E B6 or (hl)
427 130F 20 59 jr nz,ray12hit19
427 1311 2C inc l
427 1312 24 inc h
427 1313 B6 or (hl)
427 1314 20 5B jr nz,ray12hit20
427 1316 2C inc l
427 1317 24 inc h
427 1318 B6 or (hl)
427 1319 20 5D jr nz,ray12hit21
427 131B 2C inc l
427 131C B6 or (hl)
427 131D 20 60 jr nz,ray12hit22
427 131F 2C inc l
427 1320 24 inc h
427 1321 B6 or (hl)
427 1322 20 62 jr nz,ray12hit23
427 1324 2C inc l
427 1325 24 inc h
427 1326 B6 or (hl)
427 1327 20 64 jr nz,ray12hit24
427 1329 2C inc l
427 132A B6 or (hl)
427 132B 20 67 jr nz,ray12hit25
427 132D 2C inc l
427 132E 24 inc h
427 132F B6 or (hl)
427 1330 20 69 jr nz,ray12hit26
427 1332 2C inc l
427 1333 24 inc h
427 1334 B6 or (hl)
427 1335 20 6B jr nz,ray12hit27
427 1337 2C inc l
427 1338 B6 or (hl)
427 1339 20 6E jr nz,ray12hit28
427 133B 2C inc l
427 133C 24 inc h
427 133D B6 or (hl)
427 133E 20 70 jr nz,ray12hit29
427 1340 2C inc l
427 1341 24 inc h
427 1342 B6 or (hl)
427 1343 20 72 jr nz,ray12hit30
427 1345 2C inc l
427 1346 B6 or (hl)
427 1347 20 75 jr nz,ray12hit31
427 1349 2C inc l
427 134A 24 inc h
427 134B B6 or (hl)
427 134C 20 77 jr nz,ray12hit32
427 134E 2C inc l
427 134F 24 inc h
427 1350 B6 or (hl)
427 1351 20 79 jr nz,ray12hit33
427 1353 2C inc l
427 1354 B6 or (hl)
427 1355 ray12hit34
427 1355 ; скорей всего луч никуда не попал
427 1355 67 ld h,a
427 1356 2E 28 ld l,40
427 1358 E5 push hl
427 1359 C3 43 14 jp castray13
427 135C ray12hit17
427 135C 67 ld h,a
427 135D 2E 14 ld l,20
427 135F E5 push hl
427 1360 C3 43 14 jp castray13
427 1363 ray12hit18
427 1363 67 ld h,a
427 1364 2E 15 ld l,21
427 1366 E5 push hl
427 1367 C3 43 14 jp castray13
427 136A ray12hit19
427 136A 67 ld h,a
427 136B 2E 16 ld l,22
427 136D E5 push hl
427 136E C3 43 14 jp castray13
427 1371 ray12hit20
427 1371 67 ld h,a
427 1372 2E 17 ld l,23
427 1374 E5 push hl
427 1375 C3 43 14 jp castray13
427 1378 ray12hit21
427 1378 67 ld h,a
427 1379 2E 19 ld l,25
427 137B E5 push hl
427 137C C3 43 14 jp castray13
427 137F ray12hit22
427 137F 67 ld h,a
427 1380 2E 19 ld l,25
427 1382 E5 push hl
427 1383 C3 43 14 jp castray13
427 1386 ray12hit23
427 1386 67 ld h,a
427 1387 2E 1B ld l,27
427 1389 E5 push hl
427 138A C3 43 14 jp castray13
427 138D ray12hit24
427 138D 67 ld h,a
427 138E 2E 1C ld l,28
427 1390 E5 push hl
427 1391 C3 43 14 jp castray13
427 1394 ray12hit25
427 1394 67 ld h,a
427 1395 2E 1D ld l,29
427 1397 E5 push hl
427 1398 C3 43 14 jp castray13
427 139B ray12hit26
427 139B 67 ld h,a
427 139C 2E 1E ld l,30
427 139E E5 push hl
427 139F C3 43 14 jp castray13
427 13A2 ray12hit27
427 13A2 67 ld h,a
427 13A3 2E 20 ld l,32
427 13A5 E5 push hl
427 13A6 C3 43 14 jp castray13
427 13A9 ray12hit28
427 13A9 67 ld h,a
427 13AA 2E 21 ld l,33
427 13AC E5 push hl
427 13AD C3 43 14 jp castray13
427 13B0 ray12hit29
427 13B0 67 ld h,a
427 13B1 2E 22 ld l,34
427 13B3 E5 push hl
427 13B4 C3 43 14 jp castray13
427 13B7 ray12hit30
427 13B7 67 ld h,a
427 13B8 2E 23 ld l,35
427 13BA E5 push hl
427 13BB C3 43 14 jp castray13
427 13BE ray12hit31
427 13BE 67 ld h,a
427 13BF 2E 24 ld l,36
427 13C1 E5 push hl
427 13C2 C3 43 14 jp castray13
427 13C5 ray12hit32
427 13C5 67 ld h,a
427 13C6 2E 26 ld l,38
427 13C8 E5 push hl
427 13C9 C3 43 14 jp castray13
427 13CC ray12hit33
427 13CC 67 ld h,a
427 13CD 2E 27 ld l,39
427 13CF E5 push hl
427 13D0 C3 43 14 jp castray13
427 13D3 ;================================================= =====
427 13D3 RAY_13_ROUTINE
427 13D3 ;================================================= =====
427 13D3 ray13hit1
427 13D3 67 ld h,a
427 13D4 2E 01 ld l,1
427 13D6 E5 push hl
427 13D7 C3 D8 15 jp castray14
427 13DA ray13hit2
427 13DA 67 ld h,a
427 13DB 2E 02 ld l,2
427 13DD E5 push hl
427 13DE C3 D8 15 jp castray14
427 13E1 ray13hit3
427 13E1 67 ld h,a
427 13E2 2E 04 ld l,4
427 13E4 E5 push hl
427 13E5 C3 D8 15 jp castray14
427 13E8 ray13hit4
427 13E8 67 ld h,a
427 13E9 2E 05 ld l,5
427 13EB E5 push hl
427 13EC C3 D8 15 jp castray14
427 13EF ray13hit5
427 13EF 67 ld h,a
427 13F0 2E 06 ld l,6
427 13F2 E5 push hl
427 13F3 C3 D8 15 jp castray14
427 13F6 ray13hit6
427 13F6 67 ld h,a
427 13F7 2E 07 ld l,7
427 13F9 E5 push hl
427 13FA C3 D8 15 jp castray14
427 13FD ray13hit7
427 13FD 67 ld h,a
427 13FE 2E 09 ld l,9
427 1400 E5 push hl
427 1401 C3 D8 15 jp castray14
427 1404 ray13hit8
427 1404 67 ld h,a
427 1405 2E 0A ld l,10
427 1407 E5 push hl
427 1408 C3 D8 15 jp castray14
427 140B ray13hit9
427 140B 67 ld h,a
427 140C 2E 0B ld l,11
427 140E E5 push hl
427 140F C3 D8 15 jp castray14
427 1412 ray13hit10
427 1412 67 ld h,a
427 1413 2E 0C ld l,12
427 1415 E5 push hl
427 1416 C3 D8 15 jp castray14
427 1419 ray13hit11
427 1419 67 ld h,a
427 141A 2E 0E ld l,14
427 141C E5 push hl
427 141D C3 D8 15 jp castray14
427 1420 ray13hit12
427 1420 67 ld h,a
427 1421 2E 0F ld l,15
427 1423 E5 push hl
427 1424 C3 D8 15 jp castray14
427 1427 ray13hit13
427 1427 67 ld h,a
427 1428 2E 10 ld l,16
427 142A E5 push hl
427 142B C3 D8 15 jp castray14
427 142E ray13hit14
427 142E 67 ld h,a
427 142F 2E 11 ld l,17
427 1431 E5 push hl
427 1432 C3 D8 15 jp castray14
427 1435 ray13hit15
427 1435 67 ld h,a
427 1436 2E 13 ld l,19
427 1438 E5 push hl
427 1439 C3 D8 15 jp castray14
427 143C ray13hit16
427 143C 67 ld h,a
427 143D 2E 14 ld l,20
427 143F E5 push hl
427 1440 C3 D8 15 jp castray14
427 1443 ;================================================= =====
427 1443 castray13
427 1443 0D dec c
427 1444 CA 10 C5 jp z,raycast_end
427 1447 AF xor a
427 1448 62 ld h,d
427 1449 6B ld l,e
427 144A 2C inc l
427 144B 24 inc h
427 144C B6 or (hl)
427 144D 20 84 jr nz,ray13hit1
427 144F 2C inc l
427 1450 24 inc h
427 1451 B6 or (hl)
427 1452 20 86 jr nz,ray13hit2
427 1454 2C inc l
427 1455 24 inc h
427 1456 B6 or (hl)
427 1457 20 88 jr nz,ray13hit3
427 1459 2C inc l
427 145A B6 or (hl)
427 145B 20 8B jr nz,ray13hit4
427 145D 2C inc l
427 145E 24 inc h
427 145F B6 or (hl)
427 1460 20 8D jr nz,ray13hit5
427 1462 2C inc l
427 1463 24 inc h
427 1464 B6 or (hl)
427 1465 20 8F jr nz,ray13hit6
427 1467 2C inc l
427 1468 24 inc h
427 1469 B6 or (hl)
427 146A 20 91 jr nz,ray13hit7
427 146C 2C inc l
427 146D B6 or (hl)
427 146E 20 94 jr nz,ray13hit8
427 1470 2C inc l
427 1471 24 inc h
427 1472 B6 or (hl)
427 1473 20 96 jr nz,ray13hit9
427 1475 2C inc l
427 1476 24 inc h
427 1477 B6 or (hl)
427 1478 20 98 jr nz,ray13hit10
427 147A 2C inc l
427 147B 24 inc h
427 147C B6 or (hl)
427 147D 20 9A jr nz,ray13hit11
427 147F 2C inc l
427 1480 B6 or (hl)
427 1481 20 9D jr nz,ray13hit12
427 1483 2C inc l
427 1484 24 inc h
427 1485 B6 or (hl)
427 1486 20 9F jr nz,ray13hit13
427 1488 2C inc l
427 1489 24 inc h
427 148A B6 or (hl)
427 148B 20 A1 jr nz,ray13hit14
427 148D 2C inc l
427 148E 24 inc h
427 148F B6 or (hl)
427 1490 20 A3 jr nz,ray13hit15
427 1492 2C inc l
427 1493 B6 or (hl)
427 1494 20 A6 jr nz,ray13hit16
427 1496 2C inc l
427 1497 24 inc h
427 1498 B6 or (hl)
427 1499 20 56 jr nz,ray13hit17
427 149B 2C inc l
427 149C 24 inc h
427 149D B6 or (hl)
427 149E 20 58 jr nz,ray13hit18
427 14A0 2C inc l
427 14A1 24 inc h
427 14A2 B6 or (hl)
427 14A3 20 5A jr nz,ray13hit19
427 14A5 2C inc l
427 14A6 B6 or (hl)
427 14A7 20 5D jr nz,ray13hit20
427 14A9 2C inc l
427 14AA 24 inc h
427 14AB B6 or (hl)
427 14AC 20 5F jr nz,ray13hit21
427 14AE 2C inc l
427 14AF 24 inc h
427 14B0 B6 or (hl)
427 14B1 20 61 jr nz,ray13hit22
427 14B3 2C inc l
427 14B4 24 inc h
427 14B5 B6 or (hl)
427 14B6 20 63 jr nz,ray13hit23
427 14B8 2C inc l
427 14B9 B6 or (hl)
427 14BA 20 66 jr nz,ray13hit24
427 14BC 2C inc l
427 14BD 24 inc h
427 14BE B6 or (hl)
427 14BF 20 68 jr nz,ray13hit25
427 14C1 2C inc l
427 14C2 24 inc h
427 14C3 B6 or (hl)
427 14C4 20 6A jr nz,ray13hit26
427 14C6 2C inc l
427 14C7 24 inc h
427 14C8 B6 or (hl)
427 14C9 20 6C jr nz,ray13hit27
427 14CB 2C inc l
427 14CC B6 or (hl)
427 14CD 20 6F jr nz,ray13hit28
427 14CF 2C inc l
427 14D0 24 inc h
427 14D1 B6 or (hl)
427 14D2 20 71 jr nz,ray13hit29
427 14D4 2C inc l
427 14D5 24 inc h
427 14D6 B6 or (hl)
427 14D7 20 73 jr nz,ray13hit30
427 14D9 2C inc l
427 14DA B6 or (hl)
427 14DB 20 76 jr nz,ray13hit31
427 14DD 2C inc l
427 14DE 24 inc h
427 14DF B6 or (hl)
427 14E0 20 78 jr nz,ray13hit32
427 14E2 2C inc l
427 14E3 24 inc h
427 14E4 B6 or (hl)
427 14E5 20 7A jr nz,ray13hit33
427 14E7 2C inc l
427 14E8 24 inc h
427 14E9 B6 or (hl)
427 14EA ray13hit34
427 14EA ; скорей всего луч никуда не попал
427 14EA 67 ld h,a
427 14EB 2E 2A ld l,42
427 14ED E5 push hl
427 14EE C3 D8 15 jp castray14
427 14F1 ray13hit17
427 14F1 67 ld h,a
427 14F2 2E 15 ld l,21
427 14F4 E5 push hl
427 14F5 C3 D8 15 jp castray14
427 14F8 ray13hit18
427 14F8 67 ld h,a
427 14F9 2E 16 ld l,22
427 14FB E5 push hl
427 14FC C3 D8 15 jp castray14
427 14FF ray13hit19
427 14FF 67 ld h,a
427 1500 2E 18 ld l,24
427 1502 E5 push hl
427 1503 C3 D8 15 jp castray14
427 1506 ray13hit20
427 1506 67 ld h,a
427 1507 2E 19 ld l,25
427 1509 E5 push hl
427 150A C3 D8 15 jp castray14
427 150D ray13hit21
427 150D 67 ld h,a
427 150E 2E 1A ld l,26
427 1510 E5 push hl
427 1511 C3 D8 15 jp castray14
427 1514 ray13hit22
427 1514 67 ld h,a
427 1515 2E 1B ld l,27
427 1517 E5 push hl
427 1518 C3 D8 15 jp castray14
427 151B ray13hit23
427 151B 67 ld h,a
427 151C 2E 1D ld l,29
427 151E E5 push hl
427 151F C3 D8 15 jp castray14
427 1522 ray13hit24
427 1522 67 ld h,a
427 1523 2E 1E ld l,30
427 1525 E5 push hl
427 1526 C3 D8 15 jp castray14
427 1529 ray13hit25
427 1529 67 ld h,a
427 152A 2E 1F ld l,31
427 152C E5 push hl
427 152D C3 D8 15 jp castray14
427 1530 ray13hit26
427 1530 67 ld h,a
427 1531 2E 20 ld l,32
427 1533 E5 push hl
427 1534 C3 D8 15 jp castray14
427 1537 ray13hit27
427 1537 67 ld h,a
427 1538 2E 22 ld l,34
427 153A E5 push hl
427 153B C3 D8 15 jp castray14
427 153E ray13hit28
427 153E 67 ld h,a
427 153F 2E 23 ld l,35
427 1541 E5 push hl
427 1542 C3 D8 15 jp castray14
427 1545 ray13hit29
427 1545 67 ld h,a
427 1546 2E 24 ld l,36
427 1548 E5 push hl
427 1549 C3 D8 15 jp castray14
427 154C ray13hit30
427 154C 67 ld h,a
427 154D 2E 25 ld l,37
427 154F E5 push hl
427 1550 C3 D8 15 jp castray14
427 1553 ray13hit31
427 1553 67 ld h,a
427 1554 2E 26 ld l,38
427 1556 E5 push hl
427 1557 C3 D8 15 jp castray14
427 155A ray13hit32
427 155A 67 ld h,a
427 155B 2E 28 ld l,40
427 155D E5 push hl
427 155E C3 D8 15 jp castray14
427 1561 ray13hit33
427 1561 67 ld h,a
427 1562 2E 29 ld l,41
427 1564 E5 push hl
427 1565 C3 D8 15 jp castray14
427 1568 ;================================================= =====
427 1568 RAY_14_ROUTINE
427 1568 ;================================================= =====
427 1568 ray14hit1
427 1568 67 ld h,a
427 1569 2E 01 ld l,1
427 156B E5 push hl
427 156C C3 6F 17 jp castray15
427 156F ray14hit2
427 156F 67 ld h,a
427 1570 2E 02 ld l,2
427 1572 E5 push hl
427 1573 C3 6F 17 jp castray15
427 1576 ray14hit3
427 1576 67 ld h,a
427 1577 2E 04 ld l,4
427 1579 E5 push hl
427 157A C3 6F 17 jp castray15
427 157D ray14hit4
427 157D 67 ld h,a
427 157E 2E 05 ld l,5
427 1580 E5 push hl
427 1581 C3 6F 17 jp castray15
427 1584 ray14hit5
427 1584 67 ld h,a
427 1585 2E 07 ld l,7
427 1587 E5 push hl
427 1588 C3 6F 17 jp castray15
427 158B ray14hit6
427 158B 67 ld h,a
427 158C 2E 07 ld l,7
427 158E E5 push hl
427 158F C3 6F 17 jp castray15
427 1592 ray14hit7
427 1592 67 ld h,a
427 1593 2E 09 ld l,9
427 1595 E5 push hl
427 1596 C3 6F 17 jp castray15
427 1599 ray14hit8
427 1599 67 ld h,a
427 159A 2E 0A ld l,10
427 159C E5 push hl
427 159D C3 6F 17 jp castray15
427 15A0 ray14hit9
427 15A0 67 ld h,a
427 15A1 2E 0C ld l,12
427 15A3 E5 push hl
427 15A4 C3 6F 17 jp castray15
427 15A7 ray14hit10
427 15A7 67 ld h,a
427 15A8 2E 0D ld l,13
427 15AA E5 push hl
427 15AB C3 6F 17 jp castray15
427 15AE ray14hit11
427 15AE 67 ld h,a
427 15AF 2E 0E ld l,14
427 15B1 E5 push hl
427 15B2 C3 6F 17 jp castray15
427 15B5 ray14hit12
427 15B5 67 ld h,a
427 15B6 2E 0F ld l,15
427 15B8 E5 push hl
427 15B9 C3 6F 17 jp castray15
427 15BC ray14hit13
427 15BC 67 ld h,a
427 15BD 2E 11 ld l,17
427 15BF E5 push hl
427 15C0 C3 6F 17 jp castray15
427 15C3 ray14hit14
427 15C3 67 ld h,a
427 15C4 2E 12 ld l,18
427 15C6 E5 push hl
427 15C7 C3 6F 17 jp castray15
427 15CA ray14hit15
427 15CA 67 ld h,a
427 15CB 2E 13 ld l,19
427 15CD E5 push hl
427 15CE C3 6F 17 jp castray15
427 15D1 ray14hit16
427 15D1 67 ld h,a
427 15D2 2E 15 ld l,21
427 15D4 E5 push hl
427 15D5 C3 6F 17 jp castray15
427 15D8 ;================================================= =====
427 15D8 castray14
427 15D8 0D dec c
427 15D9 CA 10 C5 jp z,raycast_end
427 15DC AF xor a
427 15DD 62 ld h,d
427 15DE 6B ld l,e
427 15DF 2C inc l
427 15E0 24 inc h
427 15E1 B6 or (hl)
427 15E2 20 84 jr nz,ray14hit1
427 15E4 2C inc l
427 15E5 24 inc h
427 15E6 B6 or (hl)
427 15E7 20 86 jr nz,ray14hit2
427 15E9 2C inc l
427 15EA 24 inc h
427 15EB B6 or (hl)
427 15EC 20 88 jr nz,ray14hit3
427 15EE 2C inc l
427 15EF 24 inc h
427 15F0 B6 or (hl)
427 15F1 20 8A jr nz,ray14hit4
427 15F3 2C inc l
427 15F4 24 inc h
427 15F5 B6 or (hl)
427 15F6 20 8C jr nz,ray14hit5
427 15F8 2C inc l
427 15F9 B6 or (hl)
427 15FA 20 8F jr nz,ray14hit6
427 15FC 2C inc l
427 15FD 24 inc h
427 15FE B6 or (hl)
427 15FF 20 91 jr nz,ray14hit7
427 1601 2C inc l
427 1602 24 inc h
427 1603 B6 or (hl)
427 1604 20 93 jr nz,ray14hit8
427 1606 2C inc l
427 1607 24 inc h
427 1608 B6 or (hl)
427 1609 20 95 jr nz,ray14hit9
427 160B 2C inc l
427 160C 24 inc h
427 160D B6 or (hl)
427 160E 20 97 jr nz,ray14hit10
427 1610 2C inc l
427 1611 24 inc h
427 1612 B6 or (hl)
427 1613 20 99 jr nz,ray14hit11
427 1615 2C inc l
427 1616 B6 or (hl)
427 1617 20 9C jr nz,ray14hit12
427 1619 2C inc l
427 161A 24 inc h
427 161B B6 or (hl)
427 161C 20 9E jr nz,ray14hit13
427 161E 2C inc l
427 161F 24 inc h
427 1620 B6 or (hl)
427 1621 20 A0 jr nz,ray14hit14
427 1623 2C inc l
427 1624 24 inc h
427 1625 B6 or (hl)
427 1626 20 A2 jr nz,ray14hit15
427 1628 2C inc l
427 1629 24 inc h
427 162A B6 or (hl)
427 162B 20 A4 jr nz,ray14hit16
427 162D 2C inc l
427 162E B6 or (hl)
427 162F 20 57 jr nz,ray14hit17
427 1631 2C inc l
427 1632 24 inc h
427 1633 B6 or (hl)
427 1634 20 59 jr nz,ray14hit18
427 1636 2C inc l
427 1637 24 inc h
427 1638 B6 or (hl)
427 1639 20 5B jr nz,ray14hit19
427 163B 2C inc l
427 163C 24 inc h
427 163D B6 or (hl)
427 163E 20 5D jr nz,ray14hit20
427 1640 2C inc l
427 1641 24 inc h
427 1642 B6 or (hl)
427 1643 20 5F jr nz,ray14hit21
427 1645 2C inc l
427 1646 24 inc h
427 1647 B6 or (hl)
427 1648 20 61 jr nz,ray14hit22
427 164A 2C inc l
427 164B B6 or (hl)
427 164C 20 64 jr nz,ray14hit23
427 164E 2C inc l
427 164F 24 inc h
427 1650 B6 or (hl)
427 1651 20 66 jr nz,ray14hit24
427 1653 2C inc l
427 1654 24 inc h
427 1655 B6 or (hl)
427 1656 20 68 jr nz,ray14hit25
427 1658 2C inc l
427 1659 24 inc h
427 165A B6 or (hl)
427 165B 20 6A jr nz,ray14hit26
427 165D 2C inc l
427 165E 24 inc h
427 165F B6 or (hl)
427 1660 20 6C jr nz,ray14hit27
427 1662 2C inc l
427 1663 B6 or (hl)
427 1664 20 6F jr nz,ray14hit28
427 1666 2C inc l
427 1667 24 inc h
427 1668 B6 or (hl)
427 1669 20 71 jr nz,ray14hit29
427 166B 2C inc l
427 166C 24 inc h
427 166D B6 or (hl)
427 166E 20 73 jr nz,ray14hit30
427 1670 2C inc l
427 1671 24 inc h
427 1672 B6 or (hl)
427 1673 20 75 jr nz,ray14hit31
427 1675 2C inc l
427 1676 24 inc h
427 1677 B6 or (hl)
427 1678 20 77 jr nz,ray14hit32
427 167A 2C inc l
427 167B 24 inc h
427 167C B6 or (hl)
427 167D 20 79 jr nz,ray14hit33
427 167F 2C inc l
427 1680 B6 or (hl)
427 1681 ray14hit34
427 1681 ; скорей всего луч никуда не попал
427 1681 67 ld h,a
427 1682 2E 2C ld l,44
427 1684 E5 push hl
427 1685 C3 6F 17 jp castray15
427 1688 ray14hit17
427 1688 67 ld h,a
427 1689 2E 16 ld l,22
427 168B E5 push hl
427 168C C3 6F 17 jp castray15
427 168F ray14hit18
427 168F 67 ld h,a
427 1690 2E 17 ld l,23
427 1692 E5 push hl
427 1693 C3 6F 17 jp castray15
427 1696 ray14hit19
427 1696 67 ld h,a
427 1697 2E 18 ld l,24
427 1699 E5 push hl
427 169A C3 6F 17 jp castray15
427 169D ray14hit20
427 169D 67 ld h,a
427 169E 2E 1A ld l,26
427 16A0 E5 push hl
427 16A1 C3 6F 17 jp castray15
427 16A4 ray14hit21
427 16A4 67 ld h,a
427 16A5 2E 1B ld l,27
427 16A7 E5 push hl
427 16A8 C3 6F 17 jp castray15
427 16AB ray14hit22
427 16AB 67 ld h,a
427 16AC 2E 1D ld l,29
427 16AE E5 push hl
427 16AF C3 6F 17 jp castray15
427 16B2 ray14hit23
427 16B2 67 ld h,a
427 16B3 2E 1D ld l,29
427 16B5 E5 push hl
427 16B6 C3 6F 17 jp castray15
427 16B9 ray14hit24
427 16B9 67 ld h,a
427 16BA 2E 1F ld l,31
427 16BC E5 push hl
427 16BD C3 6F 17 jp castray15
427 16C0 ray14hit25
427 16C0 67 ld h,a
427 16C1 2E 20 ld l,32
427 16C3 E5 push hl
427 16C4 C3 6F 17 jp castray15
427 16C7 ray14hit26
427 16C7 67 ld h,a
427 16C8 2E 22 ld l,34
427 16CA E5 push hl
427 16CB C3 6F 17 jp castray15
427 16CE ray14hit27
427 16CE 67 ld h,a
427 16CF 2E 23 ld l,35
427 16D1 E5 push hl
427 16D2 C3 6F 17 jp castray15
427 16D5 ray14hit28
427 16D5 67 ld h,a
427 16D6 2E 24 ld l,36
427 16D8 E5 push hl
427 16D9 C3 6F 17 jp castray15
427 16DC ray14hit29
427 16DC 67 ld h,a
427 16DD 2E 25 ld l,37
427 16DF E5 push hl
427 16E0 C3 6F 17 jp castray15
427 16E3 ray14hit30
427 16E3 67 ld h,a
427 16E4 2E 27 ld l,39
427 16E6 E5 push hl
427 16E7 C3 6F 17 jp castray15
427 16EA ray14hit31
427 16EA 67 ld h,a
427 16EB 2E 28 ld l,40
427 16ED E5 push hl
427 16EE C3 6F 17 jp castray15
427 16F1 ray14hit32
427 16F1 67 ld h,a
427 16F2 2E 29 ld l,41
427 16F4 E5 push hl
427 16F5 C3 6F 17 jp castray15
427 16F8 ray14hit33
427 16F8 67 ld h,a
427 16F9 2E 2B ld l,43
427 16FB E5 push hl
427 16FC C3 6F 17 jp castray15
- - - Добавлено - - -
3Ы: Кто напишет быстрее? :v2_dizzy_vodka2:
https://github.com/z00m128/sjasmplus/releases/tag/v1.13.1
Changelog:
v1.13.1:
- added --syntax command line option
- added OPT directive (modifies some command line options)
- added way to use structure at designed address
- MACRO can be now named through label (optional syntax)
- added DEFARRAY+ directive (for splitting long list of DEFARRAY values)
- added CSPECTMAP directive for MAP files for CSpect emulator
- added support for SJASMPLUSOPTS environment variable
- Z80N new variants of syntax, now also "mul de : mul : pixelad hl : pixeldn hl" works
- minor bugfixes, improvements and internal refactorings (error reporting)
- updated syntax-highlight file for KDE5 editors (Kate)
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
для лучшего понимания для чего нужна lua
вот для примера небольшой кусочек моего raycast-ера
как такое можно написать руками?
рассчитывать на самом спектруме не вариант...
(тк точности после запятой в самой lua уже не хватает...)
в оригинале процедура на 48К :)
427 1242 ;================================================= =====
427 1242 RAY_12_ROUTINE
427 1242 ;================================================= =====
427 1242 ray12hit1
427 1242 67 ld h,a
427 1243 2E 01 ld l,1
427 1245 E5 push hl
427 1246 C3 43 14 jp castray13
427 1249 ray12hit2
427 1249 67 ld h,a
427 124A 2E 02 ld l,2
427 124C E5 push hl
427 124D C3 43 14 jp castray13
427 1250 ray12hit3
427 1250 67 ld h,a
427 1251 2E 03 ld l,3
427 1253 E5 push hl
427 1254 C3 43 14 jp castray13
427 1257 ray12hit4
427 1257 67 ld h,a
427 1258 2E 04 ld l,4
427 125A E5 push hl
427 125B C3 43 14 jp castray13
427 125E ray12hit5
427 125E 67 ld h,a
427 125F 2E 05 ld l,5
427 1261 E5 push hl
427 1262 C3 43 14 jp castray13
427 1265 ray12hit6
427 1265 67 ld h,a
427 1266 2E 07 ld l,7
427 1268 E5 push hl
427 1269 C3 43 14 jp castray13
427 126C ray12hit7
427 126C 67 ld h,a
427 126D 2E 07 ld l,7
427 126F E5 push hl
427 1270 C3 43 14 jp castray13
427 1273 ray12hit8
427 1273 67 ld h,a
427 1274 2E 09 ld l,9
427 1276 E5 push hl
427 1277 C3 43 14 jp castray13
427 127A ray12hit9
427 127A 67 ld h,a
427 127B 2E 0A ld l,10
427 127D E5 push hl
427 127E C3 43 14 jp castray13
427 1281 ray12hit10
427 1281 67 ld h,a
427 1282 2E 0B ld l,11
427 1284 E5 push hl
427 1285 C3 43 14 jp castray13
427 1288 ray12hit11
427 1288 67 ld h,a
427 1289 2E 0C ld l,12
427 128B E5 push hl
427 128C C3 43 14 jp castray13
427 128F ray12hit12
427 128F 67 ld h,a
427 1290 2E 0E ld l,14
427 1292 E5 push hl
427 1293 C3 43 14 jp castray13
427 1296 ray12hit13
427 1296 67 ld h,a
427 1297 2E 0F ld l,15
427 1299 E5 push hl
427 129A C3 43 14 jp castray13
427 129D ray12hit14
427 129D 67 ld h,a
427 129E 2E 10 ld l,16
427 12A0 E5 push hl
427 12A1 C3 43 14 jp castray13
427 12A4 ray12hit15
427 12A4 67 ld h,a
427 12A5 2E 11 ld l,17
427 12A7 E5 push hl
427 12A8 C3 43 14 jp castray13
427 12AB ray12hit16
427 12AB 67 ld h,a
427 12AC 2E 12 ld l,18
427 12AE E5 push hl
427 12AF C3 43 14 jp castray13
427 12B2 ;================================================= =====
427 12B2 castray12
427 12B2 0D dec c
427 12B3 CA 10 C5 jp z,raycast_end
427 12B6 AF xor a
427 12B7 62 ld h,d
427 12B8 6B ld l,e
427 12B9 24 inc h
427 12BA B6 or (hl)
427 12BB 20 85 jr nz,ray12hit1
427 12BD 2C inc l
427 12BE 24 inc h
427 12BF B6 or (hl)
427 12C0 20 87 jr nz,ray12hit2
427 12C2 2C inc l
427 12C3 24 inc h
427 12C4 B6 or (hl)
427 12C5 20 89 jr nz,ray12hit3
427 12C7 2C inc l
427 12C8 B6 or (hl)
427 12C9 20 8C jr nz,ray12hit4
427 12CB 2C inc l
427 12CC 24 inc h
427 12CD B6 or (hl)
427 12CE 20 8E jr nz,ray12hit5
427 12D0 2C inc l
427 12D1 24 inc h
427 12D2 B6 or (hl)
427 12D3 20 90 jr nz,ray12hit6
427 12D5 2C inc l
427 12D6 B6 or (hl)
427 12D7 20 93 jr nz,ray12hit7
427 12D9 2C inc l
427 12DA 24 inc h
427 12DB B6 or (hl)
427 12DC 20 95 jr nz,ray12hit8
427 12DE 2C inc l
427 12DF 24 inc h
427 12E0 B6 or (hl)
427 12E1 20 97 jr nz,ray12hit9
427 12E3 2C inc l
427 12E4 B6 or (hl)
427 12E5 20 9A jr nz,ray12hit10
427 12E7 2C inc l
427 12E8 24 inc h
427 12E9 B6 or (hl)
427 12EA 20 9C jr nz,ray12hit11
427 12EC 2C inc l
427 12ED 24 inc h
427 12EE B6 or (hl)
427 12EF 20 9E jr nz,ray12hit12
427 12F1 2C inc l
427 12F2 B6 or (hl)
427 12F3 20 A1 jr nz,ray12hit13
427 12F5 2C inc l
427 12F6 24 inc h
427 12F7 B6 or (hl)
427 12F8 20 A3 jr nz,ray12hit14
427 12FA 2C inc l
427 12FB 24 inc h
427 12FC B6 or (hl)
427 12FD 20 A5 jr nz,ray12hit15
427 12FF 2C inc l
427 1300 B6 or (hl)
427 1301 20 A8 jr nz,ray12hit16
427 1303 2C inc l
427 1304 24 inc h
427 1305 B6 or (hl)
427 1306 20 54 jr nz,ray12hit17
427 1308 2C inc l
427 1309 24 inc h
427 130A B6 or (hl)
427 130B 20 56 jr nz,ray12hit18
427 130D 2C inc l
427 130E B6 or (hl)
427 130F 20 59 jr nz,ray12hit19
427 1311 2C inc l
427 1312 24 inc h
427 1313 B6 or (hl)
427 1314 20 5B jr nz,ray12hit20
427 1316 2C inc l
427 1317 24 inc h
427 1318 B6 or (hl)
427 1319 20 5D jr nz,ray12hit21
427 131B 2C inc l
427 131C B6 or (hl)
427 131D 20 60 jr nz,ray12hit22
427 131F 2C inc l
427 1320 24 inc h
427 1321 B6 or (hl)
427 1322 20 62 jr nz,ray12hit23
427 1324 2C inc l
427 1325 24 inc h
427 1326 B6 or (hl)
427 1327 20 64 jr nz,ray12hit24
427 1329 2C inc l
427 132A B6 or (hl)
427 132B 20 67 jr nz,ray12hit25
427 132D 2C inc l
427 132E 24 inc h
427 132F B6 or (hl)
427 1330 20 69 jr nz,ray12hit26
427 1332 2C inc l
427 1333 24 inc h
427 1334 B6 or (hl)
427 1335 20 6B jr nz,ray12hit27
427 1337 2C inc l
427 1338 B6 or (hl)
427 1339 20 6E jr nz,ray12hit28
427 133B 2C inc l
427 133C 24 inc h
427 133D B6 or (hl)
427 133E 20 70 jr nz,ray12hit29
427 1340 2C inc l
427 1341 24 inc h
427 1342 B6 or (hl)
427 1343 20 72 jr nz,ray12hit30
427 1345 2C inc l
427 1346 B6 or (hl)
427 1347 20 75 jr nz,ray12hit31
427 1349 2C inc l
427 134A 24 inc h
427 134B B6 or (hl)
427 134C 20 77 jr nz,ray12hit32
427 134E 2C inc l
427 134F 24 inc h
427 1350 B6 or (hl)
427 1351 20 79 jr nz,ray12hit33
427 1353 2C inc l
427 1354 B6 or (hl)
427 1355 ray12hit34
427 1355 ; скорей всего луч никуда не попал
427 1355 67 ld h,a
427 1356 2E 28 ld l,40
427 1358 E5 push hl
427 1359 C3 43 14 jp castray13
427 135C ray12hit17
427 135C 67 ld h,a
427 135D 2E 14 ld l,20
427 135F E5 push hl
427 1360 C3 43 14 jp castray13
427 1363 ray12hit18
427 1363 67 ld h,a
427 1364 2E 15 ld l,21
427 1366 E5 push hl
427 1367 C3 43 14 jp castray13
427 136A ray12hit19
427 136A 67 ld h,a
427 136B 2E 16 ld l,22
427 136D E5 push hl
427 136E C3 43 14 jp castray13
427 1371 ray12hit20
427 1371 67 ld h,a
427 1372 2E 17 ld l,23
427 1374 E5 push hl
427 1375 C3 43 14 jp castray13
427 1378 ray12hit21
427 1378 67 ld h,a
427 1379 2E 19 ld l,25
427 137B E5 push hl
427 137C C3 43 14 jp castray13
427 137F ray12hit22
427 137F 67 ld h,a
427 1380 2E 19 ld l,25
427 1382 E5 push hl
427 1383 C3 43 14 jp castray13
427 1386 ray12hit23
427 1386 67 ld h,a
427 1387 2E 1B ld l,27
427 1389 E5 push hl
427 138A C3 43 14 jp castray13
427 138D ray12hit24
427 138D 67 ld h,a
427 138E 2E 1C ld l,28
427 1390 E5 push hl
427 1391 C3 43 14 jp castray13
427 1394 ray12hit25
427 1394 67 ld h,a
427 1395 2E 1D ld l,29
427 1397 E5 push hl
427 1398 C3 43 14 jp castray13
427 139B ray12hit26
427 139B 67 ld h,a
427 139C 2E 1E ld l,30
427 139E E5 push hl
427 139F C3 43 14 jp castray13
427 13A2 ray12hit27
427 13A2 67 ld h,a
427 13A3 2E 20 ld l,32
427 13A5 E5 push hl
427 13A6 C3 43 14 jp castray13
427 13A9 ray12hit28
427 13A9 67 ld h,a
427 13AA 2E 21 ld l,33
427 13AC E5 push hl
427 13AD C3 43 14 jp castray13
427 13B0 ray12hit29
427 13B0 67 ld h,a
427 13B1 2E 22 ld l,34
427 13B3 E5 push hl
427 13B4 C3 43 14 jp castray13
427 13B7 ray12hit30
427 13B7 67 ld h,a
427 13B8 2E 23 ld l,35
427 13BA E5 push hl
427 13BB C3 43 14 jp castray13
427 13BE ray12hit31
427 13BE 67 ld h,a
427 13BF 2E 24 ld l,36
427 13C1 E5 push hl
427 13C2 C3 43 14 jp castray13
427 13C5 ray12hit32
427 13C5 67 ld h,a
427 13C6 2E 26 ld l,38
427 13C8 E5 push hl
427 13C9 C3 43 14 jp castray13
427 13CC ray12hit33
427 13CC 67 ld h,a
427 13CD 2E 27 ld l,39
427 13CF E5 push hl
427 13D0 C3 43 14 jp castray13
427 13D3 ;================================================= =====
427 13D3 RAY_13_ROUTINE
427 13D3 ;================================================= =====
427 13D3 ray13hit1
427 13D3 67 ld h,a
427 13D4 2E 01 ld l,1
427 13D6 E5 push hl
427 13D7 C3 D8 15 jp castray14
427 13DA ray13hit2
427 13DA 67 ld h,a
427 13DB 2E 02 ld l,2
427 13DD E5 push hl
427 13DE C3 D8 15 jp castray14
427 13E1 ray13hit3
427 13E1 67 ld h,a
427 13E2 2E 04 ld l,4
427 13E4 E5 push hl
427 13E5 C3 D8 15 jp castray14
427 13E8 ray13hit4
427 13E8 67 ld h,a
427 13E9 2E 05 ld l,5
427 13EB E5 push hl
427 13EC C3 D8 15 jp castray14
427 13EF ray13hit5
427 13EF 67 ld h,a
427 13F0 2E 06 ld l,6
427 13F2 E5 push hl
427 13F3 C3 D8 15 jp castray14
427 13F6 ray13hit6
427 13F6 67 ld h,a
427 13F7 2E 07 ld l,7
427 13F9 E5 push hl
427 13FA C3 D8 15 jp castray14
427 13FD ray13hit7
427 13FD 67 ld h,a
427 13FE 2E 09 ld l,9
427 1400 E5 push hl
427 1401 C3 D8 15 jp castray14
427 1404 ray13hit8
427 1404 67 ld h,a
427 1405 2E 0A ld l,10
427 1407 E5 push hl
427 1408 C3 D8 15 jp castray14
427 140B ray13hit9
427 140B 67 ld h,a
427 140C 2E 0B ld l,11
427 140E E5 push hl
427 140F C3 D8 15 jp castray14
427 1412 ray13hit10
427 1412 67 ld h,a
427 1413 2E 0C ld l,12
427 1415 E5 push hl
427 1416 C3 D8 15 jp castray14
427 1419 ray13hit11
427 1419 67 ld h,a
427 141A 2E 0E ld l,14
427 141C E5 push hl
427 141D C3 D8 15 jp castray14
427 1420 ray13hit12
427 1420 67 ld h,a
427 1421 2E 0F ld l,15
427 1423 E5 push hl
427 1424 C3 D8 15 jp castray14
427 1427 ray13hit13
427 1427 67 ld h,a
427 1428 2E 10 ld l,16
427 142A E5 push hl
427 142B C3 D8 15 jp castray14
427 142E ray13hit14
427 142E 67 ld h,a
427 142F 2E 11 ld l,17
427 1431 E5 push hl
427 1432 C3 D8 15 jp castray14
427 1435 ray13hit15
427 1435 67 ld h,a
427 1436 2E 13 ld l,19
427 1438 E5 push hl
427 1439 C3 D8 15 jp castray14
427 143C ray13hit16
427 143C 67 ld h,a
427 143D 2E 14 ld l,20
427 143F E5 push hl
427 1440 C3 D8 15 jp castray14
427 1443 ;================================================= =====
427 1443 castray13
427 1443 0D dec c
427 1444 CA 10 C5 jp z,raycast_end
427 1447 AF xor a
427 1448 62 ld h,d
427 1449 6B ld l,e
427 144A 2C inc l
427 144B 24 inc h
427 144C B6 or (hl)
427 144D 20 84 jr nz,ray13hit1
427 144F 2C inc l
427 1450 24 inc h
427 1451 B6 or (hl)
427 1452 20 86 jr nz,ray13hit2
427 1454 2C inc l
427 1455 24 inc h
427 1456 B6 or (hl)
427 1457 20 88 jr nz,ray13hit3
427 1459 2C inc l
427 145A B6 or (hl)
427 145B 20 8B jr nz,ray13hit4
427 145D 2C inc l
427 145E 24 inc h
427 145F B6 or (hl)
427 1460 20 8D jr nz,ray13hit5
427 1462 2C inc l
427 1463 24 inc h
427 1464 B6 or (hl)
427 1465 20 8F jr nz,ray13hit6
427 1467 2C inc l
427 1468 24 inc h
427 1469 B6 or (hl)
427 146A 20 91 jr nz,ray13hit7
427 146C 2C inc l
427 146D B6 or (hl)
427 146E 20 94 jr nz,ray13hit8
427 1470 2C inc l
427 1471 24 inc h
427 1472 B6 or (hl)
427 1473 20 96 jr nz,ray13hit9
427 1475 2C inc l
427 1476 24 inc h
427 1477 B6 or (hl)
427 1478 20 98 jr nz,ray13hit10
427 147A 2C inc l
427 147B 24 inc h
427 147C B6 or (hl)
427 147D 20 9A jr nz,ray13hit11
427 147F 2C inc l
427 1480 B6 or (hl)
427 1481 20 9D jr nz,ray13hit12
427 1483 2C inc l
427 1484 24 inc h
427 1485 B6 or (hl)
427 1486 20 9F jr nz,ray13hit13
427 1488 2C inc l
427 1489 24 inc h
427 148A B6 or (hl)
427 148B 20 A1 jr nz,ray13hit14
427 148D 2C inc l
427 148E 24 inc h
427 148F B6 or (hl)
427 1490 20 A3 jr nz,ray13hit15
427 1492 2C inc l
427 1493 B6 or (hl)
427 1494 20 A6 jr nz,ray13hit16
427 1496 2C inc l
427 1497 24 inc h
427 1498 B6 or (hl)
427 1499 20 56 jr nz,ray13hit17
427 149B 2C inc l
427 149C 24 inc h
427 149D B6 or (hl)
427 149E 20 58 jr nz,ray13hit18
427 14A0 2C inc l
427 14A1 24 inc h
427 14A2 B6 or (hl)
427 14A3 20 5A jr nz,ray13hit19
427 14A5 2C inc l
427 14A6 B6 or (hl)
427 14A7 20 5D jr nz,ray13hit20
427 14A9 2C inc l
427 14AA 24 inc h
427 14AB B6 or (hl)
427 14AC 20 5F jr nz,ray13hit21
427 14AE 2C inc l
427 14AF 24 inc h
427 14B0 B6 or (hl)
427 14B1 20 61 jr nz,ray13hit22
427 14B3 2C inc l
427 14B4 24 inc h
427 14B5 B6 or (hl)
427 14B6 20 63 jr nz,ray13hit23
427 14B8 2C inc l
427 14B9 B6 or (hl)
427 14BA 20 66 jr nz,ray13hit24
427 14BC 2C inc l
427 14BD 24 inc h
427 14BE B6 or (hl)
427 14BF 20 68 jr nz,ray13hit25
427 14C1 2C inc l
427 14C2 24 inc h
427 14C3 B6 or (hl)
427 14C4 20 6A jr nz,ray13hit26
427 14C6 2C inc l
427 14C7 24 inc h
427 14C8 B6 or (hl)
427 14C9 20 6C jr nz,ray13hit27
427 14CB 2C inc l
427 14CC B6 or (hl)
427 14CD 20 6F jr nz,ray13hit28
427 14CF 2C inc l
427 14D0 24 inc h
427 14D1 B6 or (hl)
427 14D2 20 71 jr nz,ray13hit29
427 14D4 2C inc l
427 14D5 24 inc h
427 14D6 B6 or (hl)
427 14D7 20 73 jr nz,ray13hit30
427 14D9 2C inc l
427 14DA B6 or (hl)
427 14DB 20 76 jr nz,ray13hit31
427 14DD 2C inc l
427 14DE 24 inc h
427 14DF B6 or (hl)
427 14E0 20 78 jr nz,ray13hit32
427 14E2 2C inc l
427 14E3 24 inc h
427 14E4 B6 or (hl)
427 14E5 20 7A jr nz,ray13hit33
427 14E7 2C inc l
427 14E8 24 inc h
427 14E9 B6 or (hl)
427 14EA ray13hit34
427 14EA ; скорей всего луч никуда не попал
427 14EA 67 ld h,a
427 14EB 2E 2A ld l,42
427 14ED E5 push hl
427 14EE C3 D8 15 jp castray14
427 14F1 ray13hit17
427 14F1 67 ld h,a
427 14F2 2E 15 ld l,21
427 14F4 E5 push hl
427 14F5 C3 D8 15 jp castray14
427 14F8 ray13hit18
427 14F8 67 ld h,a
427 14F9 2E 16 ld l,22
427 14FB E5 push hl
427 14FC C3 D8 15 jp castray14
427 14FF ray13hit19
427 14FF 67 ld h,a
427 1500 2E 18 ld l,24
427 1502 E5 push hl
427 1503 C3 D8 15 jp castray14
427 1506 ray13hit20
427 1506 67 ld h,a
427 1507 2E 19 ld l,25
427 1509 E5 push hl
427 150A C3 D8 15 jp castray14
427 150D ray13hit21
427 150D 67 ld h,a
427 150E 2E 1A ld l,26
427 1510 E5 push hl
427 1511 C3 D8 15 jp castray14
427 1514 ray13hit22
427 1514 67 ld h,a
427 1515 2E 1B ld l,27
427 1517 E5 push hl
427 1518 C3 D8 15 jp castray14
427 151B ray13hit23
427 151B 67 ld h,a
427 151C 2E 1D ld l,29
427 151E E5 push hl
427 151F C3 D8 15 jp castray14
427 1522 ray13hit24
427 1522 67 ld h,a
427 1523 2E 1E ld l,30
427 1525 E5 push hl
427 1526 C3 D8 15 jp castray14
427 1529 ray13hit25
427 1529 67 ld h,a
427 152A 2E 1F ld l,31
427 152C E5 push hl
427 152D C3 D8 15 jp castray14
427 1530 ray13hit26
427 1530 67 ld h,a
427 1531 2E 20 ld l,32
427 1533 E5 push hl
427 1534 C3 D8 15 jp castray14
427 1537 ray13hit27
427 1537 67 ld h,a
427 1538 2E 22 ld l,34
427 153A E5 push hl
427 153B C3 D8 15 jp castray14
427 153E ray13hit28
427 153E 67 ld h,a
427 153F 2E 23 ld l,35
427 1541 E5 push hl
427 1542 C3 D8 15 jp castray14
427 1545 ray13hit29
427 1545 67 ld h,a
427 1546 2E 24 ld l,36
427 1548 E5 push hl
427 1549 C3 D8 15 jp castray14
427 154C ray13hit30
427 154C 67 ld h,a
427 154D 2E 25 ld l,37
427 154F E5 push hl
427 1550 C3 D8 15 jp castray14
427 1553 ray13hit31
427 1553 67 ld h,a
427 1554 2E 26 ld l,38
427 1556 E5 push hl
427 1557 C3 D8 15 jp castray14
427 155A ray13hit32
427 155A 67 ld h,a
427 155B 2E 28 ld l,40
427 155D E5 push hl
427 155E C3 D8 15 jp castray14
427 1561 ray13hit33
427 1561 67 ld h,a
427 1562 2E 29 ld l,41
427 1564 E5 push hl
427 1565 C3 D8 15 jp castray14
427 1568 ;================================================= =====
427 1568 RAY_14_ROUTINE
427 1568 ;================================================= =====
427 1568 ray14hit1
427 1568 67 ld h,a
427 1569 2E 01 ld l,1
427 156B E5 push hl
427 156C C3 6F 17 jp castray15
427 156F ray14hit2
427 156F 67 ld h,a
427 1570 2E 02 ld l,2
427 1572 E5 push hl
427 1573 C3 6F 17 jp castray15
427 1576 ray14hit3
427 1576 67 ld h,a
427 1577 2E 04 ld l,4
427 1579 E5 push hl
427 157A C3 6F 17 jp castray15
427 157D ray14hit4
427 157D 67 ld h,a
427 157E 2E 05 ld l,5
427 1580 E5 push hl
427 1581 C3 6F 17 jp castray15
427 1584 ray14hit5
427 1584 67 ld h,a
427 1585 2E 07 ld l,7
427 1587 E5 push hl
427 1588 C3 6F 17 jp castray15
427 158B ray14hit6
427 158B 67 ld h,a
427 158C 2E 07 ld l,7
427 158E E5 push hl
427 158F C3 6F 17 jp castray15
427 1592 ray14hit7
427 1592 67 ld h,a
427 1593 2E 09 ld l,9
427 1595 E5 push hl
427 1596 C3 6F 17 jp castray15
427 1599 ray14hit8
427 1599 67 ld h,a
427 159A 2E 0A ld l,10
427 159C E5 push hl
427 159D C3 6F 17 jp castray15
427 15A0 ray14hit9
427 15A0 67 ld h,a
427 15A1 2E 0C ld l,12
427 15A3 E5 push hl
427 15A4 C3 6F 17 jp castray15
427 15A7 ray14hit10
427 15A7 67 ld h,a
427 15A8 2E 0D ld l,13
427 15AA E5 push hl
427 15AB C3 6F 17 jp castray15
427 15AE ray14hit11
427 15AE 67 ld h,a
427 15AF 2E 0E ld l,14
427 15B1 E5 push hl
427 15B2 C3 6F 17 jp castray15
427 15B5 ray14hit12
427 15B5 67 ld h,a
427 15B6 2E 0F ld l,15
427 15B8 E5 push hl
427 15B9 C3 6F 17 jp castray15
427 15BC ray14hit13
427 15BC 67 ld h,a
427 15BD 2E 11 ld l,17
427 15BF E5 push hl
427 15C0 C3 6F 17 jp castray15
427 15C3 ray14hit14
427 15C3 67 ld h,a
427 15C4 2E 12 ld l,18
427 15C6 E5 push hl
427 15C7 C3 6F 17 jp castray15
427 15CA ray14hit15
427 15CA 67 ld h,a
427 15CB 2E 13 ld l,19
427 15CD E5 push hl
427 15CE C3 6F 17 jp castray15
427 15D1 ray14hit16
427 15D1 67 ld h,a
427 15D2 2E 15 ld l,21
427 15D4 E5 push hl
427 15D5 C3 6F 17 jp castray15
427 15D8 ;================================================= =====
427 15D8 castray14
427 15D8 0D dec c
427 15D9 CA 10 C5 jp z,raycast_end
427 15DC AF xor a
427 15DD 62 ld h,d
427 15DE 6B ld l,e
427 15DF 2C inc l
427 15E0 24 inc h
427 15E1 B6 or (hl)
427 15E2 20 84 jr nz,ray14hit1
427 15E4 2C inc l
427 15E5 24 inc h
427 15E6 B6 or (hl)
427 15E7 20 86 jr nz,ray14hit2
427 15E9 2C inc l
427 15EA 24 inc h
427 15EB B6 or (hl)
427 15EC 20 88 jr nz,ray14hit3
427 15EE 2C inc l
427 15EF 24 inc h
427 15F0 B6 or (hl)
427 15F1 20 8A jr nz,ray14hit4
427 15F3 2C inc l
427 15F4 24 inc h
427 15F5 B6 or (hl)
427 15F6 20 8C jr nz,ray14hit5
427 15F8 2C inc l
427 15F9 B6 or (hl)
427 15FA 20 8F jr nz,ray14hit6
427 15FC 2C inc l
427 15FD 24 inc h
427 15FE B6 or (hl)
427 15FF 20 91 jr nz,ray14hit7
427 1601 2C inc l
427 1602 24 inc h
427 1603 B6 or (hl)
427 1604 20 93 jr nz,ray14hit8
427 1606 2C inc l
427 1607 24 inc h
427 1608 B6 or (hl)
427 1609 20 95 jr nz,ray14hit9
427 160B 2C inc l
427 160C 24 inc h
427 160D B6 or (hl)
427 160E 20 97 jr nz,ray14hit10
427 1610 2C inc l
427 1611 24 inc h
427 1612 B6 or (hl)
427 1613 20 99 jr nz,ray14hit11
427 1615 2C inc l
427 1616 B6 or (hl)
427 1617 20 9C jr nz,ray14hit12
427 1619 2C inc l
427 161A 24 inc h
427 161B B6 or (hl)
427 161C 20 9E jr nz,ray14hit13
427 161E 2C inc l
427 161F 24 inc h
427 1620 B6 or (hl)
427 1621 20 A0 jr nz,ray14hit14
427 1623 2C inc l
427 1624 24 inc h
427 1625 B6 or (hl)
427 1626 20 A2 jr nz,ray14hit15
427 1628 2C inc l
427 1629 24 inc h
427 162A B6 or (hl)
427 162B 20 A4 jr nz,ray14hit16
427 162D 2C inc l
427 162E B6 or (hl)
427 162F 20 57 jr nz,ray14hit17
427 1631 2C inc l
427 1632 24 inc h
427 1633 B6 or (hl)
427 1634 20 59 jr nz,ray14hit18
427 1636 2C inc l
427 1637 24 inc h
427 1638 B6 or (hl)
427 1639 20 5B jr nz,ray14hit19
427 163B 2C inc l
427 163C 24 inc h
427 163D B6 or (hl)
427 163E 20 5D jr nz,ray14hit20
427 1640 2C inc l
427 1641 24 inc h
427 1642 B6 or (hl)
427 1643 20 5F jr nz,ray14hit21
427 1645 2C inc l
427 1646 24 inc h
427 1647 B6 or (hl)
427 1648 20 61 jr nz,ray14hit22
427 164A 2C inc l
427 164B B6 or (hl)
427 164C 20 64 jr nz,ray14hit23
427 164E 2C inc l
427 164F 24 inc h
427 1650 B6 or (hl)
427 1651 20 66 jr nz,ray14hit24
427 1653 2C inc l
427 1654 24 inc h
427 1655 B6 or (hl)
427 1656 20 68 jr nz,ray14hit25
427 1658 2C inc l
427 1659 24 inc h
427 165A B6 or (hl)
427 165B 20 6A jr nz,ray14hit26
427 165D 2C inc l
427 165E 24 inc h
427 165F B6 or (hl)
427 1660 20 6C jr nz,ray14hit27
427 1662 2C inc l
427 1663 B6 or (hl)
427 1664 20 6F jr nz,ray14hit28
427 1666 2C inc l
427 1667 24 inc h
427 1668 B6 or (hl)
427 1669 20 71 jr nz,ray14hit29
427 166B 2C inc l
427 166C 24 inc h
427 166D B6 or (hl)
427 166E 20 73 jr nz,ray14hit30
427 1670 2C inc l
427 1671 24 inc h
427 1672 B6 or (hl)
427 1673 20 75 jr nz,ray14hit31
427 1675 2C inc l
427 1676 24 inc h
427 1677 B6 or (hl)
427 1678 20 77 jr nz,ray14hit32
427 167A 2C inc l
427 167B 24 inc h
427 167C B6 or (hl)
427 167D 20 79 jr nz,ray14hit33
427 167F 2C inc l
427 1680 B6 or (hl)
427 1681 ray14hit34
427 1681 ; скорей всего луч никуда не попал
427 1681 67 ld h,a
427 1682 2E 2C ld l,44
427 1684 E5 push hl
427 1685 C3 6F 17 jp castray15
427 1688 ray14hit17
427 1688 67 ld h,a
427 1689 2E 16 ld l,22
427 168B E5 push hl
427 168C C3 6F 17 jp castray15
427 168F ray14hit18
427 168F 67 ld h,a
427 1690 2E 17 ld l,23
427 1692 E5 push hl
427 1693 C3 6F 17 jp castray15
427 1696 ray14hit19
427 1696 67 ld h,a
427 1697 2E 18 ld l,24
427 1699 E5 push hl
427 169A C3 6F 17 jp castray15
427 169D ray14hit20
427 169D 67 ld h,a
427 169E 2E 1A ld l,26
427 16A0 E5 push hl
427 16A1 C3 6F 17 jp castray15
427 16A4 ray14hit21
427 16A4 67 ld h,a
427 16A5 2E 1B ld l,27
427 16A7 E5 push hl
427 16A8 C3 6F 17 jp castray15
427 16AB ray14hit22
427 16AB 67 ld h,a
427 16AC 2E 1D ld l,29
427 16AE E5 push hl
427 16AF C3 6F 17 jp castray15
427 16B2 ray14hit23
427 16B2 67 ld h,a
427 16B3 2E 1D ld l,29
427 16B5 E5 push hl
427 16B6 C3 6F 17 jp castray15
427 16B9 ray14hit24
427 16B9 67 ld h,a
427 16BA 2E 1F ld l,31
427 16BC E5 push hl
427 16BD C3 6F 17 jp castray15
427 16C0 ray14hit25
427 16C0 67 ld h,a
427 16C1 2E 20 ld l,32
427 16C3 E5 push hl
427 16C4 C3 6F 17 jp castray15
427 16C7 ray14hit26
427 16C7 67 ld h,a
427 16C8 2E 22 ld l,34
427 16CA E5 push hl
427 16CB C3 6F 17 jp castray15
427 16CE ray14hit27
427 16CE 67 ld h,a
427 16CF 2E 23 ld l,35
427 16D1 E5 push hl
427 16D2 C3 6F 17 jp castray15
427 16D5 ray14hit28
427 16D5 67 ld h,a
427 16D6 2E 24 ld l,36
427 16D8 E5 push hl
427 16D9 C3 6F 17 jp castray15
427 16DC ray14hit29
427 16DC 67 ld h,a
427 16DD 2E 25 ld l,37
427 16DF E5 push hl
427 16E0 C3 6F 17 jp castray15
427 16E3 ray14hit30
427 16E3 67 ld h,a
427 16E4 2E 27 ld l,39
427 16E6 E5 push hl
427 16E7 C3 6F 17 jp castray15
427 16EA ray14hit31
427 16EA 67 ld h,a
427 16EB 2E 28 ld l,40
427 16ED E5 push hl
427 16EE C3 6F 17 jp castray15
427 16F1 ray14hit32
427 16F1 67 ld h,a
427 16F2 2E 29 ld l,41
427 16F4 E5 push hl
427 16F5 C3 6F 17 jp castray15
427 16F8 ray14hit33
427 16F8 67 ld h,a
427 16F9 2E 2B ld l,43
427 16FB E5 push hl
427 16FC C3 6F 17 jp castray15
- - - Добавлено - - -
3Ы: Кто напишет быстрее? :v2_dizzy_vodka2:
Это чуть ли не копипаста с IMak`ковского doom`а под Спринтера. Только там кол-во шагов меньше из-за чего объекты пропадают .
Кто напишет быстрее?
я бы заменил все inc l:inc h на inc hl. 6 тактов против 8 как бы и по байтам выигрыш (1 против 2).
Bedazzle
31.05.2019, 08:46
я бы заменил все inc l:inc h на inc hl. 6 тактов против 8 как бы и по байтам выигрыш (1 против 2).
inc l: inc h ; hl = hl + 257
против
inc hl ; hl = hl + 256
они разве то же самое делают?
inc l: inc h ; hl = hl + 257
против
inc hl ; hl = hl + 256
inc hl ; hl = hl + 1
я наверное что-то подзабыл или не о том думаю. если речь о банальном инкременте адреса, то inc hl будет выгоднее, если там разделение какое-то табличное и нужно учитывать оба регистра, тогда лучше не менять, конечно.
NEO SPECTRUMAN
31.05.2019, 13:01
я бы заменил все inc l:inc h на inc hl.
И что єто даст?
ничего
inc h инкримент позиции по вертикали
inc l инкримент позиции по горизонтали
чередованием их и происходит пуляние луча под разными углами
так же для других углов там dec h и dec l
inc hl даст только инкримент по горизонтали и все
- - - Добавлено - - -
если там разделение какое-то табличное
ну да они там не просто так
- - - Добавлено - - -
1110 5DF7 castray1
1110 5DF7 62 ld h,d
1110 5DF8 6B ld l,e
1110 5DF9 AF xor a
1110 5DFA ED 4F ld r,a
1110 5DFC 2C inc l
1110 5DFD 24 inc h
1110 5DFE B6 or (hl)
1110 5DFF 20 63 jr nz,ray1hit
1110 5E01 2C inc l
1110 5E02 B6 or (hl)
1110 5E03 20 5F jr nz,ray1hit
1110 5E05 2C inc l
1110 5E06 B6 or (hl)
1110 5E07 20 5B jr nz,ray1hit
1110 5E09 2C inc l
1110 5E0A B6 or (hl)
1110 5E0B 20 57 jr nz,ray1hit
1110 5E0D 2C inc l
1110 5E0E B6 or (hl)
1110 5E0F 20 53 jr nz,ray1hit
1110 5E11 2C inc l
1110 5E12 B6 or (hl)
1110 5E13 20 4F jr nz,ray1hit
1110 5E15 2C inc l
1110 5E16 B6 or (hl)
1110 5E17 20 4B jr nz,ray1hit
1110 5E19 2C inc l
1110 5E1A B6 or (hl)
1110 5E1B 20 47 jr nz,ray1hit
1110 5E1D 2C inc l
1110 5E1E B6 or (hl)
1110 5E1F 20 43 jr nz,ray1hit
1110 5E21 2C inc l
1110 7D3F castray56
1110 7D3F 62 ld h,d
1110 7D40 6B ld l,e
1110 7D41 AF xor a
1110 7D42 ED 4F ld r,a
1110 7D44 2D dec l
1110 7D45 24 inc h
1110 7D46 B6 or (hl)
1110 7D47 20 6C jr nz,ray56hit
1110 7D49 2D dec l
1110 7D4A B6 or (hl)
1110 7D4B 20 68 jr nz,ray56hit
1110 7D4D 2D dec l
1110 7D4E 24 inc h
1110 7D4F B6 or (hl)
1110 7D50 20 63 jr nz,ray56hit
1110 7D52 2D dec l
1110 7D53 B6 or (hl)
1110 7D54 20 5F jr nz,ray56hit
1110 7D56 2D dec l
1110 7D57 24 inc h
1110 7D58 B6 or (hl)
1110 7D59 20 5A jr nz,ray56hit
1110 7D5B 2D dec l
1110 7D5C B6 or (hl)
1110 97FC castray104
1110 97FC 62 ld h,d
1110 97FD 6B ld l,e
1110 97FE AF xor a
1110 97FF ED 4F ld r,a
1110 9801 25 dec h
1110 9802 B6 or (hl)
1110 9803 20 6D jr nz,ray104hit
1110 9805 2C inc l
1110 9806 25 dec h
1110 9807 B6 or (hl)
1110 9808 20 68 jr nz,ray104hit
1110 980A 25 dec h
1110 980B B6 or (hl)
1110 980C 20 64 jr nz,ray104hit
1110 980E 2C inc l
1110 980F 25 dec h
1110 9810 B6 or (hl)
1110 9811 20 5F jr nz,ray104hit
1110 9813 25 dec h
1110 9814 B6 or (hl)
1110 9815 20 5B jr nz,ray104hit
1110 9817 25 dec h
1110 9818 B6 or (hl)
1110 9819 20 57 jr nz,ray104hit
1110 981B 2C inc l
1110 981C 25 dec h
1110 981D B6 or (hl)
1110 981E 20 52 jr nz,ray104hit
1110 9820 25 dec h
1110 9821 B6 or (hl)
1110 9822 20 4E jr nz,ray104hit
1110 9824 2C inc l
1110 9825 25 dec h
1110 9826 B6 or (hl)
1110 9827 20 49 jr nz,ray104hit
1110 9829 25 dec h
1110 982A B6 or (hl)
1110 982B 20 45 jr nz,ray104hit
1110 982D 25 dec h
1110 982E B6 or (hl)
1110 982F 20 41 jr nz,ray104hit
1110 9831 2C inc l
1110 9832 25 dec h
- - - Добавлено - - -
Это чуть ли не копипаста с IMak`ковского doom`а под Спринтера. Только там кол-во шагов меньше из-за чего объекты пропадают .
там же вроде текстуры на стенах
а я себе такого позволит не могу
у меня только красивые стобцы с отражениями и полупрозрачностями
из которых толком ничего нельзя построить тк сильно крупные
I surely wouldn't want to write such code manually.
I think I will try to show some sjasmplus MACRO version of such code generator in couple of days, if I will be in mood for it (should be simple to do).
3Ы: Кто напишет быстрее?
If you mean like performance-faster, you can for example squeeze few more percent boost % by sharing the early ray paths between, for your short example the ray13 and ray14 share first three tiles of map, so the ray13hit1-3 code paths can be merged with ray14hit1-3 (pushing two values on stack) and jump to ray15.
But this will make the code generator even more complex (to the extend where I would NOT want to write it in sjasmplus .. it may be still possible, but doesn't sound as simple as your current example... so I would probably use rather C++ for this one, as I feel most familiar with it).
And for rays very close to (+0,+-1) vector maybe there's some trick how to use cpi/cpd/cpir/cpdr, but I'm afraid there's maybe just two rays going precisely in +-1 delta which would MAYBE benefit of such change.
And finally, for particular size of map/screen/ray-count it may be faster to inverse the whole thing, going through MxN map and for every non-zero tile to update minimal distance for all rays going through the tile (of course everything lookup-table-based, i.e. again heavy memory usage and needs code-generator too), after the MxN map scan you would end with ray_array containing all the minimal distances for all rays. I didn't do the math myself, if this approach is faster for some sizes which make actual visual sense, but I'm pretty sure it's faster for some combinations (although maybe the size combinations which make visual sense are always better with classic ray-cast like you have, so this is just bare "idea", nothing more).
And of course as long as we are talking about Wolf3D, the DOOM BSP was far superior to it (in performance). Although the Z80 doesn't have MUL and DIV, and the amount of rays is probably minimal, if you have at least 100+ horizontal resolution (ray count), I guess even Z80 would do 2D BSP faster than raycasting.
Raycasting can produce interesting results if you have hi-res map (i.e. voxel-like), but in case of Wolf3D like maps (big squares only), the DOOM line-segment approach allows not only for better performance, but also for more complex maps. But it's lot more work the DOOM thing, and again Speccy introduces few more constraints (memory) which would make it difficult to exploit... I personally prefer to leave these things to 32+ bit CPUs, although I can appreciate the achievement of making the Z80 variants of them, but I don't find them truly practical (like I would WANT to play doom-like game on ZX in 4-10 FPS ... nope).
NEO SPECTRUMAN
31.05.2019, 13:53
If you mean like performance-faster, you can for example squeeze few more percent boost % by sharing the early ray paths between, for your short example the ray13 and ray14 share first three tiles of map, so the ray13hit1-3 code paths can be merged with ray14hit1-3 (pushing two values on stack) and jump to ray15.
конечно кеширование уже проверенных клеток могло бы и правда ускорить процесс
но как его организовать?
старт сканирования может начатся с любого угла
то есть понадобится еще в 2 3 раза больше памяти под дополнительный код
да и написать генератор процедуры будет гораздо сложнее
так тоже сожрет много памяти
ray3hit2
ld h,a
ld l,2
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
jp castray6
чуть экономичней
ray3hit2
ld h,a
ld l,2
push hl
call save3
jp castray6
save3
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
ret
- - - Добавлено - - -
ray14hit1-3
наверно ray15-16hit3 :)
About start at any ray... you can still have ray14hit1-3 as it was (or merged with r15-16), but then the problem is when for example ray13 ends the range, it will push extra 3 values... although that doesn't sound *that* bad, if you are ready for such overflow and can recover from it. And you need to put "end" to every ray14-ray16 entry as you don't know where it will end. Oh wait, you are doing "dec c" as column counter? You can maybe get some boost from this to, keeping all rays calling next-other, and just modify/restore the start of ending-ray code with `jp raycast_end` and not doing `dec c + jp z,` test for every ray.
The shared tiles on average will very likely boost the overall performance even if they put 2-4 values extra on stack - but that's a boost in case when you are already very near the tile, which are generally very fast anyway. :D ... so again, while technically it is faster than your original example, it's more like joke-teasing you a bit, not really practical or bringing some major boost. The self-modify terminating jump may be actual real boost, even making C free for different use. (but then the tile-sharing hit code will definitely put more values onto stack, as it doesn't count columns then).
If for example every raycast code starts `ld hl,de : xor a`, you can put the "raycast_end" at 0xAF6B and just alternate the `ld h,d` to `jp $nnnn` and back... to create "render terminators".
- - - Updated - - -
чуть экономичней
you can't `CALL + RET` while doing `PUSH hl` filler ;) the triple code must be there.. although if the value pushed is the same for all shared-rays, the hit3 can contain full fill, and hit1/2 will use it as "tail" optimization jumping into it after setting HL to desired value.
NEO SPECTRUMAN
31.05.2019, 14:35
You can maybe get some boost from this to, keeping all rays calling next-other, and just modify/restore the start of ending-ray code with `jp raycast_end` and not doing `dec c + jp z,` test for every ray.
да это не даст большего выигрыша
~500t +512байт памяти
в принципе можно сделать
- - - Добавлено - - -
+сам установщик jp raycast_end
займет много памяти
тк будет нужна таблица адресов куда его можно вставить
- - - Добавлено - - -
да и тогда легко возможна такая ситуация
casttay1
ray1hit5
push hl
push hl
push hl
jp castray7
castray2
jp raycast_end ;skiped o_O
а далее стек уничтожает все на своем пути :)
NEO SPECTRUMAN
31.05.2019, 17:01
Ага в принципе придумал как написать проверку схожести первых шагов в Lua
Потом как нибудь напишу
наверное выигрыш по скорости будет ощутимым
NEO SPECTRUMAN, так а где сама игрушка/демка то с рейкастом?
NEO SPECTRUMAN
31.05.2019, 19:02
NEO SPECTRUMAN, так а где сама игрушка/демка то с рейкастом?
нету и долго не будет
старую версию под 128к с измерителем расстояния на регистре R
я пару раз уже вбрасывал
новая еще не в запускаемом состоянии
(я только недавно разобрал свой старый сорец и переписал под получение готовых значений расстояния вместо высчитывания)
да и я не спешу ее делать
и будет она под 16с пентевы наверно
+только что придумал как сделать еще немного плавней
- - - Добавлено - - -
В старой версии был такой рейкастер
и несколько коррекций искажений
в итоге было много артефактов
и использовать полученный движок было нельзя
да и сама концепция такого рейкастера подразумевает много артефактов
мало того там я еще пытался сделать сглаживатель\улучшатель полученной картини
но это сожрало всю память...
...а качество толком не улучшилось
1114 696A castray21
1114 696A 62 ld h,d
1114 696B 6B ld l,e
1114 696C AF xor a
1114 696D ED 4F ld r,a
1114 696F 24 inc h
1114 6970 B6 or (hl)
1114 6971 20 71 jr nz,ray21hit
1114 6973 2C inc l
1114 6974 24 inc h
1114 6975 B6 or (hl)
1114 6976 20 6C jr nz,ray21hit
1114 6978 24 inc h
1114 6979 B6 or (hl)
1114 697A 20 68 jr nz,ray21hit
1114 697C 2C inc l
1114 697D 24 inc h
1114 697E B6 or (hl)
1114 697F 20 63 jr nz,ray21hit
1114 6981 24 inc h
1114 6982 B6 or (hl)
1114 6983 20 5F jr nz,ray21hit
1114 6985 2C inc l
1114 6986 24 inc h
1114 6987 B6 or (hl)
1114 6988 20 5A jr nz,ray21hit
1114 698A 2C inc l
1114 698B 24 inc h
1114 698C B6 or (hl)
1114 698D 20 55 jr nz,ray21hit
1114 698F 24 inc h
1114 6990 B6 or (hl)
1114 6991 20 51 jr nz,ray21hit
1114 6993 2C inc l
1114 6994 24 inc h
1114 6995 B6 or (hl)
1114 6996 20 4C jr nz,ray21hit
1114 6998 24 inc h
1114 6999 B6 or (hl)
1114 699A 20 48 jr nz,ray21hit
1114 699C 2C inc l
1114 699D 24 inc h
1114 699E B6 or (hl)
1114 699F 20 43 jr nz,ray21hit
1114 69A1 2C inc l
1114 69A2 24 inc h
1114 69A3 B6 or (hl)
1114 69A4 20 3E jr nz,ray21hit
1114 69A6 24 inc h
1114 69A7 B6 or (hl)
1114 69A8 20 3A jr nz,ray21hit
1114 69AA 2C inc l
1114 69AB 24 inc h
1114 69AC B6 or (hl)
1114 69AD 20 35 jr nz,ray21hit
1114 69AF 24 inc h
1114 69B0 B6 or (hl)
1114 69B1 20 31 jr nz,ray21hit
1114 69B3 2C inc l
1114 69B4 24 inc h
1114 69B5 B6 or (hl)
1114 69B6 20 2C jr nz,ray21hit
1114 69B8 2C inc l
1114 69B9 24 inc h
1114 69BA B6 or (hl)
1114 69BB 20 27 jr nz,ray21hit
1114 69BD 24 inc h
1114 69BE B6 or (hl)
1114 69BF 20 23 jr nz,ray21hit
1114 69C1 2C inc l
1114 69C2 24 inc h
1114 69C3 B6 or (hl)
1114 69C4 20 1E jr nz,ray21hit
1114 69C6 24 inc h
1114 69C7 B6 or (hl)
1114 69C8 20 1A jr nz,ray21hit
1114 69CA 2C inc l
1114 69CB 24 inc h
1114 69CC B6 or (hl)
1114 69CD 20 15 jr nz,ray21hit
1114 69CF 2C inc l
1114 69D0 24 inc h
1114 69D1 B6 or (hl)
1114 69D2 20 10 jr nz,ray21hit
1114 69D4 24 inc h
1114 69D5 B6 or (hl)
1114 69D6 20 0C jr nz,ray21hit
1114 69D8 2C inc l
1114 69D9 24 inc h
1114 69DA B6 or (hl)
1114 69DB 20 07 jr nz,ray21hit
1114 69DD 24 inc h
1114 69DE B6 or (hl)
1114 69DF 20 03 jr nz,ray21hit
1114 69E1 2C inc l
1114 69E2 24 inc h
1114 69E3 B6 or (hl)
1114 69E4 ray21hit
1114 69E4 67 ld h,a
1114 69E5 ED 5F ld a,r
1114 69E7 6F ld l,a
1114 69E8 CB 3D srl l
1114 69EA CB 3D srl l
1114 69EC CB 3D srl l
1114 69EE CB 3D srl l
1114 69F0 CB 3D srl l
1114 69F2 CB 3D srl l
1114 69F4 95 sub l
1114 69F5 CB 3D srl l
1114 69F7 95 sub l
1114 69F8 CB 3D srl l
1114 69FA 95 sub l
1114 69FB 6F ld l,a
1114 69FC E5 push hl
1114 69FD 0D dec c
1114 69FE CA A5 A5 jp z,raycast_end
1114 6A01 castray22
1114 6A01 62 ld h,d
1114 6A02 6B ld l,e
1114 6A03 AF xor a
1114 6A04 ED 4F ld r,a
1114 6A06 24 inc h
1114 6A07 B6 or (hl)
1114 6A08 20 6F jr nz,ray22hit
1114 6A0A 2C inc l
1114 6A0B 24 inc h
1114 6A0C B6 or (hl)
1114 6A0D 20 6A jr nz,ray22hit
1114 6A0F 24 inc h
1114 6A10 B6 or (hl)
1114 6A11 20 66 jr nz,ray22hit
1114 6A13 2C inc l
1114 6A14 24 inc h
1114 6A15 B6 or (hl)
1114 6A16 20 61 jr nz,ray22hit
1114 6A18 24 inc h
1114 6A19 B6 or (hl)
1114 6A1A 20 5D jr nz,ray22hit
1114 6A1C 2C inc l
1114 6A1D 24 inc h
1114 6A1E B6 or (hl)
1114 6A1F 20 58 jr nz,ray22hit
1114 6A21 24 inc h
1114 6A22 B6 or (hl)
1114 6A23 20 54 jr nz,ray22hit
1114 6A25 2C inc l
1114 6A26 24 inc h
1114 6A27 B6 or (hl)
1114 6A28 20 4F jr nz,ray22hit
1114 6A2A 24 inc h
1114 6A2B B6 or (hl)
1114 6A2C 20 4B jr nz,ray22hit
1114 6A2E 2C inc l
1114 6A2F 24 inc h
1114 6A30 B6 or (hl)
1114 6A31 20 46 jr nz,ray22hit
1114 6A33 24 inc h
1114 6A34 B6 or (hl)
1114 6A35 20 42 jr nz,ray22hit
1114 6A37 2C inc l
1114 6A38 24 inc h
1114 6A39 B6 or (hl)
1114 6A3A 20 3D jr nz,ray22hit
1114 6A3C 24 inc h
1114 6A3D B6 or (hl)
1114 6A3E 20 39 jr nz,ray22hit
1114 6A40 2C inc l
1114 6A41 24 inc h
1114 6A42 B6 or (hl)
1114 6A43 20 34 jr nz,ray22hit
1114 6A45 2C inc l
1114 6A46 24 inc h
1114 6A47 B6 or (hl)
1114 6A48 20 2F jr nz,ray22hit
1114 6A4A 24 inc h
1114 6A4B B6 or (hl)
1114 6A4C 20 2B jr nz,ray22hit
1114 6A4E 2C inc l
1114 6A4F 24 inc h
1114 6A50 B6 or (hl)
1114 6A51 20 26 jr nz,ray22hit
1114 6A53 24 inc h
1114 6A54 B6 or (hl)
1114 6A55 20 22 jr nz,ray22hit
1114 6A57 2C inc l
1114 6A58 24 inc h
1114 6A59 B6 or (hl)
1114 6A5A 20 1D jr nz,ray22hit
1114 6A5C 24 inc h
1114 6A5D B6 or (hl)
1114 6A5E 20 19 jr nz,ray22hit
1114 6A60 2C inc l
1114 6A61 24 inc h
1114 6A62 B6 or (hl)
1114 6A63 20 14 jr nz,ray22hit
1114 6A65 24 inc h
1114 6A66 B6 or (hl)
1114 6A67 20 10 jr nz,ray22hit
1114 6A69 2C inc l
1114 6A6A 24 inc h
1114 6A6B B6 or (hl)
1114 6A6C 20 0B jr nz,ray22hit
1114 6A6E 24 inc h
1114 6A6F B6 or (hl)
1114 6A70 20 07 jr nz,ray22hit
1114 6A72 2C inc l
1114 6A73 24 inc h
1114 6A74 B6 or (hl)
1114 6A75 20 02 jr nz,ray22hit
1114 6A77 24 inc h
1114 6A78 B6 or (hl)
1114 6A79 ray22hit
1114 6A79 67 ld h,a
1114 6A7A ED 5F ld a,r
1114 6A7C 6F ld l,a
1114 6A7D CB 3D srl l
1114 6A7F CB 3D srl l
1114 6A81 CB 3D srl l
1114 6A83 CB 3D srl l
1114 6A85 CB 3D srl l
1114 6A87 95 sub l
1114 6A88 CB 3D srl l
1114 6A8A CB 3D srl l
1114 6A8C CB 3D srl l
1114 6A8E 95 sub l
1114 6A8F 6F ld l,a
1114 6A90 E5 push hl
1114 6A91 0D dec c
1114 6A92 CA A5 A5 jp z,raycast_end
- - - Добавлено - - -
Вот приатачил старую глючную версию
https://jpegshare.net/images/e3/9b/e39b2180a9fbfe992daf164c22c0df8b.png
Bedazzle
31.05.2019, 21:04
inc hl ; hl = hl + 1
да, это я смачно накосил про 256 :) :) :)
NEO SPECTRUMAN
31.05.2019, 22:43
да, это я смачно накосил про 256
там даже add hl,xx вместо 2-х inc h inc l ничего не ускорит
наверное только пропуск испускания некоторых лучей
спасет fps отца русской демократии :)
Ped7g, возможно ли сделать такой псевдооперанд
CHK
The CHK directive causes a checksum to be computed and deposited at the current location. The starting point of the checksum calculation is indicated as an argument. Here is the format:
[label] .CHK starting_addr
Here is an example:
start: NOP
LDA #1
.CHK start
The checksum is calculated as the simple arithmetic sum of all bytes starting at the starting_addr up to but not including the address of the CHK directive. The least significant byte is all that is used.
который есть в других, хороших:), асемблерах?)
Конечно, проггеры 80lvl могут и в LUA посчитать, но вот все же иногда КС нужен бывает и обычным "чайникам"
NEO SPECTRUMAN
01.06.2019, 01:48
Конечно, проггеры 80lvl могут и в LUA посчитать, но вот все же иногда КС нужен бывает и обычным "чайникам"
непонел чего ты хош
но первое что пришло в голову это вот что то такое
или что то в этом роде
при необходимости расставить -1 +1 там где надо
codestart
nop
nop
codesize = $-codestart
cnt = 0
chksum = 0
dup codesize
chksum = chksum + {codestart + cnt}
cnt = cnt + 1
edup
Ped7g, возможно ли сделать такой псевдооперанд..
well, it's a possibility, then again the current macros allow you to create such functionality like this (with undocumented "read word" feature):
( tests/macro_examples/sum_checksum.asm (https://github.com/z00m128/sjasmplus/blob/004c31fd519ed9963ee5de4f32bae40603a82357/tests/macro_examples/sum_checksum.asm) ):
; The CHK macro causes a checksum to be computed and deposited at the current location.
; The starting point of the checksum calculation is indicated as an argument.
;
; The checksum is calculated as the simple arithmetic sum of all bytes starting
; at the provided address up to but not including the address of the CHK macro instance.
; The least significant byte is all that is used.
;
; The macro requires the virtual DEVICE memory (checksum needs access to previously
; defined machine code bytes).
; CHK macro definition
MACRO .CHK address?
.SUM = 0 ; init values for checksumming
.ADR = address? ASSERT address? < $ ; starting address must be below current
DUP $ - address? ; do simple sum of all bytes
.SUM = (.SUM + {.ADR})&$FF
.ADR = .ADR + 1
EDUP
DB .SUM
ENDM
; Examples and verification (ZX Spectrum 48 virtual device is used for the test)
DEVICE ZXSPECTRUM48 : OUTPUT "sum_checksum.bin"
TEST1 DB 'A'
.CHK TEST1 ; expected 'A'
TEST2 DS 300, 'b'
DB 'B' - ((300*'b')&$FF) ; adjust checksum to become 'B'
.CHK TEST2 ; expected 'B'
TEST3 inc hl ; $23
inc h ; $24
.CHK TEST3 ; expected 'G' ($47)
... so I'm rather thinking about documenting the `{}` operator finally, to make it official, as it can cover many similar cases.
The advantage of this solution is, that you can copy/paste it into your source now, and use it (no need to wait for new exe).
The disadvantage of this solution is, that it sort of destroys listing file (too much noise from DUP-EDUP).
Somebody can maybe provide also LUA version, which would be more kind to the listing, but I did want to verify that even macro-only solution is possible.
The native version in sjasmplus exe would be faster and preserve the listing file, but I'm not sure if it's worth of it (it feels a bit too specialized, it's not even very good checksum algorithm, although probably quite standard on ZX).
Is this macro sufficient solution for your needs? Or would LUA version suffice?
NEO SPECTRUMAN
01.06.2019, 02:26
so I'm rather thinking about documenting the `{}` operator finally, to make it official, as it can cover many similar cases.
да это очень полезная вещь
ее всегда не хватало
теперь буду использовать повсеместно :)
печально что открытие {} произошло сразу после того
как я притулил {} себе для сворачиваемых комментариев в notepad++...
- - - Добавлено - - -
крайне неприятная особеность
jp l1
jP l1
Jp l1
JP l1
l1 nop
SjASMPlus Z80 Cross-Assembler v1.13.1 (https://github.com/z00m128/sjasmplus)
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
1.asm(8): error: Unrecognized instruction: jP l1
1.asm(9): error: Unrecognized instruction: Jp l1
Pass 3 complete
Errors: 2, warnings: 0, compiled: 16 lines, work time: 0.000 seconds
7 8000 C3 06 80 jp l1
1.asm(8): error: Unrecognized instruction: jP l1
8 8003 jP l1
1.asm(9): error: Unrecognized instruction: Jp l1
9 8003 Jp l1
10 8003 C3 06 80 JP l1
11 8006
12 8006
13 8006 00 l1 nop
Is this macro sufficient solution for your needs?
Спасибо, хороший пример, но что-то в моем случае он считает неправильно :(((((((((
http://s1.micp.ru/R2u4v.jpg
справа - скомпилировано в TASM, слева - в SJAsm
по адресу 1Bh - контрольная сумма, как видно - разная, 79 - правильное число.
Считается с адреса 02h до адреса 1Ah включительно
About {} ... if you would read the sources (that's how I found it)... ;) (I think it was added already by Aprisobal back around first sjasmplus release)
About jp/Jp/jP/JP ... that's intentional choice of sjasmplus (I think it was decided maybe in original sjasm by Sj.M. himself)
instruction/directive must be all of the same case.
Labels/macros/defines are case sentitive.
I actually like it, because I use CamelCase for labels, so I have ~zero risk the assembler will pick one of them as instruction by accident.
But even if I would not like it, I don't think I would change one of the base choices of original sjasmplus, I don't "own" this project enough to introduce such massive change in behaviour.
NEO SPECTRUMAN
01.06.2019, 03:16
About jp/Jp/jP/JP ... that's intentional choice of sjasmplus (I think it was decided maybe in original sjasm by Sj.M. himself)
в нашей отечественной ветке
https://github.com/sjasmplus/sjasmplus
уже пофикшено?
- - - Добавлено - - -
instruction/directive must be all of the same case.
но когда правишь чужой код
у тебя появляются дополнительные проблемы
и это неудобно и раздражает
- - - Добавлено - - -
SjASMPlus Z80 Cross-Assembler v.20190306.1
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
Pass 3 complete
Errors: 0, warnings: 0, compiled: 16 lines
04 0000 org $8000
05 8000
06 8000
07 8000 C3 0C 80 jp l1
08 8003 C3 0C 80 jP l1
09 8006 C3 0C 80 Jp l1
10 8009 C3 0C 80 JP l1
11 800C
12 800C
13 800C 00 l1 nop
для меток это может и нужно (Label labeL LabEL)
но не для инструкций явно нет
- - - Добавлено - - -
справа - скомпилировано в TASM, слева - в SJAsm
по адресу 1Bh - контрольная сумма, как видно - разная, 79 - правильное число.
Считается с адреса 02h до адреса 1Ah включительно
попробуй сгенерировать контрольную сумму для 2-х 3-х байт ($1,$2,$4)
и посмотри что не так
просмотри значения на каждом шаге
по адресу 1Bh - контрольная сумма, как видно - разная, 79 - правильное число.
Считается с адреса 02h до адреса 1Ah включительно
I don't understand... I see (from address 02 to 1A)
20 50 49 38 30 20
20 20 20 20 20 43 01 00
40 08 40 20 20 20 20 20
20 43 41
too lazy to do the full 8b math in head, but I see the low nibbles 9 + 8 + 3 + 1 + 8 + 3 + 1 = 33 mod 16 = 1
So the "9" in 79 doesn't make sense with "The checksum is calculated as the simple arithmetic sum of all bytes starting" - seems like some other formula is used in TASM.
Seems to me like XOR instead of add... let me try that.
https://github.com/z00m128/sjasmplus/blob/master/tests/macro_examples/sum_checksum.asm
Yes, with XOR the result is $79.
NEO SPECTRUMAN
01.06.2019, 03:26
MACRO CHK address
.SUM = 0 ; init values for checksumming
.ADR = address ASSERT address < $ ; starting address must be below current
DUP $ - address ; do simple sum of all bytes
.SUM = (.SUM + {.ADR})&$FF
.ADR = .ADR + 1
EDUP
DB .SUM
display .SUM
ENDM
org $8000
l0
db $FF
db $01
db $02
CHK l0
21 8000 01 db $01
22 8001 02 db $02
23 8002 04 db $04
24 8003
25 8003
26 8003
27 8003
28 8003 CHK l0
28 8003 07 > DB .SUM
21 8000 FF db $FF
22 8001 01 db $01
23 8002 00 db $00
24 8003
25 8003
26 8003 CHK l0
26 8003 00 > DB .SUM
21 8000 FF db $FF
22 8001 01 db $01
23 8002 02 db $02
24 8003
25 8003
26 8003 CHK l0
26 8003 02 > DB .SUM
вполне себе правильно работает
About jp/Jp/jP/JP ... well, there's the new `--syntax` option, which can be extended also to switch off instructions same-case sensitivity for particular piece of source, so I will look into it, how much difficult that would be.
But I don't want that "fix" as "default" at this moment (I may change my mind over time after thinking about it more, this is only telling you how I *feel* *now* = what you can expect in near future = no change or --syntax extension)
NEO SPECTRUMAN
01.06.2019, 03:29
.SUM = (.SUM + {.ADR})&$FF
.SUM = (.SUM + {.ADR})
DEFB low .SUM
да и low high значительно удобней использовать чем %$FF /$FF
- - - Добавлено - - -
Yes, with XOR the result is $79.
в конечном итоге так и оказалось...
Seems to me like XOR instead of add... let me try that.
Excellent!!
Now it works correctly, this macro is enough for me.
Thank.
Ok, in future release (or you can already build from github current master) this will come:
"--syntax=i" to make instructions/directives case insensitive ... I was hoping to add also "I" option to uppercase all labels, but that's not possible without finally rewriting the labels implementation, would be too much mess and work in current source.
(BTW, I still think you should rather reformat the old source, shouldn't be that much hard... but the option will be available too)
"opt" will get two more commands "listoff, liston" to suspend listing file from source (for macros like CHKXOR to not fill listing with useless DUP looping)
"{address}" is now "official" (in documentation), and I added "{b address}" variant to read only BYTE.
(I have no idea yet, when "1.13.2" will happen, the 13.1 was just released, so I'm in no hurry, will give it probably 2-4 weeks = so this is just early-access info :) )
лично мне в sjasm/sjasmplus всегда не хватало библиотек, как это было, к примеру, у M80. Т.е. код чтобы собрать не в бинарь, а в некую либу, по мотивам всяких компиляторов си или тот же M80. А потом можно было бы прилинковывать из этой библиотеки функции/процедуры. Было бы удобно очень.
NEO SPECTRUMAN
04.06.2019, 11:56
лично мне в sjasm/sjasmplus всегда не хватало библиотек, как это было, к примеру, у M80. Т.е. код чтобы собрать не в бинарь, а в некую либу, по мотивам всяких компиляторов си или тот же M80. А потом можно было бы прилинковывать из этой библиотеки функции/процедуры. Было бы удобно очень.
org $8000
l0
call dup3
call dup2
l1 di
halt
ifused dup3
dup3
dup 3
ld a,a
ret
edup
endif
ifused dup2
dup2
dup 2
ld b,b
ret
edup
endif
ifused dup1
dup1
dup 5
ld c,c
ret
edup
endif
17 0000 org $8000
18 8000
19 8000 l0
20 8000
21 8000 CD 08 80 call dup3
22 8003 CD 0E 80 call dup2
23 8006
24 8006
25 8006 F3 l1 di
26 8007 76 halt
27 8008
28 8008
29 8008 ifused dup3
30 8008 dup3
31 8008 dup 3
32 8008 7F > ld a,a
33 8009 C9 > ret
32 800A 7F > ld a,a
33 800B C9 > ret
32 800C 7F > ld a,a
33 800D C9 > ret
35 800E endif
36 800E
37 800E ifused dup2
38 800E dup2
39 800E dup 2
40 800E 40 > ld b,b
41 800F C9 > ret
40 8010 40 > ld b,b
41 8011 C9 > ret
43 8012 endif
44 8012
45 8012 ifused dup1
46 8012~ dup1
47 8012~ dup 5
48 8012~ ld c,c
49 8012~ ret
50 8012~ edup
51 8012 endif
и чтоб оно часами собиралось?
а кто мешает прицепить инклудом?
а там нагородить макросов или процедур
которые по условию будут компилироваться если были использованы
- - - Добавлено - - -
объявил использование процедуры в начале сорца
macro dup100nop
dup100nop_cmp = 1
call dup100nop_code
endmacro
библиотека
if dup100nop_cmp = 1
dup100nop_code
dup 100
nop
edup
ret
endif
использование
dup100nop
почему оно должно собираться часами?
для этого придумали библиотеки, а ты костыль предлагаешь.
NEO SPECTRUMAN
04.06.2019, 12:07
для этого придумали библиотеки, а ты костыль предлагаешь.
переписал на более правильное
помоему теперь єто то что надо
- - - Добавлено - - -
все ifused-ы цепляешь инклудом
и будет тебе библиотека
переписал на более правильное
помоему теперь єто то что надо
как был костыль, так и остался. М80 на профике за 10 секунд собирает весь дос со всеми драйверами и не только, а ты хочешь чтобы благодаря либам ужасм часами на многопоточной системе код собирал. шутник ты, однако.
NEO SPECTRUMAN
04.06.2019, 12:10
случайно запихнул RET под DUP :)
- - - Добавлено - - -
как был костыль, так и остался.
и чего ты тогда хочешь
если 2-й вариант не устраивает?
не знаю что там у вас в м80 и что это такое
NEO SPECTRUMAN, ты никогда библиотеками не пользовался? на си никогда не писал? тогда понятно твоё стремление оскостылить любой код ифами и дапами.
не знаю что там у вас в м80 и что это такое
чего там не знать? целая куча кросс компиляторов с поддержкой библиотек. печаль в том, что все они древние и нет функционала ужасма.
NEO SPECTRUMAN
04.06.2019, 12:17
NEO SPECTRUMAN, ты никогда библиотеками не пользовался? на си никогда не писал? тогда понятно твоё стремление оскостылить любой код ифами и дапами.
слава богу не писал
страдать такой херней
я в основном просматривал чужие сорцы
да dup-ы да примера Же
- - - Добавлено - - -
чего там не знать?
ну когда я начинал ужо был сджасм
(хотя я начинал не снего)
а юзать какието окаменелости...
- - - Добавлено - - -
ты никогда библиотеками не пользовался? на си никогда не писал? тогда понятно твоё стремление оскостылить любой код ифами и дапами.
так тут асм а не этот ваш си
а в него все время пытаетесь засунуть свои структуры и библиотеки и прочую объектоориентированную херню...
объясни в двух словах как должно работать
можот я знаю что это
но не знаю как называется
все ifused-ы цепляешь инклудом
и будет тебе библиотека
Библиотека это всё несколько иное. Никаких диких костылей инклуд и прочего делать не надо. Это можно конечно, но не нужно. Вдруг ты где что забыл? Закомментил и оно не работает. А если юзать именно библиотеки, то написал ты call MyProcedure. Сборщик видит это и выцепляет из библиотеки нужную процедуру. Это удобнее же?
NEO SPECTRUMAN
04.06.2019, 19:19
Сборщик видит это и выцепляет из библиотеки нужную процедуру. Это удобнее же?
и чем это отличается от ifused?
такая сложность собрать с ним "библиотеку" в виде 1 инклуда?
а потом закоментил последний call на процедуру
и все отдельная процедура не собирается
серавно готовых библиотек не найдете
и нужно их будет писать самому
Никаких диких костылей инклуд
какие дикие костыли (1-й вариант конечно был но я его быстро выпилил)
всего лишь надо написать в начале каждой процедуры
1 ifused
и приципить этот набор процедур в свободное место
NEO SPECTRUMAN, у всех всё по разному. а если набор таких функций и процедур несколько десятков? сидеть и пилить в основном коде серию дефайнов? что-то забыл задефайнить и код не рабочий или не собирается - сиди потом разгребай, ищи, тестируй. А библиотека это всё решает. Кроме того, когда в исходнике будет сотня всяких ифов, то читаемость такого исходника падает. в случае косяков опять сидеть разгребать. библиотека эту проблему тоже решает. объектный код прилинковывается в момент сборки, указать нужно всего лишь объектный файл. всё, что в либе используется, будет подключено, включая прочие зависимости. всё что не нужно, останется в файле, а не в собираемом бинаре. меньше телодвижений, меньше текста, меньше багов.
если бы всё решалось так "просто" как ты предлагаешь. сишники так бы и делали. но нет - придумали объектные файлы и прочие подобные фигны. уж сколько лет существует цпм, а даже там и то есть такое и это при том, что М80 тоже понимает всякие ифы и макросы. вот только М80 работает в адресном пространстве z80 и ничуть не тупит при компиляции тяжёлых файлов. а ты переживаешь, что ужасм поставит на колени твой любимый Core I.
NEO SPECTRUMAN
04.06.2019, 19:45
а если набор таких функций и процедур несколько десятков? сидеть и пилить в основном коде серию дефайнов? что-то забыл задефайнить и код не рабочий или не собирается - сиди потом разгребай, ищи, тестируй. А библиотека это всё решает.
что забыл задефайнить?
приведи пример
что может не работать?
- - - Добавлено - - -
Кроме того, когда в исходнике будет сотня всяких ифов, то читаемость такого исходника падает.
какие ифы?
все ифы в библиотеке
с cорцe только call procedure
а в инклуженной библиотеке
при использовании procedure
создается метка procedure и комплилится код
- - - Добавлено - - -
включая прочие зависимости. всё что не нужно, останется в файле, а не в собираемом бинаре.
ну если зависимости между 2+ библеотеками
то тогда придется крепить к сорцу каждую библиотеку самому
или же будет как раз куча костылей
по самоинклуживанию
что не вариант
- - - Добавлено - - -
твой любимый Core I.
нету у меня такого
терпеть ненавижу єту линейку процов
- - - Добавлено - - -
в случае косяков опять сидеть разгребать. библиотека эту проблему тоже решает. объектный код прилинковывается в момент сборки, указать нужно всего лишь объектный файл. всё, что в либе используется, будет подключено, включая прочие зависимости.
да вижу эти преимущества
чтоб скомпилить чужой сорец
тебе надо выкачать пол интернетов библиотек определенных версий
и плясать с бубном чтоб что то собрать...
тк сорец идет без ничего
- - - Добавлено - - -
а щас можно ложить сджасм в комплекте с сорцом
и все собирается из коробки в 1 клик
- - - Добавлено - - -
и ничуть не тупит при компиляции тяжёлых файлов. а ты переживаешь, что ужасм поставит на колени твой любимый Core I.
ну не совсем так
просто как по мне
впиливание новой версии lua
намного важней єтих сишных приблуд
которые итак как по мне легко заменяются тем что есть
нету у меня такого
терпеть ненавижу єту линейку процов
ну значит amd fx/amd ryzen, не суть важно.
все ифы в библиотеке
в какой библиотеке? то, о чём ты говоришь не библиотека, а просто исходник, который ты инклудишь. опять таки - пачка ифов портит читаемость.
я твой посыл понял, тебе это удобно, а мне было бы удобно иметь объектный файл. никаких ифов и прочей фигни. и исходники чистые, особенно если эта библиотека собирается не из одного мегаисходника, а их серии мелких. это ещё один недостаток твоего метода - всё нужно засовывать в один большой файл или делать с десяток инклудов.
хочется примеров? да пожалуйста. я вот под трдос не делаю что-либо, а кодю под спринтера. всякие fopen, fread, fwrite, всякие page_alloc, функции печати аля printf (да да, есть и такая, как для си, только писанная на асме без поддержки float). порядка 40 системных вызовов завернул бы в одну либу. а сейчас это всё в одном мегаисходнике. аж воротит туда заглядывать. вот пилю щас новый fdisk и такая либа была бы очень кстати.
и чем это отличается от ifused?
В библиотеке может быть 10 процедур, при вызове одной только она и возьмется, в этом и есть отличие
NEO SPECTRUMAN
04.06.2019, 19:59
в какой библиотеке? то, о чём ты говоришь не библиотека, а просто исходник, который ты инклудишь. опять таки - пачка ифов портит читаемость.
как они портят читаемость?
они несколко портят читаемость лог-а\готового листинга
в основном исходнике же
только только call
и 1 инклуд 1 библиотеки
а кодю под спринтера. всякие fopen
а как процедуре должны передаваться параметры?
- - - Добавлено - - -
В библиотеке может быть 10 процедур, при вызове одной только она и возьмется, в этом и есть отличие
та глянь пример
при вызове одно процедуры
ТОЛЬКО ОДНА ПРОЦЕДУРА И СОБЕРЕТСЯ ЖЕ!!!!!!!!1
45 8012 ifused dup1 46 8012~ dup1 47 8012~ dup 5 48 8012~ ld c,c 49 8012~ ret 50 8012~ edup 51 8012 endif
вот те цитата
dup1 не вызывался
и не попал в сорец
вот с параметрами для процедуры
могут быть проблемы
это я не учел
если вы их хотите передавать в виде
procedure 444,444,44
это нужно городить макросы с костылями
и тут тогда я не совсем прав
как они портят читаемость?
тем, что все библиотечные процедуры и функции сидят в одном мегаисходнике, который потом инклудится. если дробить на мелкие файлы, то в основном исходнике уже не 1 инклуд, а пачка, что тоже не удобно.
а как процедуре должны передаваться параметры?
не понял вопроса. какой процедуре? в библиотеке? точно так же как и всегда - хоть через регистры, хоть через буфера, хоть через стэк. как сам напишешь.
макрос это макрос. у ужасма макросы параметрические, как и у всех асм компиляторов, даже у старого М80.
NEO SPECTRUMAN
04.06.2019, 20:13
тем, что все библиотечные процедуры и функции сидят в одном мегаисходнике, который потом инклудится. если дробить на мелкие файлы, то в основном исходнике уже не 1 инклуд, а пачка, что тоже не удобно.
а что тогда из себя представляет библиотека в твоем понимании?
- - - Добавлено - - -
не понял вопроса. какой процедуре? в библиотеке? точно так же как и всегда - хоть через регистры, хоть через буфера, хоть через стэк. как сам напишешь.
спрашиваю не прописываются ли с боку параметры при вызове
или параметры хочешь ложить при помощи обычных инструкций перед вызовом
ld a,parameter
call procedure
?
- - - Добавлено - - -
а так ты ужо столько настрочил
мог бы 100 раз привести строчек 10 псевдокода
чтоб донести идею
или параметры хочешь ложить при помощи обычных инструкций перед вызовом
ld a,parameter
call procedure
?
именно так. иначе это уже си какой то. хотя если будет дериктива procedure для обозначения процедуры/функции, то не откажусь.
а что тогда из себя представляет библиотека в твоем понимании?
может я ранее как-то не верно сформулировал, попробую сейчас пояснить, "перефразируюсь"...
вот смотри - есть часто прикручиваемые к разным прогам функции и процедуры. открыть файл, прочитать файл, записать файл, запрос памяти у доса, вернуть досу память, печать текста (простая печать и более сложная функция printf выдернутая из си и адаптированная под свои нужды), мат.функции, вроде 8/16/32 бита умножение и деление и другие. лично мне содержать в одном большом файле это всё не удобно. да. 1 инклуд, я знаю, но в случае правки кода в этой "библиотеке", перемещаться становится там всё сложнее. плюс гора этих ифов. я бы разбил это всё на мелкие исходнички, которые потом скомпилировал бы в одну статичную либу/объектный файл/rel файл. при сборке основного кода в качестве доп.аргумента указал бы имя этой либы. каждая вызываемая процедура/функция подключалась бы к процессу компиляции. при этом, к примеру, на си когда компилишь, то порядок перечисления исходников. объектов и библиотек будет соблюдаться и при линковке кода из этих объектов и библиотек. но у нас ужасм, значит можно было бы добавить директиву, по которой можно было бы указать место размещения кода из библиотеки. может даже указать внутри основного кода имя этой библиотеки. это было бы равносильно инклуду с той разницей, что нет нужны ковыряться в большом мегаисходнике-библиотеке или инклудить с десяток мелких.
надеюсь так понятнее будет, если не запутал...
NEO SPECTRUMAN
04.06.2019, 20:46
как вариант
сорец
ld a,66
call procedure1
call procedure3
call procedure1
include "libs.asm"
libs.asm
display "version"
include "libs\a1.asm"
include "libs\a2.asm"
include "libs\a3.asm"
include "libs\a4.asm"
include "libs\a5.asm"
a1.asm
ifused procedure1
procedure1
rra
ret
endif
либасм и папку подкидывать в каждый нужный сорец
include "libs.asm"
можно вообще наверно сослаться на
include "с:\фигзнаетчточтониукогоне т\libs.asm"
и использовать одну библиотеку для всего
но после єтого тебя будут вспоминать...
- - - Добавлено - - -
надеюсь так понятнее будет, если не запутал...
нутак
а как происходит вызов функций из сорца?
сомневаюсь можно ли их чем то заменить
- - - Добавлено - - -
которые потом скомпилировал бы в одну статичную либу/объектный файл/rel файл. при сборке основного кода в качестве доп.аргумента указал бы имя этой либы. каждая вызываемая процедура/функция подключалась бы к процессу компиляции.
но а потом получить читаемый сорец будет проще из дизасма
чем из твоего исходника
пушо будет упоминание левых процедур
а самих процедур не будет
мало того тут асм а на си
используются реги проца
некоторые постоянно
некоторые весь фрейм висят ждут пока из них прочитают
если ты накосячих в одной своей библиотеке
и откомпилируешь
а потом процедура из библиотеки что то затрет
как ты будешь отлавливать что затерло?
ты не сможешь быстро перейти в код библиотеки и пофиксить
хотя как всегда
оно будет работать годами что то затирая и не вызывая подозрений
а потом в один день наступят грабли
если передавать параметры через стек
ты уже не можешь быстро запушить все регистры
в начале процедуры
тебе нужно будет достать и куда то сохранить параметры
а потом только пушить
если не пушить их в самой процедуре библиотеки
то будут грабли с затиранием чем то чего то нужного
неизвестно когда
тут не си
регистры общие для всего
или же на этих си костылях просрется вся скорость
для которой и нужен асм
как эту всю байду оптимизировать?
а потом дизасмишь игры
а там часто такое...
call l1
l1 jp l4
l4 jp l7
l7 ld a,b
jp l44
l44 ret
I will try to be very brief (as I'm busy and my "brief" posts tend to be 3 pages long, while "non-brief" would aspire for a book chapter).
sjasmplus does assemble directly into machine code. There is no support for object file currently. If you want support for some specific object file, create issue on github with documentation about the object file format... but it better should be mostly as-machine-code with just some meta data added on top of it, otherwise it would need another assembler inside the assembler = I don't think somebody will find time to do that.
For my personal projects (and for all SW I use) I strongly prefer sources, "libraries" like libSomething-dev.deb are convenient to install (I can turn fresh linux installation into developer's machine in ~5 minutes, having all compilers and stuff installed), but sooner or later one always needs also sources to fix or modify something, or just verify how the author did implement it. I mean, I don't build from sources everything I use, but I always make sure I can obtain source of everything I use (and if the source is not available, I usually go great lengths to find alternative or write my own).
With assembly programming it's even worse, almost always I need to slightly adjust particular code per-project, there's rarely something I just copy/paste without any modification, so having "libraries" in sources works nicely for me (in assembly especially).
Aside my personal preferences, there are these tools available:
** Way of "include source":
`INCLUDE` to include source files, you can set include paths on command line, if you want to keep all utility sources at one place outside of project (by using quotes/angle-brackets around file name you can specify if the sjasmplus should search first system includes, or current source directory). (and if you will use the "IFUSED" in the library source, only the used subroutines will emit machine code)
(this also makes it easier to relocate Z80 machine code, because Z80 CPU doesn't provide good support for "position independent code", so relocating binary without source is usually big pain).
These source lines are of course visible in listing file, and in labels table.
About listing file: in upcoming sjasmplus (v1.13.2+) there will be new option to suppress listing file temporarily, so you can use that to make library "invisible" in listing.
About labels table: the sjasmplus does support "MODULES" (for a long time), so you can use particular module namespace for your library to avoid accidental collisions with labels used by your project code. These will be still visible in listing of all labels (you can delete module labels quickly in any text editor by search+replace, if that would become a real problem)
** Way of "include binaries":
You can also create "export" file - in library source use `EXPORT function_name` to put the symbol into export file, then at command line while assembling use `--exp=export_file_name.asm` to store these symbols in small ASM source file. You can then include this export list in project source, and use symbols to call the library code. And you can use INCBIN to include the library code itself or load it separately from code (listing and labels table will show only the exported symbols).
------
I have very difficult time to imagine real world ZX Spectrum project written in ASM which would be too large to manage in the "source" way above, so I never thought too much about the "binary" way. From a quick glance it seems viable too (although I would expect it to be more cumbersome and not as powerful as tailoring sources to specific needs of particular project).
If you have on mind some large project, where maintaining sources would be too difficult, you can also check other projects like z88dk compiler suite (contains two C compilers for Z80, assembler and linker).
I personally have no plans to extend sjasmplus so much, that it would compete with these (and I'm not aware of anyone else willing to contribute toward this goal at this moment).
Actually the small-size and self-containment of sjasmplus is something what I **like**. If you want just to try some small Z80 assembly on ZX Spectrum, like some short piece of code from book, sjasmplus should be simple to download, and use even by somebody new to the assembly programming (and if it is not, let me know what is problematic, so we can improve it).
Yet I believe it is very powerful tool (already in current version, and I have some plans how to extend it even a bit more), with most of the bugs fixed and quality assured, I have no hesitation to recommend current v1.13.1 even for "production-quality" large projects.
But if you are used to other tools, you should invest some time into reading through documentation (http://z00m128.github.io/sjasmplus/documentation.html) and checking out the accompanying "examples (https://github.com/z00m128/sjasmplus/tree/master/examples)" and "tests (https://github.com/z00m128/sjasmplus/tree/master/tests)" folders, to get more familiar with sjasmplus options and features.
а потом дизасмишь игры
а там часто такое...
call l1
l1 jp l4
l4 jp l7
l7 ld a,b
jp l44
l44 ret
You know, so you decide to optimize it, replace `call l1` with `ld a,b` and suddenly the game stops to work correctly, because the new timing will uncover some bug somewhere else which didn't show up with the slower code before... :P ... I know you all, you will not trick me so easily ... this time... :D (/joke)
NEO SPECTRUMAN
03.07.2019, 02:00
4 часа пытаюсь заставить sjasm скомпилировать подобный код... :v2_dizzy_wall:
aaa = 0
lua allpass
_pc("if aaa = 0")
_pc("defb $ff")
_pc("defb $ff")
_pc("defb $ff")
_pc("defb $ff")
_pc("endif")
_pl(" if aaa = 3")
_pl(" defb $f0")
_pl(" endif")
endlua
SjASMPlus Z80 Cross-Assembler v1.07 RC7 (build 02-04-2008)
Test.asm(11): error: Unexpected end of file
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
Test.asm(11): error: [IF] No ENDIF
Test.asm(18): error: ENDIF without IF/IFN/IFUSED/IFNUSED/IFDEF/IFNDEF
Test.asm(20): error: [IF] No ENDIF
Test.asm(22): error: ENDIF without IF/IFN/IFUSED/IFNUSED/IFDEF/IFNDEF
Pass 3 complete
Errors: 4, warnings: 0, compiled: 17 lines, work time: 0.000 seconds
но при этом одни $00
заставить сделать if не получается никак
на pass1 pass2 pass3 отдельно тоже без результатно
просто все стало на этой ХЕРНЕ
- - - Добавлено - - -
Ped7g, а нельзя сделать что то типа такого?
defarray the_array
the_array[1] = 4
the_array[5] = the_array[4] + 1
the_array[counter] = 2
или такое
{0} = 3
{5} = 3
if {$4000} = 5
nop
eif
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:
aaa = 3
bbb = $c0
dup 10
if aaa = 5 : db $ff : endif
db bbb+aaa
aaa = aaa + 1
bbb = bbb - $10
edup
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.
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/releases/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).
NEO SPECTRUMAN
03.07.2019, 10:55
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.
нет это не работает
да и мне нужно будет вставить много кода между if endif
for all_addr_cnt1 = op_jptabs_haddr_start,op_jptabs_haddr_end,1 do
print (all_addr_cnt1)
temp1 = string.gsub("if op_addr_xxx = 0 : nop : endif","xxx",string.format("%x",all_addr_cnt1))
_pc(temp1)
end
SjASMPlus Z80 Cross-Assembler v1.13.2 (https://github.com/z00m128/sjasmplus)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Pass 1 complete (0 errors)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Pass 2 complete (0 errors)
32
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
33
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
34
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
35
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
36
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
37
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
38
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
39
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
40
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
41
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
42
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
43
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
44
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
45
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
46
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
47
Test.asm(33): error: [IF] No ENDIF
Test.asm(33): error: Unexpected: : nop : endif
Pass 3 complete
Errors: 32, warnings: 0, compiled: 61 lines, work time: 0.031 seconds
- - - Добавлено - - -
because pass1 and pass2 will see {$4000} as 0, only in pass3 there will be real value...
а сильно тяжело увеличить количество проходов?
мне кажется что 3 прохода это маловато для работы сложных генераторов кода
- - - Добавлено - - -
But if you want "array" of control variables,
мне нужен переменный набор переменных
чтоб сделать подобный код
vars = 3
a1 = 0
a2 = 0
a3 = 0
...
if a1 = 0
code
a1=a1+5
endif
...
if a3 = 0
code
a3=a3+10
endif
a1=a1-1
a2=a2-1
a3=a3-1
vars = 200
a1 = 0
...
a200 = 0
if a1 = 0
code
a1=a1+10
endif
....
if a200 = 0
code
a200=a200+44
endif
a1=a1-1
a2=a2-1
...
a200=a200-1
а дальше будет генерироваться адреса для org-ов
а сильно тяжело увеличить количество проходов?
мне кажется что 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 ... :D (but still not that easy, even that may be complicated, probably not 2-3 lines fix).
NEO SPECTRUMAN
04.07.2019, 00:32
I'm still not sure why you don't use full Lua generator,
а как мне организовать переменный набор переменных в lua?
опять же было бы там _write_to_memory(16384.255)
и я бы как то выкрутился
да и документации на lua которая встроена в sjasm нет
неизвестно какие команды в ней есть а какие нет
может там как то можно завести массив на 256 значений
и использовать его
- - - Добавлено - - -
вот нагуглил такое
a = {} -- new array
for i=1, 1000 do
a[i] = 0
end
пойду пробовать
заработает ли подобное в lua sjasm-a
- - - Добавлено - - -
a = {}
for i=1,1000,1 do
a[i] = i*2
end
print (a[3])
print (a[6])
print (a[10])
на вид работает :v2_dizzy_roll:
SjASMPlus Z80 Cross-Assembler v1.13.2 (https://github.com/z00m128/sjasmplus)
6
12
20
Pass 1 complete (0 errors)
6
12
20
Pass 2 complete (0 errors)
6
12
20
Pass 3 complete
Errors: 0, warnings: 0, compiled: 18 lines, work time: 0.000 seconds
- - - Добавлено - - -
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 endif :)
а результат работы lua кода должен быть специальный адрес для org
так что переписать на lua может не получиться...
- - - Добавлено - - -
I'm still not sure why you don't use full Lua generator
и как мне сделать на lua такое?
lua (use code_size)
code
defb $01
defb $01
code_end
code_size = code_end - code
lua (use code_size)
code
defb $02
defb $02
defb $02
code_end
code_size = code_end - code
lua (use code_size)
code
defb $03
defb $03
code_end
code_size = code_end - code
- - - Добавлено - - -
Ped7g, а еще в целях отладки не хватает pause
чтоб через display и print ()
можно было пошагово проследить
правильно ли идет сложная генерация кода
NEO SPECTRUMAN
04.07.2019, 12:38
В общем пока ничего не получается...
Вопрос от AloneCoder. Сам по каким-то причинам он не может его задать здесь, а на почту как он говорит ответа не дождался.
Hello!
We are developing a new operating system for Speccy, NedoOS: http://nedoos.ru/
Recently I tried the new version of sjasmplus.
It's very nice because now it can export labels in 0..3fff.
Can you please restore support for backslash-escaped characters in single-quoted character constants? Rationale: it was supported in v1.07, and it's used in NedoLang output (it exports constants directly from *.c).
Also I see, support for UTF8-encoded sources was dropped, so it shows an error at the beginning BOM marker. Can you please restore it? There was a bug previously: BOM marker should be followed by a blank line.
One more question: is it possible to remove the following messages in the output:
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
INCBIN: name=winto866 Offset=0 Len=256
Pass 3 complete
Errors: 0, warnings: 0, compiled: 2311 lines, work time: 0.047 seconds
And make error lines RED? That's crucial because there are so many programs in the project.
Thanks!
ZX_NOVOSIB
05.07.2019, 12:52
Сам по каким-то причинам он не может его задать здесь
Гордость? :)
gurfunkel
05.07.2019, 19:45
Гордость?
Он же забанен, вроде.
Can you please restore support for backslash-escaped characters in single-quoted character constants? Rationale: it was supported in v1.07, and it's used in NedoLang output (it exports constants directly from *.c).
hmmm... maybe as extra --syntax option, but not sure if/when...
I have a suspicion it's a bit more difficult than it may seem ... although maybe if I would treat apostrophe the same way as quote, it would work as long as you will not try to break it ... i.e. 'don\'t do it' would parser see as "don\'t do it", which would work, but then <apostrophe><quote><apostrophe> would be invalid (would need <apostrophe><backslash><quote><apostrophe> to work), and 'text" would become valid (!)... if such hack is enough for you, maybe it will happen. But to do it properly would basically need two versions of buffered-reader and line parser code, as both are hardcoded to parse strings as defined in the documentation. Basically I'm not a big fan of this idea.
Also I see, support for UTF8-encoded sources was dropped, so it shows an error at the beginning BOM marker. Can you please restore it? There was a bug previously: BOM marker should be followed by a blank line.
I don't recall it was even there, but maybe it worked due to some quirk... definitely good idea, I will make a note to my TODO. But you can also just strip the BOM marker out of the file... I have to do that pretty often in our commercial Android projects.... :D I think in some projects I have even some batch shell script to scan all the files and cut it out where it's found. I think in linux world BOM marker is not that important, not sure about elsewhere. (that's like "workaround" suggestion, I will try to fix BOM parsing in future)
One more question: is it possible to remove the following messages in the output:
Pass 1 complete (0 errors) ...
--msg=none|war|err
And make error lines RED? That's crucial because there are so many programs in the project.
hmm... maybe... but if you are building from IDE/text editor, they usually do it for you, like for example this is how it looks on my machine in Kate:
69455
... so, depends what you are using, also if you are using command line, then you can also catch output into file and open it in text editor...
This is also small asnwer for NEO SPECTRUMAN, if I understand his problem correctly? ("Ped7g, а еще в целях отладки не хватает pause")
you can do `sjasmplus --some-options file.asm 2> error.log.txt` and open that in the text editor, then you can use Search all to highlight Error lines... (but warnings/errors are now channelled to STDERR, not STDOUT, so you must redirect with "2>", not simple ">" or "1>")
- - - Updated - - -
But I'm glad you find sjasmplus useful... hopefully some of these will make it even more useful... I'm kinda really unhappy about that apostrophe thing, sjasmplus had this syntax defined long time ago, I just fixed the parsers, it was not my idea. And for assembler purposes the "no escaping" is often helpful, while in C/C++ I think the escape-always makes more sense. ... I would like lot more if you would fix your output instead to produce "correct" asm source.. :D
NEO SPECTRUMAN
06.07.2019, 15:46
This is also small asnwer for NEO SPECTRUMAN, if I understand his problem correctly? ("Ped7g, а еще в целях отладки не хватает pause")
нет это никак мне не поможет
мне нужна именно пауза до нажатия любой клавиши при компиляции
чтоб через расставленные по коду десятки display
оценивать правильность работы
проверять гигантские результаты
и искать 1 строку в которой пошло все не так
достаточно тяжело
https://jpegshare.net/images/73/f5/73f573d781738bb6eddae72f9553d649.png
I don't understand you... simply assemble with output redirected into file, then open the file in text editor, and go through it as slowly as you wish, or even return back, or use search/replace to adjust it, etc...
Or if you insist on pause, you can redirect stderr to stdout: `sjasmplus 2>&1 | more` ... (talking about regular *NIX environment like bash shell, if you are using windows, than I have no idea how their shell work nowadays, you probably should still try this too, it has some chance of working ... actually now with "git" being so often used even by windows users, you may have almost fully working bash from the git installation, from there you can surely do the thing above)
But I don't get how pausing current output is in any way better than storing it into file, and process the file instead, with pause-only you can't even go back, or archive it... but whatever you like, it's your choice. :)
а как мне организовать переменный набор переменных в lua?
ман почитать? нагородил тут не пойми зачем.
Условная компиляцыя:
DEFINE rel
IFNDEF rel
include "../utils.inc"
ELSE
include "../demovars.inc"
ENDIF
display /d,end-begin
display notecnt
IFNDEF rel
savesna "pair.sna",begin
ELSE
savebin "01pair.code",begin,end-begin
ENDIF
как-то так
- - - Добавлено - - -
Он же забанен, вроде.
не, просто обидели мышку, накакали в норку - сверху темно, тесно и воняет.
...
и как мне сделать на lua такое?
lua (use code_size)
code
defb $01
defb $01
code_end
code_size = code_end - code
lua (use code_size)
code
defb $02
defb $02
defb $02
code_end
code_size = code_end - code
lua (use code_size)
code
defb $03
defb $03
code_end
code_size = code_end - code
https://github.com/z00m128/sjasmplus/tree/master/tests/lua_examples
;-----------------------------------------------------------------
; idea is from NEO SPECTRUMAN, who was trying to speed up "opcode" jumptable.
; implementation of Lua scripts and macros for sjasmplus is from Ped7g
device zxspectrum48
;-----------------------------------------------------------------
; example of usage of the produced table (code provided by NEO SPECTRUMAN)
org $C000
; A = operation (alias "opcode") number 0..255
ld l,a ;4
ld h,high opJpTab ;7
ld h,(hl) ;7
jp (hl) ;4
;=22t
;-----------------------------------------------------------------
; define LUA functions for memory allocations for opcodes functions
;
; (the ";" ahead of "end" and some "--" is not needed for Lua, but for my text
; editor sjasmplus syntax highlight, as it gets confused by lua source)
;
; Opcodes *must* be allocated in sequence (0,1,2 ...) to avoid large empty
; areas in memory, or even running out of memory completely. Also opcode
; implementation subroutines must be reasonably short (few bytes, not hundreds)
lua pass1
function allocateOpMemory(opcode)
-- search for free "page" (512B pages starting at opRoutines address)
freePage = _c("high opRoutines")
while allocatedPages[freePage] and opcode < allocatedPages[freePage] do
freePage = freePage + 2
-- +2 to operate over 512 bytes, with 256B pages high opcodes like FE
-- may overwrite following page where early opcodes like 01 resides
;end
; -- remember it for "finishOpAllocate" function
_G.lastFreePage = freePage
; -- free page found, emit it into jump table
_pc(string.format("org $%04x", _c("opJpTab") + opcode))
_pc(string.format("db $%02x", freePage))
; -- and reset ORG to target memory for opcode function body
_pc(string.format("org $%04x", freePage*256 + opcode))
_pl(string.format("opcode_%02x_impl:", opcode))
;end -- ";" to make my Kate editor syntax highlight survive "end" in lua
function finishOpAllocate()
assert(_G.lastFreePage, "allocateOpMemory not called yet")
allocatedPages[_G.lastFreePage] = _c("low $")
;end
function setOrgAfterLastAllocated()
checkPage = _c("high opRoutines")
while allocatedPages[checkPage] do
lastAdr = checkPage*256 + allocatedPages[checkPage]
checkPage = checkPage + 2
;end
assert(lastAdr, "no memory was allocated yet")
_pc(string.format("org $%04x", lastAdr))
;end
endlua
;-----------------------------------------------------------------
; helper macros to make the lua calls one-liners in asm
macro allocateOpMemory _opcode?
@__allocateOpMemory_opcode = _opcode?
lua allpass
allocateOpMemory(_c("__allocateOpMemory_opcode"))
endlua
endm
macro finishOpAllocate
lua allpass
finishOpAllocate()
endlua
endm
;-----------------------------------------------------------------
; global definitions and variables used to generate jump table
; jump table with "high" bytes of opcode function addresses
opJpTab equ $7F00 ; must be 256B aligned, size 256B
; opcode functions will go into memory starting from $8000
opRoutines equ $8000 ; must be 256B aligned, size dynamic (N * 512)
; reset all Lua global variables ahead of each assembling pass
lua allpass
allocatedPages = {} -- reset allocated pages for every pass
lastFreePage = nil
endlua
;-----------------------------------------------------------------
; define opcode functions (builds also jump table and labels like "opcode_a1_impl")
allocateOpMemory 0
db 1, 2 ; fake "implementation" (just 1,2,3,4,... byte values)
finishOpAllocate
allocateOpMemory 1
db 3, 4, 5
finishOpAllocate
allocateOpMemory 2
db 6, 7, 8
finishOpAllocate
allocateOpMemory 3
db 9, 10
finishOpAllocate
allocateOpMemory 4
db 11
finishOpAllocate
allocateOpMemory 255
db 12, 13, 14, 15, "this goes over into page $8100..81FF"
finishOpAllocate
lua allpass
setOrgAfterLastAllocated()
endlua
;-----------------------------------------------------------------
; store result as binary blob for simple verification in hexa editor
align 512, 0 ; fill also last page to full 512B first
savebin "lua_build_jp_table.bin", opJpTab, $ - opJpTab
I think this should work reasonably well... I had to raise "page" size to 512B to avoid memory overwrites from last opcodes like FF (with 256B you have either only 1B in "current page", or you need to know that following "page" was used for bigger opcode and beginning of the area is unused. So the memory efficiency will be not very good, probably having multiple almost-256B free blocks between, but on the other hand you don't need to place them manually... So as long as you can exchange a bit of memory for a convenience, this should be fine.
NEO SPECTRUMAN
08.07.2019, 02:34
Вроде бы работает
JP-ы на вид ведут куда надо
условное компиляция на вид работает
будем пробовать это применить :v2_dizzy_dance:
NEO SPECTRUMAN
08.07.2019, 20:00
allocatedPages[_G.lastFreePage] = _c("low $")
С low $ не будет правильно работать!
нужно так
op_allocated_pages[_G.op_allocator_last_free_page] = (_c("$")-(_G.op_allocator_last_free_page*256))
(я у себя изменил названия всех переменных под стиль своего исходника)
while allocatedPages[freePage] and opcode < allocatedPages[freePage] do freePage = freePage + 2
это сильно не экономично!
lua_build_jp_table.asm
лучше переименовать в lua_build_fast_jp_table.asm
чтоб было очевидно что там не обычный вариант
и все таки нужно как то измерять количество байт в процедуре
между allocateOpMemory и finishOpAllocate
завести массив с минимальным начальным адресом в странице
чтобы можно было предотвратить перезапись кода
и переместить процедуру в следующую свободную страницу
https://jpegshare.net/images/3a/6e/3a6ea0b2c71301e937f2180cbe512bde.png
может будет проще
добавить средства генерации таких таблиц в сам sjasm?
например мне нужно будет делать несколько таких таблиц одновременно
при этом остается много места
куда можно было бы поместить другие процедуры
lua здесь уже не поможет
или нужно индексировать каждый байт
и искать свободное место немного по другому
https://jpegshare.net/images/b5/b9/b5b9287e1bc67c40989d1eb9984d0e34.png
чем другие граберы плохи?
NEO SPECTRUMAN
08.07.2019, 20:12
чем другие граберы плохи?
Shiny сначала вникни в суть проблемы...
...там еще некоторое обсуждение велось в личке
так что вникай сильней
за одно скажи видел ли ты где то такие таблицы переходов?
(именно ld h,(hl) а не кастрированный ld l,(hl) который иногда применяется)
(я не видел))
...там еще некоторое обсуждение велось в личке
так что вникай сильней
буду краток: не могу, у меня лапки.
за одно скажи видел ли ты где то такие таблицы переходов?
(именно ld h,(hl) а не кастрированный ld l,(hl) который иногда применяется)
(я не видел))
не помню. самое извратское, что я применял - стек для чанок.
например мне нужно будет делать несколько таких таблиц одновременно
при этом остается много места
куда можно было бы поместить другие процедуры
lua здесь уже не поможет
а написать процедуру религия не позволяет?
NEO SPECTRUMAN
08.07.2019, 21:13
а написать процедуру религия не позволяет?
конечно установщики это хорошо
НО
у меня куча условной компиляции и несколько вариантов процедур
256+ самих процедур
в данном случае заточено оно под 48к
и даже нет гуи все через конфигурацию переменных в начале исходника
нужно будет писать установщик уровня компилятора...
и места там нет
а что делать когда код генерируется на основе злобного матана с плавающей запятой?
еще скажи использовать вызовы процедур бейсика...
такой вариант мне не подходит...
С low $ не будет правильно работать!
Indeed, good catch. I will probably fix it by using _c("$&0x1F") in the official example, but your fix is correct too. (didn't verify my idea yet, but should be ok)
это сильно не экономично!
LUL. "... compiled: 119 lines, work time: 0.002 seconds" ... it's even less economic to comment on this point...
и все таки нужно как то измерять количество байт в процедуре
между allocateOpMemory и finishOpAllocate
I'm not sure if I understand you... while inside the opcode-function code, you can measure byte usage at any particular spot by `code_size = $ - opcode_XX_impl` where "XX" is hexa opcode in lowercase (i.e. "opcode_1a_impl" for opcode 26 == 0x1a)
I would need code size ahead before allocating memory for more optimal solutions, and that *is* problem. It can be probably worked around by defining each subroutine first as macro, and then assemble all of them twice, first time at $0000 to collect code size, second time at final destination. But such solution requires lot of cooperation, the macros for subroutines must be written in certain way, etc... not a prefect fit for generic example.
завести массив с минимальным начальным адресом в странице
чтобы можно было предотвратить перезапись кода
и переместить процедуру в следующую свободную страницу
*fresh new idea* Thinking about it... I can actually collect code-sizes during pass1 (unless the subroutine does something stupid with if/ifdef/dup to modify it's size between pass1 and pass3)... and use that info in pass2 and pass3 to create the final placement.
That should be possible with current sjasmplus, maybe I will try to create it as "version 2" somewhere in the future.
может будет проще
добавить средства генерации таких таблиц в сам sjasm?
I don't see how to fit that into sjasmplus in some nice versatile generic way. Also I already forgot all the "algorithm" stuff from the high school, so I can't even recall what was the optimal solution to "pack the boxes"... (can't even count how many times we had similar task at programming contests, hehe)
If somebody will show me some good designs, how to do it (I mean designs of everything: syntax, docs, algorithm), and it will be compatible with current implementation, then it may happen, but so far only very few people did any kind of "pull request" with new improvements, and people who want to try must be prepared that I will comment on their code a lot and it may take several iterations before the code will be accepted.
At this stage of development I don't want to spend my time on this, it's very specialized, while I have major general issues with labels, big memory and define substitutions.
например мне нужно будет делать несколько таких таблиц одновременно
при этом остается много места
куда можно было бы поместить другие процедуры
lua здесь уже не поможет
или нужно индексировать каждый байт
и искать свободное место немного по другому
Lua is full scripting programming language. If your requirements needs O(N*M*K*J) complex algorithm, then so be it. Who cares. We are talking about hundreds of subroutines. I.e. even some ugly brute force O(N^4) on modern CPU will take maybe 10s to generate final machine code. I don't care. In my paid work right now I have Android Studio and I'm forced to use corporate notebook with windows and antivirus, so only "clean" of the project needs 20+ seconds (on my home notebook with linux the "clean" of large projects takes usually between 0.5s to 3s and most of that is that f*cking gradle starting up), and full rebuild takes 4 to 7 minutes. If I would have project build times at 10s, I would be super happy.
The point is, that you *can* do it in Lua. You don't even need sjasmplus at all, you can just write machine code into file straight from the Lua script. It will be probably ugly and difficult to debug and maintain (the generator in Lua), and I would probably rather write it in C++, but stop crying in the way "it's not possible to do it in lua". It's just difficult and ugly, but by the Turing computational theory, if you can clearly (in computational way) specify the desired outcome, it surely can be calculated also in Lua. Or in Z80 machine code. Or in PHP. Or in hundreds of other programming languages.
The question is not if it is possible, but which tool is best fit. For such complex generators the sjasmplus is currently a bit cumbersome. If you can do it better in some other assembler, just use it. Programming languages, compilators and assemblers are just tools. Pick the best one for your current task.
And if you need more runtime memory, use ZX Spectrum Next ... :D ... 756kiB in base model, and some people will have them extended to 1.75MiB.... :P (or you can code for x86_64 and have gigabytes of memory available).
NEO SPECTRUMAN
09.07.2019, 00:26
756kiB in base model
православный zx evo имеет 4MB ;)
- - - Добавлено - - -
while inside the opcode-function code, you can measure byte usage at any particular spot by `code_size = $ - opcode_XX_impl` where "XX" is hexa opcode in lowercase (i.e. "opcode_1a_impl" for opcode 26 == 0x1a)
если измерять так
тогда боюсь мне не хватит 3 проходов компилятора...
You have basically only pass1 for any shenanigans. Pass2 should have already the same layout as pass3 (labels positions, machine code can differ).
As far as I can tell what you are trying to do (place routines into memory = different labels), at the beginning of pass2 you must already know precisely how you will generate the final code (in the same way, in both pass2 and pass3).
The N-pass will make this a bit more relaxed, that the requirement will be to have stable two passes (when lastpass == previouspass => finish assembling), but still it will have to happen in some reasonable amount of passes (probably configurable at command line).
I still believe the N-pass will be substantially less universal (= more limited) than Lua itself, which is full scripting language surpassing by far any limits of 3-pass or N-pass assembling. Although it's pain to write, and it's pain to read such code generators back, and try to guess how they work...
But maybe you have some nice idea for which the N-pass would be perfect fit, it's quite possible. The current 3-pass is sufficient only for simple straight assembler, any sort of more dynamic stuff is problematic.
NEO SPECTRUMAN
10.07.2019, 17:27
вроде бы написал какой то безобразие
которое индексирует каждый байт
ищет свободное место и втыкает туда процедуру...
https://jpegshare.net/images/42/10/42102767ab0a7218e72a3c02d1b83828.png
:v2_dizzy_tired2::v2_dizzy_vodka::v2_dizzy_wall::v 2_crazy::v2_dizzy_sleep2:
смайлики символизируют процесс написания...
задолбался перебирать pass1 pass2 pass3...
The UTF BOM markers are now detected and skipped.
Only UTF8 is of course "legal", UTF16/32 will cause fatal error, as the assembler is still 8bit ASCII only, with *some* support for the two DOS age Cyrillic encodings even for values, like DB "...". (The UTF8 Cyrillic characters are not correctly processed and will be NOT converted to target encoding (DOS 866, or some windows), i.e. UTF8 chars are legal only for comments or maybe for Lua parts, although not sure what you can do with them in Lua).
It's just support to not die on the UTF8 BOM, and to correctly warn user that UTF16/32 are completely off limits.
(pushed to github, will be released in next v1.13.3 ... which will happen no idea when, I'm thinking about adding few more small fixes, and release v1.13.3 maybe even next week, or maybe in another month... If you want it *now*, build from sources of course)
NEO SPECTRUMAN
16.07.2019, 03:38
PASS1 - interpret Lua script in first pass only.
PASS2 - interpret Lua script in second pass only.
PASS3 - interpret Lua script in third pass only. By default.
ALLPASS - interpret Lua script in all passes. It is need, if you generate some Z80 code.
не хватает
PASS1,2
PASS2,3
PASS1,3
приходиться дублировать один и тот же код!!!!!11111одинодинодин
или нужна глобальная переменная из которой можно прочитать текущее состояние
типа так
if sj_pass = 2...
You should always generate the same code in every pass. i.e. "ALLPASS" is usually the only correct setting (hmm, makes me wonder why it is not "default" if you write just "lua").
The PASS1 / PASS2 / PASS3 are special extras, if you know what you are doing (PASS1 is OK to define global variables and functions in lua, although with ALLPASS you will just redefine them every time = usually works too).
You can create the "pass" variable in lua like this:
lua pass1
lua_pass = 1
endlua
; ... some code
lua allpass
print("Lua pass: "..lua_pass)
lua_pass = lua_pass + 1
endlua
But you should generate the same code at the same positions in every pass.
If you understand how it internally works, you can get away by generating slightly different code in pass1 (the relative positions of labels must be valid already (and all labels must be emitted), but absolute positions in memory (and machine code emitted between) may change between pass1 and pass2, pass3 should be identical to pass2.
edit:
"приходиться дублировать один и тот же код!!!!!11111одинодинодин"
I think I now better understand what you mean, and you don't understand it correctly, it's not "adding" code, like you can generate some code in pass1, some in pass2 and final in pass3.
The assembler needs pretty much the identical source 3 times to produce correct machine code.
The pass1 can look somewhat different than final one, although already *all* [global] labels and ideally in correct relative order should be defined, only some absolute positions may change. pass2 should produce the same source as pass3, any difference there may cause unexpected results.
My comment about that dynamic allocator was going like this, to remember subroutine sizes from pass1 (where they would be allocated all into the same page, overwriting each other), and using that info at end of pass1 to calculate final positions for pass2 and pass3, but that must be done quite carefully to bend the assembling internal state correctly, to get correct machine code at end of pass3, it's a bit more advanced trick (you should probably read first source code of sjasmplus to understand how it works, before trying these kind of tricks).
edit2:
And if the N-pass will be added, that again does not mean you can add small bits of code in every pass, but it means that the dynamic source, which is seen by assembler (produced by lua/includes/dups/macros/...), must be identical between passN and pass(N-1). If you will keep changing the generated code, the N-pass will never finish assembling, as it waits for identical passes (well, it would error out on max-passes reached). So you need to design the dynamic parts like that, producing same source as early as possible (some difference between pass1 and pass2 are ok, some are not, pass2 and pass3 should be identical to be safe, although for example same-size opcode change like "nop" in pass2 vs "ret" in pass3 don't cause any harm, "ret" is produced in the final binary).
NEO SPECTRUMAN
17.07.2019, 22:15
вроде бы написал какой то безобразие
которое индексирует каждый байт
ищет свободное место и втыкает туда процедуру...
собственно вот
https://zx-pk.ru/threads/30694-vyravnivanie-utrambovyvanie-i-vpikhivanie-koda-bystrye-tablitsy-perekhodov-i-sjasm.html
https://github.com/z00m128/sjasmplus/releases/tag/v1.13.3
v1.13.3 changelog:
- bugfixes, new examples (check tests/lua_examples)
- UTF BOM are now detected, UTF8 BOM is silently skipped, UTF16/32 BOMs cause fatal error
- ZXSPECTRUMNEXT device is now initialized with whole memory zeroed (no more ZX48 sysvars)
- DEFL documented, "no forward reference" rule relaxed for EQU
- some error messages reworded to make them easier to comprehend
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
P.S.
I managed to set up "coverage" measuring in the project, and connected it with web service coveralls.io:
https://coveralls.io/github/z00m128/sjasmplus
I'm already at 81% for base sjasm sources (excluding lua/tolua++ which are external projects), which I find "not bad", but in following days I will now use the coverage data to see which parts of sjasmplus lack testing, and add tests where appropriate (my guess is the optimal coverage for this project should be somewhere in 90-95% range).
That will probably lead to few more bugfixes and release of few more v1.13.x versions of z00m's sjasmplus...
But I think there will be no v1.14, but v2.0 after that, which will have some changes in default settings, so old sources (used with v1.13.x) may not compile and will require some small changes to "fix" them. (I already managed to break few things between 1.10.4 and 1.13.3, but those compatibility issues were due to desperate situations where it was very difficult to maintain old behaviour ... in v2.x I will break few more only due to "better style/syntax" reasons)
So if you have some nice archive of sjasmplus projects, please test with v1.13.3 if they still work correctly, and report any bugs (if 1.13.3 fails and they work in v1.07 - v1.10.4 or in the mkoloberdin branch, try to read through "what's new" list in docs to see if your problem is actually announced change, like MAP removal back in v1.11 or when it was, etc).
I will certainly try to support v1.13.x even after I will start working on v2.0, but only bugfixes and similar, no major rewrites or new features.
The plans for v2.0 so far (may change easily):
- n-pass
- syntax tuned to be a bit more strict (similar to `--syntax=abf` in v1.13.3, but also with "keywords", so labels like "hl" will be not possible any more.
- DEFINE substitution even more formalized and documented, with the algorithm adjusted
- operators precedence changed to C++ precedence
- more operators and better support for "large" memory devices like 4MiB soviet machines or ZX Next
- some details here and there to make sjasmplus behave more similarly to common tools like gcc/clang (so various text editors supporting gcc/clang will probably work for sjasmplus reasonably well)
As the amount of changes is considerable, and will need probably months of effort, the v2.x may just as well never happen :D (because I often get distracted by other projects), so take the list and plans described above more like a "dream", not a "promise".
I still believe the sjasmplus v1.13.x is now very mature and solid tool, and can be used for Speccy SW development for another decade or two, even if we would release only few more bugfixes and nothing else.
Thank you for all the support so far, and keep the feedback coming, bugs reported, etc, it's very important part of the project, and you helped a lot already. Thank you all.
Can you add support of defining big text blocks in source?
Something like
LabelTXT DEFTXT
sometext
another text
blablabla
ENDDEFTXT
Can you add support of defining big text blocks in source?
Hmm... it's possible, but it will very likely have the limits of sjasmplus parser, i.e. max 2048 chars per line... Actually not, if I would add it, I would have to avoid regular read-buffered-line, because it does some very limited parsing to correctly read multi-line comment blocks and strings in quotes/apostrophes, and that's not something to be done in the big-text block, so I would definitely have to write second "read-input" code to avoid regular, and then it can be without those limits of regular parser.
Ok, so it's possible, and I will add it to my TODO.txt.
But I find it very low priority, because I don't see much point in it.
Are you aware that you can write your big-text in other file, like "scroller2.txt", and do in ASM source simple:
LabelTXT: INCBIN "scroller2.txt"
I find this workaround very reasonable, often maybe even better than having the text data directly in the ASM source (and I don't need to write whole new input-stream-reader :) ).
Let me know if you disagree or INCBIN solution doesn't fit your purpose, and let me know what is problematic (if you want the "big-text" feature to get higher priority).
With my current information about the issue, I will very likely keep it on the bottom of TODO list, so it may never happen or very lately.
In my project I have much text data (text dialogs). They not very big at once (may be 200b-3K for block), but their count big enough. And for each I need label to print text to screen. If I will use incbin, this would need for 500+ files to include.
I could wrote fulltext parser to get labels from text, but then I would have to solve problem where to store this labels and how to name them.
Demige, а что если попробовать на LUA написать аналог INCBIN. Назвать его INCTEXT. Пусть он работает так же как INCBIN, но строки текста заканчивающиеся особым знаком превращал в метки.
Тогда подсунув ему такой текст в файле Messages.txt:
Label1>>
Supertext
Message1>>
Game over!
Вызвав INCTEXT "Messages.txt",">>"
Он создаст две метки для двух текстов.
In my project I have much text data (text dialogs). They not very big at once (may be 200b-3K for block), but their count big enough. And for each I need label to print text to screen. If I will use incbin, this would need for 500+ files to include.
I could wrote fulltext parser to get labels from text, but then I would have to solve problem where to store this labels and how to name them.
I see, ok, this is the kind of stuff which makes big-text seem more important than I expected.
Some notes about possible workarounds with current sjasmplus version:
You can process data in device memory (reading them with { address } operator), but you can't easily build dynamic labels name from that, and values from memory can be read only in pass3, so the INCBIN+MACRO+DEFINE path would be very difficult to create some workaround, and it would probably not work well = unless I'm overlooking something, this is wrong approach.
Lua can add symbols (labels) (build dynamically, from file content for example) and can add bytes to the output (at least according to docs, I don't have these covered in tests, so you may find new bugs if you will try these, reporting them with example.asm will help me a lot). And there's probably a way in Lua to open text file and parse it, so you can implement your own INCTEXT as Reobne suggested, seems like good idea and should very likely work well (unless you run into some bug in sjasmplus). If you will go this route, and run into some problems, let me know, so we can fix it all.
Finally is the classic DB way *that* bad for these things?
Dialog1:
db "Hi", 13, 13
db "Some text.", 13
db "Next line.",0
; to get zero terminated text with ZX enter=13 newlines
Depending on your workflow and where the devtime is mostly spent, having external .txt file processed by lua may even bring some productivity boost and may make it easier for non-programmer people to contribute to your project, so the Lua workaround sounds to me quite good, maybe even better than native support for big-text blocks from sjasmplus, but it's more initial work to get that setup working.
(would be also nice example of lua usage, if you want to share it afterwards :), I can add it to the project tests/luaexamples)
Кажется получилось! :)
Вот пример. Он компилируется! Для проверки - просмотр в дебагере.
IncText_test.asm
DEVICE ZXSPECTRUM128
LUA PASS1
function inc_text(file_name,label_attr,line_terminator)
if line_terminator==nil then
l_t=13
else
l_t=line_terminator
end
for line in io.lines(file_name) do
if string.sub(line,1+string.len(line)-string.len(label_attr))==label_attr then
--print (string.sub(line,1,string.len(line)-string.len(label_attr)),sj.current_address)
sj.parse_line(string.sub(line,1,string.len(line)-string.len(label_attr)))
else
for i = 1,string.len(line) do
sj.add_byte(string.byte(line,i))
end
sj.add_byte(l_t)
end
end
end
ENDLUA
;----------------------------------------------------------------------
ORG #8000
START
LD HL,TT1
LD DE,TT2
LD IX,TT3
MainLoop
JP MainLoop
LUA ALLPASS
inc_text("test.txt",">>")
ENDLUA
SAVESNA "textovik.sna",START ;в папку unreal после компиляции сохранится снапшот для запуска в эмуляторе, содержащий программу, описанную сверху
Образец текста.
test.txt
TT1>>
Hello!!
Ready?
3
2
1
Go!
TT2>>
SOS!!!
TT3>>
GAME OVER
PRESS ANY KEY
Final>>
LD A,123>>
RLCA>>
JP Final>>
BYTE "SEVER",0,"BURAN",0>>
Как видите, можно добавлять через текст не только метки. ;)
Это моя первая "программа" на LUA, так что я готов к любой критике как стиля так и содержания. :)
NEO SPECTRUMAN
30.07.2019, 18:05
device
zxspectrum128\256\512\1024
slot 0
page 0
вообще работает?
slot 3
page 5
error: [PAGE] Page number must be in range 0..3
о_О
slot 1
page 5
error: [PAGE] Page number must be in range 0..3
:v2_dizzy_facepalm:
как вообще сохранить sna
с нужной включенной в slot 3 страницей?
а шо, у какого-то были такие девайсы?
NEO SPECTRUMAN
30.07.2019, 18:35
а шо, у какого-то были такие девайсы?
а шо другие sjasm-ы так ругаются?
для особо непонятливых
ZXSPECTRUM256
Same as russian clone Scorption 256. Has 16 RAM pages (0-15) with size 4000h.
ZXSPECTRUM512
Same as russian clones ATM Turbo 512 and Pentagon 512. Has 32 RAM pages (0-31) with size 4000h.
ZXSPECTRUM1024
Same as russian clones ATM Turbo 2 and Pentagon 1024 SL. Has 64 RAM pages (0-63) with size 4000h.
- - - Добавлено - - -
а шо, у какого-то были такие девайсы?
а еще есть пентевы с 256 страниц в любое окно...
которых нет в комплиторах....
а еще есть пентевы с 256 страниц в любое окно...
в тсконфе решалось SPG builder'ом.
NEO SPECTRUMAN
30.07.2019, 19:30
в тсконфе решалось SPG builder'ом.
а в не тс конфе не решается
да и sjasm больше метра не делает
а когда вопрос подымался
всех все устраивает
как я помню
а я спг делалку еще и дето потерял
- - - Добавлено - - -
да и другой версией
которая работает
не могу воспользоваться тк
error: [LUA] Maximum size of Lua script is 32768 bytes
:v2_dizzy_facepalm:
только sjasm от z00m
переваривает
- - - Добавлено - - -
а шо, у какого-то были такие девайсы?
https://zx-pk.ru/threads/4057-perepis-dejstvuyushchikh-quot-realov-quot/page6.html
а в не тс конфе не решается
беды индейцев шерифа не колышут. Что за глобальный проект ты задумал ?
device
...
вообще работает?
...
как вообще сохранить sna
с нужной включенной в slot 3 страницей?
Hm... maybe you should always post precise code which you were trying (or pastebin url, or something like that), because of course it *should* work, it's being tested with every commit: https://github.com/z00m128/sjasmplus/blob/master/tests/devices/zx128_default_pages.asm
... in multiple tests...: https://github.com/z00m128/sjasmplus/blob/master/tests/devices/zx48_and_128.asm
Can you make sure you are using v1.13+ for assembling? Basically you can do `sjasmplus --msg=lstlab file.asm 2> file.lst` and the first line will contain also sjasmplus version ... which is bug (it should produce listing only), which I discovered *now* thanks to you... thanks. :D
But otherwise I have no idea what is not working for you and why, probably some tiny detail, which we both missed.
About snapshot... well, I didn't check those yet, as I don't use them much (sometimes zx48 snapshots for quick tests of Next features, but never zx128).
So... looking a bit into io_snapshots.cpp now ... I don't like that code too much... basically seems like zx128 has stack fixed to 0x6000? Not sure, but I think both zx48 and zx128 devices get fake zx48 sysvars+stack, but then save snapshot checks for the fake stack in wrong page, so with 128 device it will always default to 0x6000 I believe (eventually I will probably write some tests to verify my guess, but not now, focusing on more important parts).
Then it writes into file short block with register values, then pages 5, 2 and current slot3 page (i.e. should work), then second small block of extra values (PC and I/O 7FFF page num), and finally it adds remaining pages of ZX128. Then it should display warning for any other device (non zx48/zx128), but it will not work, because it's using wrong device names and the whole logic of that code is stupid and error prone.
So, unless there are some bugs I didn't see when reading quickly through it, this should work:
https://github.com/z00m128/sjasmplus/blob/master/tests/devices/savesna_zx128.asm
DEVICE ZXSPECTRUM128
PAGE 5 ; btw this is VRAM page (and slot 3 is default)
ORG 0xC000
; so this code will be visible on screen
; and it will cause page 5 to be stored in snapshot twice, is this even legal? :D
start:
ld bc,0x07FE
.borderMess:
inc a
and b
out (c),a
jp .borderMess
SAVESNA "savesna_zx128.sna", start
And testing in #CSpect 2.9.2 -> reset into ZX Spectrum ROM ...
but CSpect is not the most accurate emulator, so one more try with ZEsarUX 8.0: 69681
Seems it works for me.
NEO SPECTRUMAN
30.07.2019, 19:56
:v2_conf2:
написал простую проверку
device zxspectrum128
slot 0
page 1
org $0000
l1 jp $C000
slot 3
page 5
savesna "test.sna",$C000
и все работает как нодо
но другой исходник
имеющий в конце
slot 3
page 5
savesna "sidplay.sna", start
ругаетсо...
xxx.asm(4538): error: [PAGE] Page number must be in range 0..3
xxx.asm(4540): warning: [SAVESNA] RAM <0x4000-0x4001> will be overriden due
to 48k snapshot imperfect format.
и в итоге slot 3 все время page 0
что не пиши...
щас попробую проредить исходник
и посмотрю что будет
BTW about outputting large files... keep in mind sjasmplus is ASSEMBLER ... it can emit MACHINE CODE ...
It would be very bad assembler, if it would be impossible to emit any machine code you need. And machine code is like binary data.
So if everything else fails (you want new file format which is not supported by sjasmplus), you can do also something like this:
OUTPUT "file.xyz"
DB "header bytes", 1, 2, 3, 4
DISP 0x4000
vram:
DB 1, 2, "... 6192 bytes in total"
ENT
DB "some other section bytes like crc or pages"
DISP 0xC000
start:
; some code
ENT
; ... etc
OUTEND ; close the file
This is not very practical for formats which use compression, or where you need to calculate many fields in the header, but for things like ROM images there shouldn't be any major problem to prepare binary images precisely to your liking.
Similarly, I did need something similar for the ZX Next, so I added support of NEX file format to sjasmplus (but took me 5 months longer than I expected, because whenever I take a look at that source, I find some bug... :/ ... instead of working on my projects...)
NEO SPECTRUMAN
30.07.2019, 20:05
трижды извиняюсь :v2_dizzy_wall:
нашел у себя багу
когда собирал несколько сорцов в один
один из них содержал
device zxspectrum48
в мало заметном месте
в итоге в какой то момент все компилировалось не так как надо
и сохраняло даже в 48к снапшоте...
написал простую проверку
device zxspectrum128
slot 0
page 1
...
savesna "test.sna",$C000
As far as I can tell, slot 0 is not part of snapshot files, but page 1 will be stored in the zx128 snapshot, so the data you prepared there, you can still page them in at regular zx128 bank at 0xC000 (or even to other slots on +3 machines, but I don't know details how those work). But slot 0 is considered ROM area by snapshot files (but that's not problem of sjasmplus, but limitation of the file format)
но другой исходник
slot 3
page 5
savesna "sidplay.sna", start
ругаетсо...
и в итоге slot 3 все время page 0
что не пиши...
щас попробую проредить исходник
и посмотрю что будет
Are you doing it sequentially? It's sort of like running code in ZX Spectrum.
I.e. you must do everything in correct steps:
1) select device (ZXSPECTRUM128)
2) select slot, select page (you can do it in single command `MMU 3, 5`)
3) use ORG to target the new page in that slot
4) produce the machine code (DB or instructions/macros/etc...)
5) savesna when the memory contains all machine code
BTW, *why* page 5? Why VRAM? This also damages sysvars. Are you intentionally picking the most fragile options, and then you wonder when things break? :D
NEO SPECTRUMAN
30.07.2019, 20:14
DISP 0x4000 vram: DB 1, 2, "... 6192 bytes in total" ENT DB "some other section bytes like crc or pages" DISP 0xC000
когда я последний раз пользовался disp
(на старой версии компилятора)
оказалось что оно с ошибками компилирует
уже не помню что именно
или не работали макросы и jp вели не туда куда надо
или lua генерировала код не по тем адресам
в конечном итоге
я этим disp больше не пользуюсь
может конечно его уже и починили...
- - - Добавлено - - -
As far as I can tell, slot 0 is not part of snapshot files, but page 1 will be stored in the zx128 snapshot, so the data you prepared there, you can still page them in at regular zx128 bank at 0xC000 (or even to other slots on +3 machines, but I don't know details how those work). But slot 0 is considered ROM area by snapshot files (but that's not problem of sjasmplus, but limitation of the file format)
page0 прекрасно подключается у злых русских в slot0
http://dev.speccy.info/index.php?title=%D0%A1%D1%82%D0%B0%D0%BD%D0%B4%D0% B0%D1%80%D1%82%D1%8B_%D1%83%D0%BF%D1%80%D0%B0%D0%B 2%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F_%D0%9E%D0%97%D0%A3 #Pentagon-1024
когда я последний раз пользовался disp
(на старой версии компилятора) ...
There was a serious bug when using DISP and crossing slot-boundary, the machine code was lost. I think I fixed it in v1.12.x or v1.13.0, not sure, and too lazy to check the changelog. (the other sjasmplus has this one fixed for many years, but it was still bugged in z00m's versions)
There is another issue of DISP inside DISP, which is not well defined in docs, and not well implemented: basically one you start DISP, the next change of "$" should be done by ORG, which will affect the DISP address, and I really don't like the current status, but so far I didn't have time to rewrite this, will be probably part of incompatible v2.x changes.
But otherwise it should work reasonably well, if you hit some problem, surely let me know, thank you. :)
(about Pentagon ... hey, slow down, I can hardly page the banks at regular ZX128, don't know how it works at +3, and the only thing I know about Soviet ZX clones is, that they exist ... or at least there are rumours ...)
I think few years ago, like in 2008 or so, I had brief period of checking ZX scene, and I tried to find some info, but everything is in azbuka and Russian, so that didn't go well... (now I'm using google translator to decipher messages in this thread, it usually makes about 70% understandable, the rest I ignore, but it's quite exhausting to chew through some of the personal chit-chat or sort-of-poetry, so sometimes I just give up and don't understand)
NEO SPECTRUMAN
30.07.2019, 20:33
ну а английском могу вспомнить разве что
мануал по АТМ-у
http://alonecoder.nedopc.com/zx/books/ATMHW.rar
For those who know how to build from github, can you please try the current version in master branch?
https://github.com/z00m128/sjasmplus/commits/master
It's now what will become "v1.14.0" during next week, I think I'm done with the development (just want to edit docs and prepare everything for release).
And this is, as I wrote earlier, one of the last "v1.x" versions of sjasmplus, where I was trying to keep backward compatibility as high as possible.
So if you can test it with your Z80 projects and see if everything still works (or requires only very minor changes), I would love to hear from you (also of course if you run into some problem).
After this I'm planning to start work on "v2.x", which will change some of the syntax rules, and most of the old sources will require some small changes to be compilable with v2.x, so I want the v1.14.x to be very solid, stable and good assembler, because it may be the last version usable for some legacy sources (if you don't want to update them to new changes). Thank you girls and guys. :)
(preliminary changelog for v1.14.0 from my work notes)
- INCLUDE bugfix, now searching paths according to original documentation (may break some projects)
- UNDEFINE had undocumented feature of removing also labels, removed (seemed broken beyond repair)
- R800 MULUB was producing wrong opcode all those years... fixed.
- MODULE names can't contain dot any more, MODULE/ENDMODULE resets non-local label to "_"
- expression evaluator was not stricly 32 bit (64b binaries could have produced different results than 32b binaries)
- accessing low memory addresses 0..255 directly emits warning
- several tests added to improve the code coverage: https://coveralls.io/github/z00m128/sjasmplus?branch=master
- as tests were added, minor bugs were found and squashed (errors wording, etc)
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.0
v1.14.0 changelog:
- INCLUDE bugfix, now searching paths according to original documentation (may break some projects)
- UNDEFINE had undocumented feature of removing also labels, cancelled (was broken beyond repair)
- R800 `MULUB` was producing wrong opcode all those years... fixed
- MODULE names can't contain dot any more! MODULE and ENDMODULE resets non-local label to "_"
- --syntax option: "m" (switch off low-mem access warning) and "M" added, "A" removed
- macro expansion can be inhibited by using "@" in front of instruction
- expression evaluator was not stricly 32 bit (64b binaries could have produced different results than 32b binaries)
- reading memory addresses 0..255 directly emits warning, use "; ok" comment to suppress it.
- several tests added to improve the code coverage: https://coveralls.io/github/z00m128/sjasmplus
- as tests were added, minor bugs were found and squashed (errors wording, etc)
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
Last time I wrote there will be no 1.14, but some bugfixes did change the behaviour of the assembler a bit more than I wished (may even break some old projects, although unlikely or they can be fixed very easily), so I moved from 1.13.
But the idea is still the same, this is one of the last 1.x versions and there will be bugfix-only on 1.x in the future. And I'm going soon to start the "2.x" branch (which will probably start as 1.90.0, releasing changes feature by feature, so you will be able to follow the development all the time, the 2.0 will be released when the changes with regard to syntax and behaviour will be finished and stabilized).
If you have some project which did work with v1.10+ and is broken with v1.14, let me know about the issue. It may still require some changes on the project (it was not my goal to stay 100% backward compatible), but the changes should be very small and simple to do.
If you have some non-upgrade issues, or feature requests, feel free to ask here, or add feature request in github.
Thank you for your support everyone, have a great time.
Кажется получилось! :)
...
In my project I have much text data (text dialogs).
...
I finally found a time to review Reobne's script, and it's excellent.
I did adjust it slightly (to detect markers at beginning of line) and few other minor changes, and added it as official lua example in the repository:
https://github.com/z00m128/sjasmplus/tree/master/tests/lua_examples (all the "lua_inctext" files/folder)
(for your project you need only the https://github.com/z00m128/sjasmplus/blob/master/tests/lua_examples/lua_inctext.lua file and "includelua" it in your ASM source, remaining files are part of example + test)
So the "inc_text" file can now look like this:
>>Text1
Hello!!
Ready?
>> DB 0 ; turn it into zero-terminated string by adding zero
>>Text2
SOS!!!
>> \_o_/
>>Text3
GAME OVER
PRESS ANY KEY
>>Final
>> RLCA
>> JP Final
>> BYTE "SEVER",0,"BURAN",0
It's still possible to use assembly lines in the file (just prepend them with the marker you want to use, default marker is ">>"), which I was at first a bit sceptical about, if I should keep it there, but after some thinking... it doesn't add any extra syntax to original text+labels thing, and it allows to insert short code or zero bytes after string like ">> DB 0". So I kept that feature there.
Also it did show bug in listing file of v1.14.0 (when bytes are emitted from lua, and parse_line is used too), so I fixed it, if you want "correct" listing like in the example, you will have to build sjasmplus from the github source (or get v1.14.1 release later, when it will be released).
So thank you again for your help with this, and for your patience, in the end it seems quite solid feature.
(BTW v1.14.1 probably soon, as the Microsoft VS builds were very broken and I managed to configure windows builds in the Cirrus CI, so now I can check myself if I did break the windows builds.. still a bit cumbersome, but better than no windows check at all, if you are building your own sjasmplus from sources and using VS, definitely avoid v1.14.0 and get fresh sources from github, there are many problems fixed for VS builds ... or just build with MinGW/MSYS2/etc, the GCC windows builds were OK all the time, just VS is difficult to maintain for me).
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.1
... just small bugfixes/polish, documentation refresh, etc... nothing important, if v1.14.0 is working for you, the v1.14.1 should do the same.
If you did want to build sjasmplus from sources (or debug it), with MS Visual Studio, then upgrade to v1.14.1 for sure, there were serious bugs in older versions, making VS builds crashing on some features. Now it should work mostly identically to official exe (built with MinGW GCC8.2), except few minor differences in `--fullpath` handling, etc..
edit: I'm very interested into any bug reports or issues, as the plan is still to make this one of the last v1.x releases, so I hope it will be rock solid stable, and everyone who needs Z80 assembler can use this version for many years without running into some trivial bug or getting damaged machine code from correct ASM source.
Checking my TODO: there is one open issue when you would try to assemble STDIN and literally input source code manually from console, then it needs many many Ctrl+D presses to finish the assembling (should work well when you just redirect some output of previous command to sjasmplus), and otherwise I am not aware of any "bug", everything else is "feature" :P :)
Вопрос: условия в макросах добавили или нет ещё?
Вопрос: условия в макросах добавили или нет ещё?
What do you mean precisely? The reasonably simple cases work for me, like:
; conditions_in_macro.asm
testCond MACRO arg1?, arg2?, arg3?
IF arg1?
DB arg2?
IF !arg1?
never happens
ENDIF
ELSE
DB arg3?
IF $8004 <= $
DB "..."
ELSE
jr nc,.localLabelInCondition + '!'
ENDIF
.localLabelInCondition
ENDIF
ENDM
DEVICE ZXSPECTRUM48 : ORG $8000
OUTPUT "conditions_in_macro.bin"
testCond 1, 'A', 'B' ; A
testCond 0, 'A', 'B' ; B0!
DB " " ; " "
testCond 0, 'C', 'D' ; D...
OUTEND
The binary contains expected "AB0! D..."
Maybe if you would combine them also with DUP and emit macro inside macro which has conditionals, etc... I'm not claiming it's 100% bug free, but AFAIK it works.
If you have some example of something what doesn't produce correct result, just post it here or open issue on github, thank you. :)
-----------------------------------------------------------------
EDIT: one thing "obviously" (if you know how sjasmplus works, hehe) does NOT work, you can't only start/end conditional block in macro, i.e. the whole block must belong to the same macro.. i.e. things like:
MyEndIf MACRO
ENDIF
ENDM
IF 1
nop
MyEndIf
will NOT work, and I don't have any plan to support them, not even in v2.x (I mean, they may happen by accident if I rewrite the parser in certain way and I was toying with that idea for a short while, but I don't find these important, actually opposite, seems like code smell).
edit2: unfortunately, similar logic does apply DUP/EDUP blocks and others, basically any block (dup-edup, if-endif, macro-endm) should be nested in other block fully, interleaving start/end of different types of blocks will in 99% not work... and that's something I'm thinking about for v2.x, to allow things like conditional EDUP, but it's very complicated, so rather do not expect this ever working. I'm also not completely convinced this is real limitation, so far I had never issues to organize my code around these rules, but as always, by posting real-world issue with real project helps tremendously to shift my bias... :)
slowly going toward 1.14.2 release... so far the changelog looks like this:
- added i8080 mode (--i8080 CLI option) (it's still Z80 Zilog syntax, just limited instruction set)
- small improvements/polish/extra-info in docs, INSTALL, README, few new tests added
- cmake script fix of SYSTEM_LUA=ON option, CirrusCI configs added for macOS and FreeBSD
- few fixes of memory leaks, invalid memory access, double free/delete, ...
Basically nothing important for ZX coder, no bugs affecting code were found in 1.14.1, so no fixes. Sayman also didn't respond, so I guess everything works well for him... (the code is now really well covered with tests, so I don't expect too many new bugs to be found, maybe in the parts which are not covered well like TRD and HOB functions, but I don't know anyone using those and I'm not familiar enough with those formats to write tests by myself, so if somebody is bored enough, sending me test similar to TAP/NEX may help to cover it more)
I think the release will be done in couple of weeks or a month, something like that (unless there will be some unexpected activity worth a delay).
NEO SPECTRUMAN
27.09.2019, 00:23
- added i8080 mode (--i8080 CLI option) (it's still Z80 Zilog syntax, just limited instruction set)
ура :v2_yahoo: :v2_dizzy_turn: :v2_dizzy_roll:
теперь будет проще адаптировать свои поделки к 8080
если ВНЕЗАПНО появиться такое желание :)
еще не тестировал
но по хорошему наверно надо чтоб
компиляция продолжалась до конца
и чтоб на z80, при этом, код был рабочим
но чтоб выкидывало ошибки
и номера строк где лежат z80 only команды
или же нужно 2 варианта режима i8080
при одном только предупреждения
а при втором уже пропуск z80 команд которых нет
- - - Добавлено - - -
Ped7g, а поддержка православного Sharp LR35902 случаем не планируется?
Ped7g, а поддержка православного Sharp LR35902 случаем не планируется?
The i8080 mode: it's actually still the same Z80 sjasmplus under, just not adding Z80 instructions into the string map at init (instructions like `rr` = "not recognized"), limiting registers (`ld i,a` is "illegal instruction", `ld a,i` will emit machine code of `ld a,0` with "label i not found"), and few more checks narrowing possible opcodes (`in a,(c)` = `in a,(N)` with "label c not found", etc..).
All of these types of errors are non-fatal, i.e. compilation will continue (machine code is usually not emitted for them, although if they can be interpreted as legit i8080 instruction with just missing symbol/label (i, r, ix, iy, c, ...), those get evaluated as zero immediate value and machine code with this zero value is emitted).
Check the listing files in `tests/i8080` for examples how the assembler is behaving and what/how errors are reported:
https://github.com/z00m128/sjasmplus/tree/master/tests/i8080
(you can still help to improve it with feedback, if you think something of that is really wrong and you have idea how to improve it ... I'm quite OK with the current status, if I imagine I have Z80 asm file I want to make i8080 compatible, the current state would give me enough info and errors to know what to change ... plus I don't want to spend too much time on this, for me i8080 is minimal priority, it got added because it was minimal work and with the tests in place I'm not too afraid to break the Z80/Z80N parts ... also the z80.cpp after heavy refactoring is not that difficult to modify for this i8080 support).
About LR35902 - that's a bit more difficult, as it is not only limiting Z80, but changing some small parts of it. I will take a look and try to asses the difficulty... As mentioned above, due to test coverage I'm not afraid to break Z80, so I can give it some try. But then again, sjasmplus is strongly Z80 oriented with pretty much everything hard-coded, so it may turn out to be clashing too much with current implementation, not worth the effort.
Also the i8080 was reviewed by M.Borik and Busy, who are very familiar with it, they are doing lot of work lately on the PMD-85 computer (old Czechoslovakia 8bit from the ZX era, based on i8080), having fun there.
Do you know somebody being very familiar of LR35902, like doing GameBoy games, etc, who would be able to review the sjasmplus after such change, and asses it's usability, suggest improvements, etc?
(I was doing myself GameBoy Advance games, that was already ARMv6 CPU, so I'm unfortunately not familiar with this Z80 variant)
- - - Updated - - -
Did check the differences... seems doable.. not sure about syntax of some specials (should `ld a,($FFxx)` be automagically assembled as `ldh a,($xx)` ?? I think *yes* .... but `ld a,(hl+)` would end as `ldi a,(hl)` probably, just like the same fake instruction in current sjasmplus, not supporting the "hl+" syntax? Is it "good enough"?)
And I definitely need some "guarantor", who would check all opcodes and encodings after me, as by a quick search with google I already run into few technical references which slightly disagree between themselves or there's some info missing. Also seems there're subtle differences between GB, GBP and GBC, although I guess the machine code is identical, just the HW reacts a bit differently to some instructions ("STOP 0" seems to be rather "STOP $nn" and gets extra functionality in GBC, if I'm reading it correctly)???
So, if you know about somebody deeply familiar with the GB/GBP/GBC intricacies, who's willing to "sponsor" the sjasmplus (by making thorough review of the test+listing files, and also by commenting on the proposed syntax, plus recommendations about usability, if something like OUTPUT / SAVEBIN is enough, or there's some common format which would be very helpful, etc.. i.e. what is common in other assemblers and people would really miss that if I do just crude sjasmplus conversion like i8080 is). ... This may be about 8-40h effort. If you can find somebody willing to do this, I can add the LR35902 mode too.
NEO SPECTRUMAN
27.09.2019, 11:01
I'm not afraid to break Z80, so I can give it some try. But then again, sjasmplus is strongly Z80 oriented with pretty much everything hard-coded, so it may turn out to be clashing too much with current implementation, not worth the effort.
можно сделать отдельный SJASMPLUSGB
и вообще убрать из него z80
SAVEBIN
думаю с экспортом проблем особых не будет
gb gbc файлы не имеют какого либо заголовка
там вроде просто лежат 16к страницы друг за другом подряд (плохо помню)
и самих mapper-ов всего штуки 3
правда в начале ПЗУ там кажется есть контрольная сумма
если она не совпадает по моему запуск не происходит
(я не знаю как она считается)
но на bgb такой .gb можно и запустить
и в нем же исправить контрольную сумму если что
а потом можно запускать где угодно
who would check all opcodes and encodings after me
by commenting on the proposed syntax
я предлагаю поддержать синтаксис который генерирует IDA
+ у меня есть некоторый дизассемблированный GB код полученный в IDA
и я мог бы сравнить и проверить результат
можно сделать отдельный SJASMPLUSGB
и вообще убрать из него z80
дa, можно. (BSD-3 license, open source). But not *me*.
я предлагаю поддержать синтаксис который генерирует IDA
+ у меня есть некоторый дизассемблированный GB код полученный в IDA
и я мог бы сравнить и проверить результат
Again, if anyone [else] wants to create it, I certainly can't stop him.
But as long as we are talking about extra option to the sjasmplus I'm helping to maintain, the syntax of sjasmplus is to stay basically without change.
Luckily I don't know IDA, so I have no idea what's different, so for me this kind of comments (without actual content) are easy to ignore. :)
My question was if `ldi a,(hl)` is "good enough" (people will use sjasmplus even with this), or the `ld a,(hl+)` *must* be supported to make people even consider using sjasmplus for GB dev.
If the syntax must be modified as whole, because GB devs will not accept sjasmplus syntax, then this leads nowhere, I don't have time/will to rewrite all of it, and then later to maintain it.
I can add few exceptions here and there, maybe even "(hl+)" and "(hl-)", but if that will happen, it will be probably treated as fixed string, requiring it to be used in source in literal way (no extra space inside/etc). But as long as we are talking about *me* adding it to *zoom128's* branch, it's sjasmplus Z80 syntax in 95%, plus few important exceptions (which you must describe in greater detail than "like IDA", that means nothing to me and I don't want to invest my time googling how IDA looks)
контрольная сумма
I guess this one can be easily implemented with some macro in `DEVICE ZXSPECTRUM48` mode, just like there were those macros to calculate XOR/ADD checksums before. Even if it needs more complex formula of checksum. Such macro can be added to tests/macro_examples folder, so you will just include the asm file from there for definition, and use the macro at proper place after you have the header data in device memory defined.
Meanwhile I did create a summary of the opcode differences, if somebody wants to check if I have them Oll Korrekt:
70111 (it's ODS spread sheet file, two sheets)
Basically it all boils down to somebody else investing their time to prepare the resources/details/info for me, so I don't need to waste my time on that. And after implementing it, again somebody else will have to review + check the result.
You seem to be actively helping with this, so if you think you can go all the way along from start to finish, then it may become real (just don't expect it to be super simple, to deal with me ;) ... I'm sometimes quite an ass ... and hole... :D )
NEO SPECTRUMAN
27.09.2019, 13:12
My question was if `ldi a,(hl)` is "good enough" (people will use sjasmplus even with this), or the `ld a,(hl+)` *must* be supported to make people even consider using sjasmplus for GB dev.
ну синтаксис IDA и bgb вообще предлагает использовать квадратные скобки
может по ним можно отличить gb код от z80
F0 F6 - ld a, [$FFF6] - IDA :v2_dizzy_facepalm:
FA B5 DB - ld a, [$DBB5] - IDA
F0 F6 - ldh a,[$FFF6] - bgb
FA B5 DB - ld a,[$DBB5] - bgb
но все равно придется проверять
есть ли обращение к FF page
- - - Добавлено - - -
насчет
LD A,($FF00+nn)
LD A,($FF00+C)
LD ($FF00+nn),A
LD ($FF00+C),A
LD HL,SP+nn
я немного позже уточню варианты написания
и где какие применяются
сейчас нет под рукой нужных средств чтобы быстро это проверить
- - - Добавлено - - -
My question was if `ldi a,(hl)` is "good enough" (people will use sjasmplus even with this), or the `ld a,(hl+)` *must* be supported to make people even consider using sjasmplus for GB dev.
по хорошему нужна полная поддержка синтаксиса IDA
чтоб про дизассемблированное в IDA можно было сразу скомпилировать
в IDA запихнут синтаксис от rgbasm-а
но сам rgbasm не пригоден к использованию
(так как редкостное ***** а не компилятор
я потратил сутки чтоб заставить его просто компилировать... )
то есть сейчас есть отличный дизассемблер (IDA)
но нет к нему нормального компилятора
...по крайней мере так было несколько лет назад :)
F0 F6 - ld a, [$FFF6] - IDA
FA B5 DB - ld a, [$DBB5] - IDA
good, that's sjasmplus compatible way (with adding magic detection of $FFxx for `ld a,(a16)` turning it into `ldh a,($xx)` = that's extra new code, but tiny one)
(adding `ldh` extra is also tiny work, such changes are generally OK and can be expected).
You can even enforce square brackets in sjasmplus with `--syntax=B` option .. which may be default for GB mode (?), by default the square brackets are only optional in sjasmplus.
LD A,($FF00+nn)
LD A,($FF00+C)
LD ($FF00+nn),A
LD ($FF00+C),A
LD HL,SP+nn
my first guess would be (in sjasmplus mostly compatible way, "easy" to add):
ldh a,[$xx] + ld a,[$ffxx] ; impossible to create 3byte `ld a,[$ffxx]` (except using `db` or other hack)
ldh a,[c] + ld a,[c] ; `ld a,[$ff00+c]` would be INVALID syntax, that's too much fuss, `ld a,[c]` must be enough
ldh [$xx],a + ld [$ffxx],a ; impossible to create 3byte `ld [$ffxx],a` (except using `db` or other hack)
ldh [c],a + ld [c],a
The `ld hl,sp+nn` is tricky ... if I don't need to follow other assemblers, then the simplest thing is to create extra mnemonics like `addhlsp $nn`
If I *must* follow some other assembler syntax, I need to first see it, to evaluate how much pain it will be.
`add sp,$nn` can use default syntax, needs just extra trap in implementation, but `add sp,anything` is invalid on Z80, so such trap will not clash with regular Z80 implementation, that's easy to add to add (pun intended).
.... in the end, I'm 100% sure the syntax will be "sjasmplus" tainted, not 100% compatible with other assemblers, but at least something like 99% would be nice.
EDIT: that "ld a,[$ffxx]" detections would happen after evaluation of the expression, i.e. you can write in source `ld a,[my_variable_in_ffxx_memory]` with regular label, and it will emit 2B opcode if the final result is in $FFxx range. ... but that means that you can not assemble regular `ld a,[a16]` opcode with $ffxx value, like for self-modify code, you will have to use `ld a,[0000..feff]` or `db $FA : dw your_ffxx_initial_value` to get the 3B encoding, otherwise the LD magic will collapse it to 2B encoding.
- - - Updated - - -
по хорошему нужна полная поддержка синтаксиса IDA
чтоб про дизассемблированное в IDA можно было сразу скомпилировать
It's usually impossible to directly compile the disassembled source. And when the syntax does pass and some binary is received, it's usually impossible to keep identical binary.
For example I would expect IDA do disassemble `FA 00 FF` as `ld a,[$FF00]`, but by assembling that back you will get `F0 00`.
That's a common problem with disassembling + assembling machine code on all platforms, and I have zero will to pursue "perfect" results, that's not the point of assembler. Besides that you can always use the original source, and modify that, no need to disassemble any good SW (because good SW comes with sources .. if it doesn't have sources, it's not GOOD .... max OK-ish, but not good+). :) (yes, I'm kinda radical in this).
So all your IDA examples, etc... keep in mind it will work in 90-99% cases only and that's what I would try to achieve, but it will never be 100% binary identical, there will be always a way to derail the IDA+sjasmplusGB tooling into producing different binary. And I don't care, that's not a real issue for real good SW. :)
So the effort is to get as close as possible. Let's say in ideal case any IDA source will assemble to *expected binary* (even if different from original), i.e. the syntax will be mostly understood. And if even that will be too much pain, some instructions may need hand-patching to "fix" their syntax.
(*expected binary* = from the source you will be able to tell, how the binary will look, i.e. stable machine code is produced, no random variants... if the produced binary is not identical to original, then it will be different in every assembling, and you can tell already from the source, that the resulting machine code will differ ... there should be no "surprise" involved).
- - - Updated - - -
... so.. if you can produce examples of all GB specific instructions, how they are disassembled by IDA, it will help to see, how compatible it is with sjasmplus...
You can use that spreadsheet in my post to see which instructions are different, and disassemble those for me. The identical instructions will simply use current sjasmplus syntax. If you know about case where that is not compatible with IDA, let me know, it's a good info. I may then decide to either change the sjasmplus, or simply be not compatible with IDA.
But so far (square brackets) the IDA syntax is sjasmplus compatible.
NEO SPECTRUMAN
28.09.2019, 02:42
;IDA bgb GBCPUman.pdf
defb $3E,0 ;ld a,0 ld a,$00 LD A,n
defb $06,0 ;ld b,0 ld b,$00 LD B,n
defb $0E,0 ;ld c,0 ld c,$00 LD C,n
defb $16,0 ;ld d,0 ld d,$00 LD D,n
defb $1E,0 ;ld e,0 ld e,$00 LD E,n
defb $26,0 ;ld h,0 ld h,$00 LD H,n
defb $2E,0 ;ld l,0 ld l,$00 LD L,n
defb $7F ;ld a,a ld a,a LD A,A
defb $78 ;ld a,b ld a,b LD A,B
defb $79 ;ld a,c ld a,c LD A,C
defb $7A ;ld a,d ld a,d LD A,D
defb $7B ;ld a,e ld a,e LD A,E
defb $7C ;ld a,h ld a,h LD A,H
defb $7D ;ld a,l ld a,l LD A,L
defb $47 ;ld b,a ld b,a LD B,A
defb $40 ;ld b,b ld b,b LD B,B
defb $41 ;ld b,c ld b,c LD B,C
defb $42 ;ld b,d ld b,d LD B,D
defb $43 ;ld b,e ld b,e LD B,E
defb $44 ;ld b,h ld b,h LD B,H
defb $45 ;ld b,l ld b,l LD B,L
defb $4F ;ld c,a ld c,a LD C,A
defb $48 ;ld c,b ld c,b LD C,B
defb $49 ;ld c,c ld c,c LD C,C
defb $4A ;ld c,d ld c,d LD C,D
defb $4B ;ld c,e ld c,e LD C,E
defb $4C ;ld c,h ld c,h LD C,H
defb $4D ;ld c,l ld c,l LD C,L
defb $57 ;ld d,a ld d,a LD D,A
defb $50 ;ld d,b ld d,b LD D,B
defb $51 ;ld d,c ld d,c LD D,C
defb $52 ;ld d,d ld d,d LD D,D
defb $53 ;ld d,e ld d,e LD D,E
defb $54 ;ld d,h ld d,h LD D,H
defb $55 ;ld d,l ld d,l LD D,L
defb $5F ;ld e,a ld e,a LD E,A
defb $58 ;ld e,b ld e,b LD E,B
defb $59 ;ld e,c ld e,c LD E,C
defb $5A ;ld e,d ld e,d LD E,D
defb $5B ;ld e,e ld e,e LD E,E
defb $5C ;ld e,h ld e,h LD E,H
defb $5D ;ld e,l ld e,l LD E,L
defb $67 ;ld h,a ld h,a LD H,A
defb $60 ;ld h,b ld h,b LD H,B
defb $61 ;ld h,c ld h,c LD H,C
defb $62 ;ld h,d ld h,d LD H,D
defb $63 ;ld h,e ld h,e LD H,E
defb $64 ;ld h,h ld h,h LD H,H
defb $65 ;ld h,l ld h,l LD H,L
defb $6F ;ld l,a ld l,a LD L,A
defb $68 ;ld l,b ld l,b LD L,B
defb $69 ;ld l,c ld l,c LD L,C
defb $6A ;ld l,d ld l,d LD L,D
defb $6B ;ld l,e ld l,e LD L,E
defb $6C ;ld l,h ld l,h LD L,H
defb $6D ;ld l,l ld l,l LD L,L
defb $77 ;ld [hl],a ld [hl],a LD (HL),A
defb $70 ;ld [hl],b ld [hl],b LD (HL),B
defb $71 ;ld [hl],c ld [hl],c LD (HL),C
defb $72 ;ld [hl],d ld [hl],d LD (HL),D
defb $73 ;ld [hl],e ld [hl],e LD (HL),E
defb $74 ;ld [hl],h ld [hl],h LD (HL),H
defb $75 ;ld [hl],l ld [hl],l LD (HL),L
defb $36,0 ;ld [hl],0 ld [hl],$00 LD (HL),n
defb $7E ;ld a,[hl] ld a,[hl] LD A,(HL)
defb $46 ;ld b,[hl] ld b,[hl] LD B,(HL)
defb $4E ;ld c,[hl] ld c,[hl] LD C,(HL)
defb $56 ;ld d,[hl] ld d,[hl] LD D,(HL)
defb $5E ;ld e,[hl] ld e,[hl] LD E,(HL)
defb $66 ;ld h,[hl] ld h,[hl] LD H,(HL)
defb $6E ;ld l,[hl] ld l,[hl] LD L,(HL)
defb $0A ;ld a,[bc] ld a,[bc] LD A,(BC)
defb $1A ;ld a,[de] ld a,[de] LD A,(DE)
defb $02 ;ld [bc],a ld [bc],a LD (BC),A
defb $12 ;ld [de],a ld [de],a LD (DE),A
defb $FA,0,0 ;ld a,[0] ld a,[$0000] LD A,(nn) !!!! different opcode
defb $EA,0,0 ;ld [0],a ld [$0000],a LD (nn),A !!!! different opcode
defb $F2 ;ld a,[c] ld a,[$ff00+c] LD A,(C) \ LD A,($FF00+C) !!!!!!
defb $E2 ;ld [c], a ld [$ff00+c],a ld (C),A \ LD ($FF00+C),A !!!!!!
defb $3A ;ldd a,[hl] ldd a,[hl] LD A,(HLD) \ LDD A,(HL) \ LD A,(HL-)
defb $2A ;ldi a,[hl] ldi a,[hl] LD A,(HLI) \ LDI A,(HL) \ LD A,(HL+)
defb $32 ;ldd [hl],a ldd [hl],a LD (HLD),A \ LDD (HL),A \ LD (HL-),A
defb $22 ;ldi [hl],a ldi [hl],a LD (HLI),A \ LDI (HL),A \ LD (HL+),A
defb $F0,0 ;ld a,[$FF00] ldh a,[$FF00] LDH A,(n) \ LD A,($FF00+n)
defb $E0,0 ;ld [$FF00],a ldh [$FF00],a LDH (n),A \ LD ($FF00+n),A
defb $01,0,0 ;ld bc,0 ld bc,$0000 LD BC,nn
defb $11,0,0 ;ld de,0 ld de,$0000 LD DE,nn
defb $21,0,0 ;ld hl,0 ld hl,$0000 LD HL,nn
defb $31,0,0 ;ld sp,0 ld sp,$0000 LD SP,nn
defb $F9 ;ld sp,hl ld sp,hl LD SP,HL
defb $F8,0 ;ld hl,sp+0 ld hl,[sp+$00] LD HL,SP+n \ LDHL SP,n !!!!!!!!
defb $08,0,0 ;ld [0],sp ld [$0000],sp LD (nn),SP
defb $F5 ;push af push af PUSH AF
defb $C5 ;push bc push bc PUSH BC
defb $D5 ;push de push de PUSH DE
defb $E5 ;push hl push hl PUSH HL
defb $F1 ;pop af pop af POP AF
defb $C1 ;pop bc pop bc POP BC
defb $D1 ;pop de pop de POP DE
defb $E1 ;pop hl pop hl POP HL
defb $87 ;add a,a add a ADD A,A
defb $80 ;add a,b add b ADD A,B
defb $81 ;add a,c add c ADD A,C
defb $82 ;add a,d add d ADD A,D
defb $83 ;add a,e add e ADD A,E
defb $84 ;add a,h add h ADD A,H
defb $85 ;add a,l add l ADD A,L
defb $8F ;adc a,a adc a ADC A,A
defb $88 ;adc a,b adc b ADC A,B
defb $89 ;adc a,c adc c ADC A,C
defb $8A ;adc a,d adc d ADC A,D
defb $8B ;adc a,e adc e ADC A,E
defb $8C ;adc a,h adc h ADC A,H
defb $8D ;adc a,l adc l ADC A,L
defb $97 ;sub a sub a SUB A
defb $90 ;sub b sub b SUB B
defb $91 ;sub c sub c SUB C
defb $92 ;sub d sub d SUB D
defb $93 ;sub e sub e SUB E
defb $94 ;sub h sub h SUB H
defb $95 ;sub l sub l SUB L
defb $9F ;sbc a,a sbc a SBC A,A
defb $98 ;sbc a,b sbc b SBC A,B
defb $99 ;sbc a,c sbc c SBC A,C
defb $9A ;sbc a,d sbc d SBC A,D
defb $9B ;sbc a,e sbc e SBC A,E
defb $9C ;sbc a,h sbc h SBC A,H
defb $9D ;sbc a,l sbc l SBC A,L
defb $A7 ;and a and a AND A
defb $A0 ;and b and b AND B
defb $A1 ;and c and c AND C
defb $A2 ;and d and d AND D
defb $A3 ;and e and e AND E
defb $A4 ;and h and h AND H
defb $A5 ;and l and l AND L
defb $B7 ;or a or a OR A
defb $B0 ;or b or b OR B
defb $B1 ;or c or c OR C
defb $B2 ;or d or d OR D
defb $B3 ;or e or e OR E
defb $B4 ;or h or h OR H
defb $B5 ;or l or l OR L
defb $AF ;xor a xor a XOR A
defb $A8 ;xor b xor b XOR B
defb $A9 ;xor c xor c XOR C
defb $AA ;xor d xor d XOR D
defb $AB ;xor e xor e XOR E
defb $AC ;xor h xor h XOR H
defb $AD ;xor l xor l XOR L
defb $BF ;cp a cp a CP A
defb $B8 ;cp b cp b CP B
defb $B9 ;cp c cp c CP C
defb $BA ;cp d cp d CP D
defb $BB ;cp e cp e CP E
defb $BC ;cp h cp h CP H
defb $BD ;cp l cp l CP L
defb $3C ;inc a inc a INC A
defb $04 ;inc b inc b INC B
defb $0C ;inc c inc c INC C
defb $14 ;inc d inc d INC D
defb $1C ;inc e inc e INC E
defb $24 ;inc h inc h INC H
defb $2C ;inc l inc l INC L
defb $3D ;dec a dec a DEC A
defb $05 ;dec b dec b DEC B
defb $0D ;dec c dec c DEC C
defb $15 ;dec d dec d DEC D
defb $1D ;dec e dec e DEC E
defb $25 ;dec h dec h DEC H
defb $2D ;dec l dec l DEC L
defb $86 ;add a,[hl] add [hl] ADD A,(HL)
defb $8E ;adc a,[hl] adc [hl] ADC A,(HL)
defb $96 ;sub [hl] sub [hl] SUB (HL)
defb $9E ;sbc a,[hl] sbc [hl] SBC A,(HL)
defb $A6 ;and [hl] and [hl] AND (HL)
defb $B6 ;or [hl] or [hl] OR (HL)
defb $AE ;xor [hl] xor [hl] XOR (HL)
defb $BE ;cp [hl] cp [hl] CP (HL)
defb $34 ;inc [hl] inc [hl] INC (HL)
defb $35 ;dec [hl] dec [hl] DEC (HL)
defb $C6,0 ;add a,0 add a,$00 ADD A,n
defb $CE,0 ;adc a,0 adc a,$00 ADC A,n
defb $D6,0 ;sub 0 sub a,$00 SUB n
defb $DE,0 ;sbc a,0 sbc a,$00 SBC A,n
defb $E6,0 ;and 0 and a,$00 AND n
defb $F6,0 ;or 0 or a,$00 OR n
defb $EE,0 ;xor 0 xor a,$00 XOR n
defb $FE,0 ;cp 0 cp a,$00 CP n
defb $09 ;add hl,bc add hl,bc ADD HL,BC
defb $19 ;add hl,de add hl,de ADD HL,DE
defb $29 ;add hl,hl add hl,hl ADD HL,HL
defb $39 ;add hl,sp add hl,sp ADD HL,SP
defb $E8,0 ;add sp,0 add sp,$00 ADD SP,n
defb $03 ;inc bc inc bc INC BC
defb $13 ;inc de inc de INC DE
defb $23 ;inc hl inc hl INC HL
defb $33 ;inc sp inc sp INC SP
defb $0B ;dec bc dec bc DEC BC
defb $1B ;dec de dec de DEC DE
defb $2B ;dec hl dec hl DEC HL
defb $3B ;dec sp dec sp DEC SP
defb $CB,$37 ;swap a swap a SWAP A
defb $CB,$30 ;swap b swap b SWAP B
defb $CB,$31 ;swap c swap c SWAP C
defb $CB,$32 ;swap d swap d SWAP D
defb $CB,$33 ;swap e swap e SWAP E
defb $CB,$34 ;swap h swap h SWAP H
defb $CB,$35 ;swap l swap l SWAP L
defb $CB,$36 ;swap [hl] swap [hl] SWAP (HL)
defb $27 ;daa daa DAA
defb $2F ;cpl cpl CPL
defb $3F ;ccf ccf CCF
defb $37 ;scf scf SCF
defb $00 ;nop nop NOP
defb $76 ;halt halt HALT
defb $10,$00 ;stop stop STOP
defb $F3 ;di di DI
defb $FB ;ei ei EI
defb $07 ;rlca rlca RLCA
defb $17 ;rla rla RLA
defb $0F ;rrca rrca RRCA
defb $1F ;rra rra RRA
defb $CB,$07 ;rlc a rlc a RLC A
defb $CB,$00 ;rlc b rlc b RLC B
defb $CB,$01 ;rlc c rlc c RLC C
defb $CB,$02 ;rlc d rlc d RLC D
defb $CB,$03 ;rlc e rlc e RLC E
defb $CB,$04 ;rlc h rlc h RLC H
defb $CB,$05 ;rlc l rlc l RLC L
defb $CB,$17 ;rl a rl a RL A
defb $CB,$10 ;rl b rl b RL B
defb $CB,$11 ;rl c rl c RL C
defb $CB,$12 ;rl d rl d RL D
defb $CB,$13 ;rl e rl e RL E
defb $CB,$14 ;rl h rl h RL H
defb $CB,$15 ;rl l rl l RL L
defb $CB,$0F ;rrc a rrc a RRC A
defb $CB,$08 ;rrc b rrc b RRC B
defb $CB,$09 ;rrc c rrc c RRC C
defb $CB,$0A ;rrc d rrc d RRC D
defb $CB,$0B ;rrc e rrc e RRC E
defb $CB,$0C ;rrc h rrc h RRC H
defb $CB,$0D ;rrc l rrc l RRC L
defb $CB,$1F ;rr a rr a RR A
defb $CB,$18 ;rr b rr b RR B
defb $CB,$19 ;rr c rr c RR C
defb $CB,$1A ;rr d rr d RR D
defb $CB,$1B ;rr e rr e RR E
defb $CB,$1C ;rr h rr h RR H
defb $CB,$1D ;rr l rr l RR L
defb $CB,$27 ;sla a sla a SLA A
defb $CB,$20 ;sla b sla b SLA B
defb $CB,$21 ;sla c sla c SLA C
defb $CB,$22 ;sla d sla d SLA D
defb $CB,$23 ;sla e sla e SLA E
defb $CB,$24 ;sla h sla h SLA H
defb $CB,$25 ;sla l sla l SLA L
defb $CB,$2F ;sra a sra a SRA A
defb $CB,$28 ;sra b sra b SRA B
defb $CB,$29 ;sra c sra c SRA C
defb $CB,$2A ;sra d sra d SRA D
defb $CB,$2B ;sra e sra e SRA E
defb $CB,$2C ;sra h sra h SRA H
defb $CB,$2D ;sra l sra l SRA L
defb $CB,$3F ;srl a srl a SRL A
defb $CB,$38 ;srl b srl b SRL B
defb $CB,$39 ;srl c srl c SRL C
defb $CB,$3A ;srl d srl d SRL D
defb $CB,$3B ;srl e srl e SRL E
defb $CB,$3C ;srl h srl h SRL H
defb $CB,$3D ;srl l srl l SRL L
defb $CB,$06 ;rlc [hl] rlc [hl] RLC (HL)
defb $CB,$16 ;rl [hl] rl [hl] RL (HL)
defb $CB,$0E ;rrc [hl] rrc [hl] RRC (HL)
defb $CB,$1E ;rr [hl] rr [hl] RR (HL)
defb $CB,$26 ;sla [hl] sla [hl] SLA (HL)
defb $CB,$2E ;sra [hl] sra [hl] SRA (HL)
defb $CB,$3E ;srl [hl] srl [hl] SRL (HL)
defb $CB,$47 ;bit 0,a bit 0,a BIT 0,A
defb $CB,$40 ;bit 0,b bit 0,b BIT 0,B
defb $CB,$41 ;bit 0,c bit 0,c BIT 0,C
defb $CB,$42 ;bit 0,d bit 0,d BIT 0,D
defb $CB,$43 ;bit 0,e bit 0,e BIT 0,E
defb $CB,$44 ;bit 0,h bit 0,h BIT 0,H
defb $CB,$45 ;bit 0,l bit 0,l BIT 0,L
defb $CB,$47+$08 ;bit 1,a bit 1,a BIT 1,A
defb $CB,$40+$08 ;bit 1,b bit 1,b BIT 1,B
defb $CB,$41+$08 ;bit 1,c bit 1,c BIT 1,C
defb $CB,$42+$08 ;bit 1,d bit 1,d BIT 1,D
defb $CB,$43+$08 ;bit 1,e bit 1,e BIT 1,E
defb $CB,$44+$08 ;bit 1,h bit 1,h BIT 1,H
defb $CB,$45+$08 ;bit 1,l bit 1,l BIT 1,L
defb $CB,$47+$10 ;bit 2,a bit 2,a BIT 2,A
defb $CB,$40+$10 ;bit 2,b bit 2,b BIT 2,B
defb $CB,$41+$10 ;bit 2,c bit 2,c BIT 2,C
defb $CB,$42+$10 ;bit 2,d bit 2,d BIT 2,D
defb $CB,$43+$10 ;bit 2,e bit 2,e BIT 2,E
defb $CB,$44+$10 ;bit 2,h bit 2,h BIT 2,H
defb $CB,$45+$10 ;bit 2,l bit 2,l BIT 2,L
defb $CB,$47+$18 ;bit 3,a bit 3,a BIT 3,A
defb $CB,$40+$18 ;bit 3,b bit 3,b BIT 3,B
defb $CB,$41+$18 ;bit 3,c bit 3,c BIT 3,C
defb $CB,$42+$18 ;bit 3,d bit 3,d BIT 3,D
defb $CB,$43+$18 ;bit 3,e bit 3,e BIT 3,E
defb $CB,$44+$18 ;bit 3,h bit 3,h BIT 3,H
defb $CB,$45+$18 ;bit 3,l bit 3,l BIT 3,L
defb $CB,$47+$20 ;bit 4,a bit 4,a BIT 4,A
defb $CB,$40+$20 ;bit 4,b bit 4,b BIT 4,B
defb $CB,$41+$20 ;bit 4,c bit 4,c BIT 4,C
defb $CB,$42+$20 ;bit 4,d bit 4,d BIT 4,D
defb $CB,$43+$20 ;bit 4,e bit 4,e BIT 4,E
defb $CB,$44+$20 ;bit 4,h bit 4,h BIT 4,H
defb $CB,$45+$20 ;bit 4,l bit 4,l BIT 4,L
defb $CB,$47+$28 ;bit 5,a bit 5,a BIT 5,A
defb $CB,$40+$28 ;bit 5,b bit 5,b BIT 5,B
defb $CB,$41+$28 ;bit 5,c bit 5,c BIT 5,C
defb $CB,$42+$28 ;bit 5,d bit 5,d BIT 5,D
defb $CB,$43+$28 ;bit 5,e bit 5,e BIT 5,E
defb $CB,$44+$28 ;bit 5,h bit 5,h BIT 5,H
defb $CB,$45+$28 ;bit 5,l bit 5,l BIT 5,L
defb $CB,$47+$30 ;bit 6,a bit 6,a BIT 6,A
defb $CB,$40+$30 ;bit 6,b bit 6,b BIT 6,B
defb $CB,$41+$30 ;bit 6,c bit 6,c BIT 6,C
defb $CB,$42+$30 ;bit 6,d bit 6,d BIT 6,D
defb $CB,$43+$30 ;bit 6,e bit 6,e BIT 6,E
defb $CB,$44+$30 ;bit 6,h bit 6,h BIT 6,H
defb $CB,$45+$30 ;bit 6,l bit 6,l BIT 6,L
defb $CB,$47+$38 ;bit 7,a bit 7,a BIT 7,A
defb $CB,$40+$38 ;bit 7,b bit 7,b BIT 7,B
defb $CB,$41+$38 ;bit 7,c bit 7,c BIT 7,C
defb $CB,$42+$38 ;bit 7,d bit 7,d BIT 7,D
defb $CB,$43+$38 ;bit 7,e bit 7,e BIT 7,E
defb $CB,$44+$38 ;bit 7,h bit 7,h BIT 7,H
defb $CB,$45+$38 ;bit 7,l bit 7,l BIT 7,L
defb $CB,$C7 ;set 0,a set 0,a SET 0,A
defb $CB,$C0 ;set 0,b set 0,b SET 0,B
defb $CB,$C1 ;set 0,c set 0,c SET 0,C
defb $CB,$C2 ;set 0,d set 0,d SET 0,D
defb $CB,$C3 ;set 0,e set 0,e SET 0,E
defb $CB,$C4 ;set 0,h set 0,h SET 0,H
defb $CB,$C5 ;set 0,l set 0,l SET 0,L
defb $CB,$C7+$08 ;set 1,a set 1,a SET 1,A
defb $CB,$C0+$08 ;set 1,b set 1,b SET 1,B
defb $CB,$C1+$08 ;set 1,c set 1,c SET 1,C
defb $CB,$C2+$08 ;set 1,d set 1,d SET 1,D
defb $CB,$C3+$08 ;set 1,e set 1,e SET 1,E
defb $CB,$C4+$08 ;set 1,h set 1,h SET 1,H
defb $CB,$C5+$08 ;set 1,l set 1,l SET 1,L
defb $CB,$C7+$10 ;set 2,a set 2,a SET 2,A
defb $CB,$C0+$10 ;set 2,b set 2,b SET 2,B
defb $CB,$C1+$10 ;set 2,c set 2,c SET 2,C
defb $CB,$C2+$10 ;set 2,d set 2,d SET 2,D
defb $CB,$C3+$10 ;set 2,e set 2,e SET 2,E
defb $CB,$C4+$10 ;set 2,h set 2,h SET 2,H
defb $CB,$C5+$10 ;set 2,l set 2,l SET 2,L
defb $CB,$C7+$18 ;set 3,a set 3,a SET 3,A
defb $CB,$C0+$18 ;set 3,b set 3,b SET 3,B
defb $CB,$C1+$18 ;set 3,c set 3,c SET 3,C
defb $CB,$C2+$18 ;set 3,d set 3,d SET 3,D
defb $CB,$C3+$18 ;set 3,e set 3,e SET 3,E
defb $CB,$C4+$18 ;set 3,h set 3,h SET 3,H
defb $CB,$C5+$18 ;set 3,l set 3,l SET 3,L
defb $CB,$C7+$20 ;set 4,a set 4,a SET 4,A
defb $CB,$C0+$20 ;set 4,b set 4,b SET 4,B
defb $CB,$C1+$20 ;set 4,c set 4,c SET 4,C
defb $CB,$C2+$20 ;set 4,d set 4,d SET 4,D
defb $CB,$C3+$20 ;set 4,e set 4,e SET 4,E
defb $CB,$C4+$20 ;set 4,h set 4,h SET 4,H
defb $CB,$C5+$20 ;set 4,l set 4,l SET 4,L
defb $CB,$C7+$28 ;set 5,a set 5,a SET 5,A
defb $CB,$C0+$28 ;set 5,b set 5,b SET 5,B
defb $CB,$C1+$28 ;set 5,c set 5,c SET 5,C
defb $CB,$C2+$28 ;set 5,d set 5,d SET 5,D
defb $CB,$C3+$28 ;set 5,e set 5,e SET 5,E
defb $CB,$C4+$28 ;set 5,h set 5,h SET 5,H
defb $CB,$C5+$28 ;set 5,l set 5,l SET 5,L
defb $CB,$C7+$30 ;set 6,a set 6,a SET 6,A
defb $CB,$C0+$30 ;set 6,b set 6,b SET 6,B
defb $CB,$C1+$30 ;set 6,c set 6,c SET 6,C
defb $CB,$C2+$30 ;set 6,d set 6,d SET 6,D
defb $CB,$C3+$30 ;set 6,e set 6,e SET 6,E
defb $CB,$C4+$30 ;set 6,h set 6,h SET 6,H
defb $CB,$C5+$30 ;set 6,l set 6,l SET 6,L
defb $CB,$C7+$38 ;set 7,a set 7,a SET 7,A
defb $CB,$C0+$38 ;set 7,b set 7,b SET 7,B
defb $CB,$C1+$38 ;set 7,c set 7,c SET 7,C
defb $CB,$C2+$38 ;set 7,d set 7,d SET 7,D
defb $CB,$C3+$38 ;set 7,e set 7,e SET 7,E
defb $CB,$C4+$38 ;set 7,h set 7,h SET 7,H
defb $CB,$C5+$38 ;set 7,l set 7,l SET 7,L
defb $CB,$87 ;res 0,a res 0,a RES 0,A
defb $CB,$80 ;res 0,b res 0,b RES 0,B
defb $CB,$81 ;res 0,c res 0,c RES 0,C
defb $CB,$82 ;res 0,d res 0,d RES 0,D
defb $CB,$83 ;res 0,e res 0,e RES 0,E
defb $CB,$84 ;res 0,h res 0,h RES 0,H
defb $CB,$85 ;res 0,l res 0,l RES 0,L
defb $CB,$87+$08 ;res 1,a res 1,a RES 1,A
defb $CB,$80+$08 ;res 1,b res 1,b RES 1,B
defb $CB,$81+$08 ;res 1,c res 1,c RES 1,C
defb $CB,$82+$08 ;res 1,d res 1,d RES 1,D
defb $CB,$83+$08 ;res 1,e res 1,e RES 1,E
defb $CB,$84+$08 ;res 1,h res 1,h RES 1,H
defb $CB,$85+$08 ;res 1,l res 1,l RES 1,L
defb $CB,$87+$10 ;res 2,a res 2,a RES 2,A
defb $CB,$80+$10 ;res 2,b res 2,b RES 2,B
defb $CB,$81+$10 ;res 2,c res 2,c RES 2,C
defb $CB,$82+$10 ;res 2,d res 2,d RES 2,D
defb $CB,$83+$10 ;res 2,e res 2,e RES 2,E
defb $CB,$84+$10 ;res 2,h res 2,h RES 2,H
defb $CB,$85+$10 ;res 2,l res 2,l RES 2,L
defb $CB,$87+$18 ;res 3,a res 3,a RES 3,A
defb $CB,$80+$18 ;res 3,b res 3,b RES 3,B
defb $CB,$81+$18 ;res 3,c res 3,c RES 3,C
defb $CB,$82+$18 ;res 3,d res 3,d RES 3,D
defb $CB,$83+$18 ;res 3,e res 3,e RES 3,E
defb $CB,$84+$18 ;res 3,h res 3,h RES 3,H
defb $CB,$85+$18 ;res 3,l res 3,l RES 3,L
defb $CB,$87+$20 ;res 4,a res 4,a RES 4,A
defb $CB,$80+$20 ;res 4,b res 4,b RES 4,B
defb $CB,$81+$20 ;res 4,c res 4,c RES 4,C
defb $CB,$82+$20 ;res 4,d res 4,d RES 4,D
defb $CB,$83+$20 ;res 4,e res 4,e RES 4,E
defb $CB,$84+$20 ;res 4,h res 4,h RES 4,H
defb $CB,$85+$20 ;res 4,l res 4,l RES 4,L
defb $CB,$87+$28 ;res 5,a res 5,a RES 5,A
defb $CB,$80+$28 ;res 5,b res 5,b RES 5,B
defb $CB,$81+$28 ;res 5,c res 5,c RES 5,C
defb $CB,$82+$28 ;res 5,d res 5,d RES 5,D
defb $CB,$83+$28 ;res 5,e res 5,e RES 5,E
defb $CB,$84+$28 ;res 5,h res 5,h RES 5,H
defb $CB,$85+$28 ;res 5,l res 5,l RES 5,L
defb $CB,$87+$30 ;res 6,a res 6,a RES 6,A
defb $CB,$80+$30 ;res 6,b res 6,b RES 6,B
defb $CB,$81+$30 ;res 6,c res 6,c RES 6,C
defb $CB,$82+$30 ;res 6,d res 6,d RES 6,D
defb $CB,$83+$30 ;res 6,e res 6,e RES 6,E
defb $CB,$84+$30 ;res 6,h res 6,h RES 6,H
defb $CB,$85+$30 ;res 6,l res 6,l RES 6,L
defb $CB,$87+$38 ;res 7,a res 7,a RES 7,A
defb $CB,$80+$38 ;res 7,b res 7,b RES 7,B
defb $CB,$81+$38 ;res 7,c res 7,c RES 7,C
defb $CB,$82+$38 ;res 7,d res 7,d RES 7,D
defb $CB,$83+$38 ;res 7,e res 7,e RES 7,E
defb $CB,$84+$38 ;res 7,h res 7,h RES 7,H
defb $CB,$85+$38 ;res 7,l res 7,l RES 7,L
defb $CB,$46 ;bit 0,[hl] bit 0,[hl] BIT 0,(HL)
defb $CB,$4E ;bit 1,[hl] bit 1,[hl] BIT 1,(HL)
defb $CB,$56 ;bit 2,[hl] bit 2,[hl] BIT 2,(HL)
defb $CB,$5E ;bit 3,[hl] bit 3,[hl] BIT 3,(HL)
defb $CB,$66 ;bit 4,[hl] bit 4,[hl] BIT 4,(HL)
defb $CB,$6E ;bit 5,[hl] bit 5,[hl] BIT 5,(HL)
defb $CB,$76 ;bit 6,[hl] bit 6,[hl] BIT 6,(HL)
defb $CB,$7E ;bit 7,[hl] bit 7,[hl] BIT 7,(HL)
defb $CB,$C6 ;set 0,[hl] set 0,[hl] SET 0,(HL)
defb $CB,$CE ;set 1,[hl] set 1,[hl] SET 1,(HL)
defb $CB,$D6 ;set 2,[hl] set 2,[hl] SET 2,(HL)
defb $CB,$DE ;set 3,[hl] set 3,[hl] SET 3,(HL)
defb $CB,$E6 ;set 4,[hl] set 4,[hl] SET 4,(HL)
defb $CB,$EE ;set 5,[hl] set 5,[hl] SET 5,(HL)
defb $CB,$F6 ;set 6,[hl] set 6,[hl] SET 6,(HL)
defb $CB,$FE ;set 7,[hl] set 7,[hl] SET 7,(HL)
defb $CB,$86 ;res 0,[hl] res 0,[hl] RES 0,(HL)
defb $CB,$8E ;res 1,[hl] res 1,[hl] RES 1,(HL)
defb $CB,$96 ;res 2,[hl] res 2,[hl] RES 2,(HL)
defb $CB,$9E ;res 3,[hl] res 3,[hl] RES 3,(HL)
defb $CB,$A6 ;res 4,[hl] res 4,[hl] RES 4,(HL)
defb $CB,$AE ;res 5,[hl] res 5,[hl] RES 5,(HL)
defb $CB,$B6 ;res 6,[hl] res 6,[hl] RES 6,(HL)
defb $CB,$BE ;res 7,[hl] res 7,[hl] RES 7,(HL)
defb $C3,0,0 ;jp 0 jp $0000 JP nn
defb $C2,0,0 ;jp nz,0 jp nz,$0000 JP NZ,nn
defb $CA,0,0 ;jp z,0 jp z,$0000 JP Z,nn
defb $D2,0,0 ;jp nc,0 jp nc,$0000 JP NC,nn
defb $DA,0,0 ;jp c,0 jp c,$0000 JP C,nn
defb $E9 ;jp [hl] jp [hl] JP (HL)
defb $18,0 ;4309 jr $430B jr $430B JR n
defb $20,0 ;430B jr nz,$430D jr nz,$430D JR NZ,n
defb $28,0 ;430D jr z,$430F jr z,$430F JR Z,n
defb $30,0 ;430F jr nc,$4311 jr nc,$4311 JR NC,n
defb $38,0 ;4311 jr c,$4313 jr c,$4313 JR C,n
defb $CD,0,0 ;call 0 call $0000 CALL nn
defb $C4,0,0 ;call nz,0 call nz,$0000 CALL NZ,nn
defb $CC,0,0 ;call z,0 call z,$0000 CALL Z,nn
defb $D4,0,0 ;call nc,0 call nc,$0000 CALL NC,nn
defb $DC,0,0 ;call c,0 call c,$0000 CALL C,nn
defb $C7 ;rst 0 rst $00 RST 00H
defb $CF ;rst 8 rst $08 RST 08H
defb $D7 ;rst $10 rst $10 RST 10H
defb $DF ;rst $18 rst $18 RST 18H
defb $E7 ;rst $20 rst $20 RST 20H
defb $EF ;rst $28 rst $28 RST 28H
defb $F7 ;rst $30 rst $30 RST 30H
defb $FF ;rst $38 rst $38 RST 38H
defb $C9 ;ret ret RET
defb $C0 ;ret nz ret nz RET NZ
defb $C8 ;ret z ret z RET Z
defb $D0 ;ret nc ret nc RET NC
defb $D8 ;ret c ret c RET C
defb $D9 ;reti reti RETI
excellent, thank you... chewing on it now...
- - - Updated - - -
the "ld hl,[sp+$00]" (bgb) is atrocious, I'm not going to add support for this one by 100%.
Seems `ld hl,sp+<expression>` has to somehow happen (looks like too official/preferred to ignore)... and if *that* happens, then `ldhl sp,n` is probably a bit redundant (and not as obvious/clear as I would wish for, so `ldhl` may be not included in sjasmplus).
And as I wrote before, I don't like `ld a,[$ff00+c] / ld a,($ff00+c)` (again bgb and variant in pdf), that's probably another one to be not expected.
`ldh a,[$FF00]` is kinda bleeding my eyes, but I can support it (doing warning about truncated value only if `high(expression)` is not zero and not $FF, so this syntax will be without warning then (but other 16b values will emit warning in "ldh")).
Everything else looks either already compatible with sjasmplus, or too important to be ignored and *needs* to be implemented, or as reasonably simple addition.
So in the end, if I add only the ones I like, the IDA will be 100% compatible, bgb source will fail on 3-5 instructions, and GBCPUman.pdf will have always at least one variant supported (on most instructions all variants should work, but few will be incompatible).
That sounds to me better than I expected...
Any info about that header checksum, how to calculate it?
And is it not the same situation as GBA, where you must include the Nintendo logo graphics in the ROM at precise address to not fail the bootloader check, but that means you are breaching the copyright if you are doing homebrew without official Nintendo license?
If there is similar (C) protection scheme on GB/GBP/GBC, then of course the required binary part will be *NOT* part of sjasmplus, and developers will have to obtain it by their own means (and decide themselves, if it is a good idea to breach big N copyright ... usually not a very good idea, unless you are just doing it for your own education and not releasing anything).
But as long as the dev provides all the required binaries and assembles header data at correct addresses, the sjasmplus can provide some macro which will calculate the correct checksum, that should be legal to add.
NEO SPECTRUMAN
28.09.2019, 11:41
Any info about that header checksum, how to calculate it?
например
0000 Restart $00 Address
(RST $00 calls this address.)
0008 Restart $08 Address
(RST $08 calls this address.)
0010 Restart $10 Address
(RST $10 calls this address.)
0018 Restart $18 Address
(RST $18 calls this address.)
0020 Restart $20 Address
(RST $20 calls this address.)
0028 Restart $28 Address
(RST $28 calls this address.)
0030 Restart $30 Address
(RST $30 calls this address.)
0038 Restart $38 Address
(RST $38 calls this address.)
0040 Vertical Blank Interrupt Start Address
0048 LCDC Status Interrupt Start Address
0050 Timer Overflow Interrupt Start Address
0058 Serial Transfer Completion Interrupt
Start Address
0060 High-to-Low of P10-P13 Interrupt
Start Address
An internal information area is located at 0100-014F in
each cartridge. It contains the following values:
0100-0103 This is the begin code execution point in a
cart. Usually there is a NOP and a JP
instruction here but not always.
0104-0133 Scrolling Nintendo graphic:
CE ED 66 66 CC 0D 00 0B 03 73 00 83 00 0C 00 0D
00 08 11 1F 88 89 00 0E DC CC 6E E6 DD DD D9 99
BB BB 67 63 6E 0E EC CC DD DC 99 9F BB B9 33 3E
( PROGRAM WON'T RUN IF CHANGED!!!)
0134-0142 Title of the game in UPPER CASE ASCII. If it
is less than 16 characters then the
remaining bytes are filled with 00's.
0143 $80 = Color GB, $00 or other = not Color GB
0144 Ascii hex digit, high nibble of licensee
code (new).
0145 Ascii hex digit, low nibble of licensee
code (new). (These are normally $00 if
[$014B] <> $33.)
0146 GB/SGB Indicator (00 = GameBoy, 03 = Super
GameBoy functions)
(Super GameBoy functions won't work
if <> $03.)
0147 Cartridge type:
0-ROM ONLY 12-ROM+MBC3+RAM
1-ROM+MBC1 13-ROM+MBC3+RAM+BATT
2-ROM+MBC1+RAM 19-ROM+MBC5
3-ROM+MBC1+RAM+BATT 1A-ROM+MBC5+RAM
5-ROM+MBC2 1B-ROM+MBC5+RAM+BATT
6-ROM+MBC2+BATTERY 1C-ROM+MBC5+RUMBLE
8-ROM+RAM 1D-ROM+MBC5+RUMBLE+SRAM
9-ROM+RAM+BATTERY 1E-ROM+MBC5+RUMBLE+SRAM+BATT
B-ROM+MMM01 1F-Pocket Camera
C-ROM+MMM01+SRAM FD-Bandai TAMA5
D-ROM+MMM01+SRAM+BATT FE - Hudson HuC-3
F-ROM+MBC3+TIMER+BATT FF - Hudson HuC-1
10-ROM+MBC3+TIMER+RAM+BATT
11-ROM+MBC3
0148 ROM size:
0 - 256Kbit = 32KByte = 2 banks
1 - 512Kbit = 64KByte = 4 banks
2 - 1Mbit = 128KByte = 8 banks
3 - 2Mbit = 256KByte = 16 banks
4 - 4Mbit = 512KByte = 32 banks
5 - 8Mbit = 1MByte = 64 banks
6 - 16Mbit = 2MByte = 128 banks
$52 - 9Mbit = 1.1MByte = 72 banks
$53 - 10Mbit = 1.2MByte = 80 banks
$54 - 12Mbit = 1.5MByte = 96 banks
0149 RAM size:
0 - None
1 - 16kBit = 2kB = 1 bank
2 - 64kBit = 8kB = 1 bank
3 - 256kBit = 32kB = 4 banks
4 - 1MBit =128kB =16 banks
014A Destination code:
0 - Japanese
1 - Non-Japanese
014B Licensee code (old):
33 - Check 0144/0145 for Licensee code.
79 - Accolade
A4 - Konami
(Super GameBoy function won't work
if <> $33.)
014C Mask ROM Version number (Usually $00)
014D Complement check
(PROGRAM WON'T RUN ON GB IF NOT CORRECT!!!)
(It will run on Super GB, however,
if incorrect.)
014E-014F Checksum (higher byte first) produced by
adding all bytes of a cartridge except for
two checksum bytes and taking two lower
bytes of the result. (GameBoy ignores this
value.)
а так для тестирования в bgb
можно загрузить любой .bin любого размера
просто header заполнить 0
а с его дебагера можно уже запустить с любого адреса
- - - Добавлено - - -
http://bgb.bircd.org/
...
Ok, "--lr35902" added to sjasmplus. You can check the listing of the test to see which variants of syntax are supported and which not.
https://github.com/z00m128/sjasmplus/blob/master/tests/lr35902/LR35902_syntax_by_neo.lst
I will add more tests in following days to verify all code paths, range checking, disabling of all Z80-only instructions, etc... but I did test the implementation a bit already while working on it, should be quite solid. I will need you to review also those new tests added later, but you can start by this first one...
And ultimately it would be nice if you would try to actually build some working binary and confirm it works and sjasmplus is usable also for LR35902 programming...
As mentioned before, the IDA disassembly + sjasmplus assembly may not produce identical binary due to ambiguity of such process, but you can patch the source with "db" to force sjasmplus emit identical binary in areas where it fails (it should fail only due to ambiguity = not bug, any other difference is bug of course).
NEO SPECTRUMAN
30.09.2019, 06:03
by default the sjasmplus understands "a," as multi-arg: "sub a,0" = "sub a : sub 0" (!)
кстати это мне мешает и при писании под z80
как по мне все "комбинированные" команды типа ld hl,0,bc,0,a,0,e,0
это есть FAKE instructions
и должны быть отключаемыми чтоб не мешали
ага почитал инструкцию
потом попробую поклацать `--syntax=a`
- - - Добавлено - - -
Ped7g, так же возможно нужно выдавать предупреждение
если после команд halt не стоит nop
так как команда после halt по ошибке читается 2 раза
однобайтная команда будет исполнена 2 раза подряд
а 2-х 3-х байтная п
76 halt
fa 34 12 ld a,[1234]
по идеи на gameboy-е превратится в
76 halt
fa fa 32 ld a,[12fa]
12 ld [de],a
хотя это явление можно использовать в своих целях
так же возможно нужно выдавать предупреждение
если после команд halt не стоит nop
It repeats opcode only when `halt` is encountered in `DI` mode? (from what I have read, I have zero real experience) (contrary to ZX where such situation is total freeze - until NMI/reset).
Anyway, this is something completely new in sjasmplus, to warn on instruction depending on the state from previous instruction. I understand it may be very handy, but I'm not sure if/how to add that. I will take a quick look, but I don't like this idea too much (it will be probably quite a mess to add)... in PC world of compilers this would be perfect case for lint-warning, not compiler. But there's no sjasmplus-lint ... yet? :D ...
(actually would be maybe interesting to create a SW doing some static analysis of Z80 machine code and issue warnings about common probably-bug codes, although I personally would really rather like IDE which would support running pieces of code in head-less emulator and display the "live" results and/or use that for unit test... there is some effort from Maziac to build something like this for VS Code, but I'm avoiding anything from Microsoft, so I didn't try it yet (if you don't mind VSC used as base editor, then definitely check this: https://github.com/maziac/z80-unit-tests ... this is IMHO such a killer thing, that I'm actually thinking about trying it out, even if I will have to revoke my MS ban temporarily for VSC ... also I'm not sure how well it works in current version, but if it would be based on any other free editor, I would be already trying to help to develop it ... and such IDE running also the lint-tool in background ... you get the idea)
So I will give it a quick look, but I'm afraid this will have no good place to land and it will not happen right now.
-----
кстати это мне мешает и при писании под z80
well, yes, that was of the main goals why I did take a look into sjasmplus sources, to get rid of bugs from `ld a,(flag1|flag2)` and `sub a,5`. But both fixes are hidden under new `--syntax` option, so the sjasmplus is mostly backward compatible with 1.07 version (and I know I did break this compatibility already in many small details, but every now and then somebody search for some old intro/tool source compiled by 1.07, and almost always it works without any change, so I think I was 50% successful with this "don't break old sources" ... actually I'm growingly unhappy by how many things I did already break, and I don't want to break anything more right now, if anything else requires change in default behaviour, I'm postponing it to "v2.0" ... and that's uncertain, when it will happen, if ever)
Anyway, I strongly suggest to use `--syntax=abfw` as default when writing new source (and probably patch old source to work with this setting too)... the "--syntax=abf" will be highly likely the syntax of v2.0 (and it will be mandatory in 2.0), so by using these already now your source will have higher chance to work in 2.0 without a change.
If somebody reading this is not familiar what it is:
"a" = multiarg delimiter is ",,", example `ld hl,1,,bc,2,,de,3 : sub a,c,,5,,a,,a,3` (the second is `sub c : sub 5 : sub a : sub 3`, the single vs double comma makes it possible for sjasmplus to tell which part is new `sub`, and which part is extra "a," like add/adc/sbc has)
"b" = round parentheses (around whole expression) may be used only for memory acces `ld b,(4)` = error, `ld b,(2)+(2)` = ok, `ld b,+(4)` = ok
"f" is producing warnings on all fake instructions (if you use some by accident)
"w" is "warning as errors", so you will never miss any warning in the source
There is also "B" option, which is my personal preference, that one enforces usage of square brackes for memory, so `ld a,(expr)` is always `ld a,imm8` and for memory you must use `ld a,[expr]`, so in my sources I'm planning to use rather `--syntax=aBfw`, but that will make them probably a bit incompatible with other people, so I'm still not sure.
This whole --syntax option is sort of not that great idea, although I designed it together with OPT directive to work in a way where you can change syntax only temporarily for part of source and then "pop" back previous syntax options, so I can still write some library code for others, and use my options, and they can still include my source.
Anyway, for people who don't like these more strict syntax things, and generally don't like any change, I want to leave v1.14.x in near-perfect state, so they can stick to it for decades... for people like me, who don't mind to fix the source and rather want more warnings/errors and stricter syntax, the v2.0 is planned...
NEO SPECTRUMAN
30.09.2019, 11:28
It repeats opcode only when `halt` is encountered in `DI` mode? (from what I have read, I have zero real experience) (contrary to ZX where such situation is total freeze - until NMI/reset).
Anyway, this is something completely new in sjasmplus,
В принципе это не важно
rgbasm (тот чей синтаксис по идеи применен в IDA)
при компиляции halt
генерирует сразу последовательность halt nop :v2_dizzy_wall:
а ты потом сидишь и ищешь
почему же дизассемблированный скомпилированный код не совпадает с оригиналом
rgbasm (тот чей синтаксис по идеи применен в IDA) при компиляции halt генерирует сразу последовательность halt nop
And I 100% don't want to go *there*. You can always create yourself:
halt MACRO
halt : nop
ENDM
(and emit only-halt by halt" if you want to avoid the macro halt+nop on purpose)
I feel this is not truly responsibility of assembler, IMHO it belongs to different stage of the pipeline. (showing warning is OK, that would make some sense, but emitting halt+nop instead of halt is just evil)
I will give it quick look, but I don't expect this warning to become a reality (unless there already is good scaffolding for state between lines... thinking about it, there are few features working like that, for example IFUSED can follow non-local label on next line, and it will use the previous label, if there was no explicit one on the IFUSED line, so I will check how general/robust those mechanisms are, but I think it's just total mess like always, and adding halt+nop check would end as mess too :) ).
edit: I think I by accident triggered the "mention" of user "ha", sorry!
edit2: and I can't get rid of it, I don't know how to escape the @ to be used only as letter and not trigger the user-mention mechanism. Wow.. that may be lot of fun with sjasmplus sources... :D
NEO SPECTRUMAN
30.09.2019, 11:58
I feel this is not truly responsibility of assembler
у меня на макросах для sjasm написан chip8 компилятор
он кидает кучу ошибок в процессе
но на выходе код получается правильный
и некоторые команды z80 там по моему вполне заменены командами chip8
- - - Добавлено - - -
поддерживаемые команды
8080 like z80 like
0*** sys ***
00C* scdown * scd *
00E0 cls
00EE rts ret rst тк при попытке напечатать rts часто получается именно так
00FB scright scr
00FC scleft scl
00FD exit
00FE low
00FF high
1*** jmp *** jp ***
2*** jsr *** call ***
3x** skeq vx,** se vx,**
4x** skne vx,** sne vx,**
5xy0 skeq vx,vy se vx,vy
6x** mov vx,** ld vx,**
7x** add vx,**
8xy0 mov vx,vy ld vx,vy
8xy1 or vx,vy
8xy2 and vx,vy
8xy3 xor vx,vy
8xy4 add vx,vy
8xy5 sub vx,vy
8x06 shr vx + 8xx6 mode
8xy7 rsb vx,vy subn vx,vy
8x0E shl vx + 8xxE mode
9xy0 skne vx,vy sne vx.vy
A*** mvi ***
B*** jmi ***
Cx** rand vx,** rnd vx,**
Dxy* sprite vx,vy,* drw vx,vy,*
Dxy0 xsprite vx,vy
Ex9E skpr vx skp vx
ExA1 skup vx skpn vx
Fx07 gdelay vx
Fx0A key vx
Fx15 sdelay vx
Fx18 ssound vx
Fx1E adi vx
Fx29 font vx
Fx30 xfont vx
Fx33 bcd vx
Fx55 str v0-vx
Fx65 ldr v0-vx
I think it would make some sense to collect these tricks/ideas/warnings about how to make your life easier while programming GB ROM into some kind of blog, or document, maybe even just `test/macro_examples` file?
But I also want to avoid mentioning "GB" word or "N" word directly in sjasmplus git (also the reason of naming it "lr35902" everywhere, even if I can't remember that number and always have to check the other terminal with sjasmplus --help), so some external blog would be probably better place to describe all these intricacies, maybe even create the checksum macro, etc... show some ROM image build form scratch...
(I'm not planning to get myself involved in this, my focus is ZX Next, so this is all open field for you guys, I will add more tests to verify the --lr35902 works correctly in sjasmplus, and that's my part "done", rest is on your ( = whoever wants to use sjasmplus for GB projects) shoulders. .... so these are like "advice how you can waste your spare time if you feel bored" :) )
NEO: most of the tests added, few bugs fixed (Z80 opcodes generated for invalid instructions) ...
https://github.com/z00m128/sjasmplus/tree/master/tests/lr35902
I think this is now very closed to "done" (I just need to add few more tests for Z80/Z80N instructions and some tests for CLI option/device, but with a bit of luck I managed to fix all bugs with this last commit.
The LR35902_specifics_exercise.asm (and .lst) contains small showcase of how the sjasmplus features/syntax work also for LR35902 instructions and how the valid values are checked.
Please review it all and if you spot something ridiculous or wrong, let me know, thank you.
NEO SPECTRUMAN
30.09.2019, 21:13
для лучшего понимания
var1 db 0x34
var2 dw 0x5678
var3 db 0xAB
var4 dw 0xCDEF
лучше бы сделать
var_34 db 0x34
var_5678 dw 0x5678
var_AB db 0xAB
var_CDEF dw 0xCDEF
; legit ones
stop ; implicit 0
stop 0
stop 0xE0
а что за stop e0 ? о_О
генерируещее 10 E0
сейчас в одном описании попался просто вариант $10 для stop o_O
у stop та же ошибка что и у halt ?
где про это написано?
в http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html тоже упоминается вариант 10
Instruction STOP has according to manuals opcode 10 00 and thus is 2 bytes long. Anyhow it seems there is no reason for it so some assemblers code it simply as one byte instruction 10.
- - - Добавлено - - -
проверил
как такое трактуется в IDA
ld a, b
; ---------------------------------------------------------------------------
db $10 ;short stop
; ---------------------------------------------------------------------------
ld a, c
ld a, d
ld a, b
; ---------------------------------------------------------------------------
stop ;stop
; ---------------------------------------------------------------------------
ld a, c
ld a, d
ld a, b
; ---------------------------------------------------------------------------
db $10 ;stop E0
ld [$FF79], a
; ---------------------------------------------------------------------------
ld a, d
ld a, b
; ---------------------------------------------------------------------------
halt ;halt
; ---------------------------------------------------------------------------
ld a, c
ld a, d
ld a, b
; ---------------------------------------------------------------------------
halt ;halt : nop
nop
; ---------------------------------------------------------------------------
ld a, c
ld a, d
ida дает
Command "MakeCode" failed
и как в bgb
ROM1:4000 78 ld a,b
ROM1:4001 10 79 <corrupted stop> ;short stop
ROM1:4003 7A ld a,d
ROM1:4004 78 ld a,b
ROM1:4005 10 00 stop ;stop
ROM1:4007 79 ld a,c
ROM1:4008 7A ld a,d
ROM1:4009 78 ld a,b
ROM1:400A 10 E0 <corrupted stop> ;stop E0
ROM1:400C 79 ld a,c
ROM1:400D 7A ld a,d
ROM1:400E 78 ld a,b
ROM1:400F 76 halt ;halt
ROM1:4010 79 ld a,c
ROM1:4011 7A ld a,d
ROM1:4012 78 ld a,b
ROM1:4013 76 halt ;halt : nop
ROM1:4014 00 nop
ROM1:4015 79 ld a,c
ROM1:4016 7A ld a,d
Bedazzle
30.09.2019, 21:18
IAnyway, this is something completely new in sjasmplus, to warn on instruction depending on the state from previous instruction.
How you can find previous instruction, if HALT is reached after jump or call?
Seems tracking previous instruction is only half of solution, and looks more like crutch.
а что за stop e0 ? о_О
I think I have catched a glimpse of some note about GBC using stop + value as mechanism to modify some console HW settings, but I may be wrong (and I don't care). Either way, the `stop` is two byte instruction in every decent description I have seen, suggesting the second byte is zero, so that is what `stop` does, but it has this optional argument which can override the zero byte to anything you want. Maybe it's useless/wrong, but shouldn't cause any harm, as normal usage is `stop` without argument = that will produce implicit zero. There is no way to produce short stop in sjasmplus (except "db $10"). I think anyone of need of these unofficial things knows how to deal with it without direct support? I guess.
.... and I pushed to github final batch of tests I did plan to add, for me this feature is done. Waiting for bug reports... :)
How you can find previous instruction, if HALT is reached after jump or call?
Seems tracking previous instruction is only half of solution, and looks more like crutch.
It's the other way, when assembling current line, I need to know that the previous instruction was `halt` and if the current instruction is not `nop`, a warning can be shown. Jumps/calls don't matter at all, as halt can't jump, so the next instruction after it will be executed, either in regular way, or with instruction opcode repeated (hw glitch of GB consoles), depending on the state of the machine when halt was reached. So `nop` is kinda only safe opcode after `halt` to fight this glitch back, unless you know precisely what you are doing and actually you want to use that glitch for some planned behaviour.
Anyway, from the assembling point of view, it's all about some internal "flag" being set by `halt` and staying active for one next instruction, which is trivial to add as some global variable, which usually trivially decays into weird bugs like forgetting to clear it in certain code paths, etc... So I'm not in hurry to add it, maybe I will figure out something more elegant and easier to maintain later. (or maybe somebody else will write some static-analyzer/lint for Z80 machine code :D )
Bedazzle
01.10.2019, 00:05
It's the other way, when assembling current line, I need to know that the previous instruction was `halt` and if the current instruction is not `nop`, a warning can be shown.
I mean it is not straightforward
HALT
DB 0
....
DB 117+1
NOP
....
HALT
AND A
I mean it is not straightforward
Exactly. :) ... from your examples the first and third should do warning and second not (even if that value is `halt`). But it can even more tricky.
For example:
DUP 4
nop : halt
EDUP
nop
... good luck with that if you are sitting early in the pipeline around substitutions and before macros are even processed... ;)
(not saying that sitting late in the pipeline where the bytes are emitted is better, pretty much same complexity, just completely different problems)
Bedazzle
01.10.2019, 06:49
Exactly. :) ... from your examples the first and third should do warning and second not (even if that value is `halt`). But it can even more tricky.
IFDEF FREEZER
HALT
ENDIF
NOP
Hey.. it just now occurred to me... GB is using banking to read all that ROM cartridge, right?
any examples, how it is done, and if anything useful can be improved on sjasmplus side?
Or is device like ZXSPECTRUM1024 + SAVEDEV large enough to build bigger ROM image easily and the 0x8000 slot sizes are native also to GB banking?
I just added the "$$label" operator, it is returning label's page value, so now it is enough to do in source:
DEVICE ZXSPECTRUM1024 : SLOT 3
ORG $c000, 4
fn1:
; fn1page EQU $$ ;; not needed anymore
nop : ...
; and the code which wants to know the page where the beginning of the code did land
; and set the bank, can use the $$ like this:
ORG $8000
ld a,$$fn1 + whatever_const ; 4 + whatever_const
out (c),a ; switch bank
call fn1 ; execute the code
In ideal case this should help also with GB, so device with suitable slots/pages to define the page-of-label well may be needed. But I'm too lazy to read about GB specs, so if NEO or somebody else will post simple details here, what needs change, I will look into it.
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.2
v1.14.2 changelog:
- added i8080 mode (--i8080 CLI option) (it's still Z80 Zilog syntax, just limited instruction set)
- added Sharp LR35902 mode (--lr35902 CLI option) (100% syntax compatibility with IDA, 95% bgb)
- new $$label operator to retrieve page of label
- 1.14.0 include-path bugfix reverted, the "." is again automatically added (did break projects)
- small improvements/polish/extra-info in docs, INSTALL, README, few new tests added
- cmake script fix of SYSTEM_LUA=ON option, CirrusCI configs added for macOS and FreeBSD
- few fixes of memory leaks, invalid memory access, double free/delete
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
Should "just work".
If you have any issue with it, and the docs doesn't explain why the assembler is doing what it is doing, please report it, so I can take a look
(before I will forget how it works).
NEO SPECTRUMAN
04.10.2019, 23:54
прогнал свои дизассмы
100% совпадение :v2_dizzy_roll:
на
ld hl, sp+$FA
выдало
error: Offset out of range (+250)
но bin-анрник в итоге правильный :v2_yahoo:
хотя по GBCPUman.pdf
ld hl,sp+n
n - signed value о_О
потом проверю как команда отрабатывает на эмуляторе
и действительно ли там signed...
вангую что это кривая IDA
ld hl, sp+$FA
выдало
error: Offset out of range (+250)
That's "correct" (but annoying), it's signed int8_t, so in source should be value -128 .. +127 ($FA = -6: `ld hl,sp-6` is correct syntax)
... it should have been just warning, but I'm reusing the check from `jr/djnz` routines which report these as error, and I was too lazy to change it.
(but it's still producing the binary, so if you are lazy too, you can just ignore it... or edit the source and add -256 to such line = `ld hl,sp+$FA-256`= that will remove the error message)
Thinking about it, there's no "(int8_t)" typecast like in C, so if IDA is producing 0..255 values, you really have to manually go over all error reports and add the -256 on those lines ... or actually, if the IDA is holding the $%02x formatting rigorously (and the whole instruction formatting), one sed line in bash like:
cat x.asm | sed -r "s/(\\bld\\s+hl,\\ sp\\+\\\$[89A-F][0-9A-F]\\s*\$)/\\1 -256 ; fixed by sed/" > x_fixed.asm
(ARGH... took me 15min to build it with correct escaping for bash.. while in Java/C++ I would just write the regexp in 3min)
(the regexp in it's final form is "s/(\bld\s+hl,\ sp\+\$[89A-F][0-9A-F]\s*$)/\1 -256 ; fixed by sed/" ... i.e. find all lines with ld hl, sp+$80..$FF values which have nothing after it except whitespace+endline, and adds " -256 " text after them. So you can even run this replacement on the already fixed file, shouldn't change it twice (because the endline condition is not fulfilled).
NEO SPECTRUMAN
05.10.2019, 02:26
you can just ignore it...
меня это не беспокоит :v2_dizzy_vodka3:
я просто отписался о первой увиденной ошибке
главное что теперь можно выкинуть rgbasm (затереть Gutmann-ом шесть раз подряд :) )
и забыть про него
NEO SPECTRUMAN
09.10.2019, 19:13
В общем
генерация контрольной суммы не нужна!
GB вроде бы ее не проверяет
проверяется только $0134-$014D
и логотип nintendo
все что нужно для запуска своего кода
; ---------------------------------------------------------------------------
org $0100
nop
jp start
; ---------------------------------------------------------------------------
org $0104
db $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$0 0,$0C,$00,$0D ;nintendo logo
db $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$D D,$DD,$D9,$99 ;do not change !!!
db $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$B B,$B9,$33,$3E ;!!!
check
db "CHCK_SUM_TEZT! " ;rom name
db 00 ;
db 00,00 ;
db 00 ;
db 00 ;
db 00 ;
db 00 ;
db 00 ;
db 00 ;
db 00 ;
checksum_cnt = 0
checksum = 0
dup 25
checksum = checksum + ({b check + checksum_cnt})
checksum_cnt = checksum_cnt + 1
edup
checksum = checksum + 25
db low (256 - checksum)
db $00,$00 ;rom check sum (who cares?)
; ---------------------------------------------------------------------------
- - - Добавлено - - -
Если что
могу проверить
действительно ли контральтовая сумма не имеет значения
на железном dmg-01
- - - Добавлено - - -
но для правильной работы эмуляторов и flash картриджей
придется наверно все таки прописывать
тип картриджа
количество банок ПЗУ \ ОЗУ
да и может есть тупые эмуляторы которые откажутся запускать без совпадения общей контрольной суммы
- - - Добавлено - - -
расчет не нужной контрольной суммы для 32К rom-а
(помещать в конце исходника перед сохранением)
;rom_00_check_sum
full_checksum_cnt = 0
full_checksum = 0
dup $14E
full_checksum = full_checksum + ({b full_checksum_cnt})
full_checksum_cnt = full_checksum_cnt + 1
edup
full_checksum_cnt = $150
dup $3EB0
full_checksum = full_checksum + ({b full_checksum_cnt})
full_checksum_cnt = full_checksum_cnt + 1
edup
;rom_01_check_sum
full_checksum_cnt = $4000
dup $4000
full_checksum = full_checksum + ({b full_checksum_cnt})
full_checksum_cnt = full_checksum_cnt + 1
edup
org $014E
db high full_checksum
db low full_checksum
SAVEBIN "teZt.gb",$0000,$8000
для больших картриджей
скорей всего просто щелкать страницами
(такой вариант я не проверял)
slot 0
page 0
;rom_00_check_sum
slot 1
page 1
;rom_01_check_sum
slot 1
page 2
;rom_01_check_sum (COPY)
slot 1
page 3
;rom_01_check_sum (COPY)
slot 1
page 4
;rom_01_check_sum (COPY)
...
...
org $014E
db high full_checksum
db low full_checksum
If you know the checksum was zero before running the checksum loop, you can just do full $4000 DUP on first area (no need to split it), the result should be same?
(or you can clear it before checksumming with `ORG $14E : DW 0`)
And then you can probably create macro for $4000x bank checksum with arguments for entry address+slot+page and use it for all parts...
Etc... I'm generally not interested too much to include this directly into sjasmplus git (N-logo for sure *NOT*, the checksum macro... maybe, but it's trivial to write if you know the sjasmplus syntax).
So I guess it's enough to have this documented here on the forum, or maybe somebody will write some public blog about "how to use sjasmplus for GB development"... (somebody not connected to sjasmplus project in any way :) and published on unrelated web not connected to the sjasmplus).
Thank you very much NEO SPECTRUMAN for testing it and for the syntax research info - it was essential task to make this happen (I think any major issue would be already found by now, so I guess LR35902 feature is of decent quality). (of course if any bug is found, let me know, as always)
Have fun. :)
NEO SPECTRUMAN
10.10.2019, 06:50
the result should be same?
ну да
если сначала туда забить ручками db 0,0
ну а в моему случае это был дизасм bgbtest.gb
и там уже была своя контрольная сумма
которую нужно было исправить на новую
тк например
db "BGBWELCOME "
сходу не совпадает
и нужно уточнять какая изначально была кодировка текста
конечно можно перед расчетом можно сделать
org $014E
dw 0
- - - Добавлено - - -
address+slot+page
не уверен на 100% процентов
но у GB по моему только slot 1
let me know, as always)
ну не баг
а скорей пожелание
нужен
DEVICE ZXSPECTRUM4096
slot 0,1,2,3
0...255 pages
как сейчас это on military Russian spectrum clones :)
таких как ZX-Evo, ATM3
и если это не трудно то
с запасом на будущее можно бы и
ZXSPECTRUM8192
ZXSPECTRUM16384 (ought to be enough for anybody :) )
так же у злых русских есть и ZXSPECTRUM2048
например ZX-Phoenix
- - - Добавлено - - -
syntax research info
я ВНЕЗАПНО обнаружил \ забыл
что в bgb
целых 3 варианта синтаксиса
а я закинул только вариант no$gmb
а там еще
rgbds (на 95% совпадающий с rgbasm \ ida версией)
wla-dx (???? о_О)
потом может закину и эти варианты для сравнения
- - - Добавлено - - -
maybe, but it's trivial to write if you know the sjasmplus syntax
не везде описан сам алгоритм
я нашел описание только в одном отечественном источнике
n*****do logo можно выдрать от куда угодно и самому
просто нужно указать по каким адресам оно лежит
я потом может сделаю заготовку gb исходника
с макросами и пометками где какой лежит вектор прерываний итд
а за n*****do©™® logo можно будет послать в какой нибудь gb programming reference
DEVICE ZXSPECTRUM4096
added to github issues, may happen (probably still in v1.14.x) (larger sizes will probably work easily too, I think 2GiB would be first size to run into some minor problems, as the expression evaluator is strictly `int32_t`, can't recall any other code having any hard limit ... oh, the array for pages/slots is 128 items max, but I'm itching to rewrite that to std::vector for long time any way... and I must have adjusted it for Next already, that one has 224 pages)
BTW https://www.wallpaper.com/lifestyle/analogue-pocket-vintage-handheld-game-boy
I don't know what how the GB home-brew scene looks, but I guess with this device being announced today in about ~2 hours, there may be some new interest into the scene (although it doesn't seem the manufacturer themselves push any dev tools even for their other fake copies, so I don't think they will promote anything like that).
Still it's funny coincidence, just when --lr35902 was added to sjasmplus ... I'm curious if somebody will ever try to build some medium/larger GB app with it (hopefully they will find way to send me any feedback, or report any issues blocking them).
(I personally want to focus on ZX Next, I have hardly enough spare time for that, so I'm not jumping onto GB thing ... except of course bugfixing of sjasmplus, but AFAIK it should be usable for GB development as is... if somebody would add nice collection of macros and how-to tutorials, it would be quite complete assembler tool IMO, I don't see any serious issue)
Сломан старый IFUSED, работает только новый.
Сломан старый IFUSED, работает только новый.
nepanimaju.
style1a IFUSED ; same line
ld b,b
ENDIF
style1b
IFUSED ; after label is defined
ld b,d
ENDIF
IFUSED style2 ; ahead label is defined
style2
ld b,c
ENDIF
; uncomment to test if the code is produced
; jr style1a
; jr style1b
; jr style2
all works for me.
Я тоже не понимаю как можно было так сломать, но тем не менее
- - - Добавлено - - -
Так то бог с ним, сломал и сломал, просто надо выпилить из синтаксиса и убрать из доков.
Так то бог с ним, сломал и сломал, просто надо выпилить из синтаксиса и убрать из доков.
Ah, interesting, but I think I know what is happening.
The line `call test1` is inside module `test`, so it has ambiguous interpretation, it can be either `call test.test1` calling another inside-module label, or it can be interpreted as `call test1` in global namespace without module.
If you remove the `IFUSED` test, the global `test1` will be defined, and in second+ pass the `call` will find it and use it, interpreting it as global label.
But with the `IFUSED` the global label is never defined, and the `call` will always trigger only the "in-module" interpretation (marking "test.test1" label as "used + not_defined", but that's not relevant to the `IFUSED` in include file, so that will be always false).
You can either use the other syntax of `IFUSED` after the label ("style1a"/"style1b" in my previous example, which do define the global label even when the label is unused, and the code is skipped, i.e.:
test1 IFUSED
ret
ENDIF
Or you can disambiguate the call line by using `call @test1` to make it clear the "test1" is label from global name space, not belonging to current `test` module.
(I guess you do not want the `test1` to belong into module `test`, otherwise also defining the `test1` routine inside the module will fix the error too, but then you have `test.test1` routine, not `test1`).
To fix this (in relaxed syntax way, allowing the source you posted as valid) the `call` would have to generate ambiguous two-variant "possibly used label" meta data, and the IFUSED would have to check all these variants then... Which is unfortunately not trivial fix. (and without thinking about it properly, I would be afraid of such change to backfire by having old source in modules generating suddenly lot more global undefined+used labels in the table, but maybe that's no issue at all, I don't know)
(and I'm not a big fan of relaxed syntax which has ambiguous interpretations, so I'm a bit tempted to fix this by removing "style2" syntax of IFUSED ... :D ... and also remove the global labels search when inside the module, to make the `@` mandatory in this case :D ... that would be like "correct" fix by my taste, but I guess that's not helping to actual users :P )
So at this moment I don't want to try to fix this, IMO either using the `@` or the "style1a" IFUSED syntax is good-enough workaround? But I should probably add this bug description to IFUSED docs as known bug.
Sorry for the inconvenience, I hope you can manage around this... (and of course thank you for the report)
Проблема лишь в том что в старом синтаксисе не работает, а в новом работает, почему в одном случае оно помечает использование в глобальных а во втором нет? У меня не так много включаемых библиотек, я просто их поправил. Глобальный поиск по собаке из модулей наверное правильно, пожалуй переделаю свои потихоньку, через пару лет.
Проблема лишь в том что в старом синтаксисе не работает, а в новом работает, почему в одном случае оно помечает использование в глобальных а во втором нет? У меня не так много включаемых библиотек, я просто их поправил. Глобальный поиск по собаке из модулей наверное правильно, пожалуй переделаю свои потихоньку, через пару лет.
The difference is subtle, the old syntax does this:
pass1:
`call` will search for both "@test.test1" and "@test1", both fails, adds into symbol table "@test.test1" as "used + undefined" symbol.
`ifused test1` will check table for `@test1`, find nothing, emit no code (and no label).
pass2 + pass3:
the same thing happens, in pass3 the `call` reports missing label "@test.test1".
New syntax:
pass1:
`call` will search for both "@test.test1" and "@test1", both fails, adds into symbol table "@test.test1" as "used + undefined" symbol.
`test1: ifused` will define "@test1" label ("unused + defined" type), will check for usage, no usage, skip block
pass2:
`call` will search for both... and find the "@test1" defined ("defined" type wins over "@test.test1" - which exist, but is "undefined" type), marking the "@test1" as "used"
`test1: ifused` will check usage flag, and emit the block, because now it is used
pass3:
same as pass2
(the "@test.test1" usage symbol is simply hanging there and being ignored, as the global "@test1" will work for all the code).
You can either change your libraries to "new" syntax, or you can do at least one usage in source with full label (`call @test1`), that will be enough to trigger the "old" syntax of IFUSED (if there will be other lines "call test1", they will still prefer @test.test1 in first pass, but since second pass those will find the global @test1 too, so they will end with correct value in pass 3).
So you can choose if you want to edit the old library or the new code.
Makes me wonder under which version your source did compile before, did it work with some older version of sjasmplus? Or did you add modules later and didn't notice until that IFUSED mystery?
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.3
v1.14.3 changelog:
- fix detection of `.end:` and `.END` labels when `--dirbol` is used
- added export of SLD (Source Level Debugging) data for NDS-NextDevSystem (https://github.com/Ckirby101/NDS-NextDevSystem)
- added `--longptr` option to allow labels outside of 16b address space
- docs: added small details about FPOS, SAVETAP, IFUSED
- fix assembling-time reported in linux
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
The minor fixes and `--longptr` option are result of cooperation with "one abandoned project by Daemos" for MSX platform, who was trying to migrate from Tniasm to sjasmplus (now successfully migrated).
From the other feedback since v1.14.2... usually most of the issues turn out to be "lack of documentation" of sjasmplus specifics, when it doesn't meet expectations of user and it works in different way than they expect.
For example the (internal) distinction between modules+labels/macros/defines (all of them being different kind, and applied to the source line in different stage of assembling) is common source of confusion, as each feature is maybe too independent and having its own rules (how it works).
So I will try in future to add few more chapters to docs about how actually sjasmplus internally works and what are expected ways of usage.
If you have some issue on your own sources, if everything fails, don't hesitate to post some example here, or send me whole project so I can check the problem and suggest some workaround/fix. Obviously some of the reported issues would be nice to fix a bit more on the assembler side and less in the project source, but I don't want to change general behaviour of v1.14.x versions, adding only new features when they don't collide with old syntax and behaviour.
(the v1.14 series are sort of "final" versions of sjasmplus v1.x, and by the amount of new bugs found+fixed in recent releases I think I'm there already, with only minor fix releases coming in future... and then maybe later one day the v2.x will be released - which will have also behaviour and syntax changes, so I'm collecting also ideas for behaviour changes for the v2.x).
- fix detection of `.end:` and `.END` labels when `--dirbol` is used
Кстатида. про "END"
Это теперь зарезервированное слово?? Псевдокоманда?? или как и раньше - может быть простой меткой??
Столкнулся с непонятным поведением. Если стоИт точно в начале строки. как метка, то компилируется, и сзздается выходной файл, ну к примеру .tap
Если же не в начале строки - то так же компилируется, без ошибок, но файла не создает.
Так
end
savetap "primer.tap" ,start
и так
end
savetap "primer.tap" ,start
в другом, хорошем:), компиляторе - пофиг на расположение.
Кстатида. про "END"
Это теперь зарезервированное слово??
It was always directive, documented as: http://z00m128.github.io/sjasmplus/documentation.html#po_end
The assembler will stop at this point. The pseudo-op END does NOT work in the beginning of line (even with --dirbol).
(it's more than 10 years old paragraph)
But it didn't work as documented, so I fixed it around v1.11 or v1.12 to work as the docs describe.
*Today* I'm not sure if that was the smartest idea, maybe I should have kept the dirEND() as it was, and change the documentation to describe what the code really does (was just setting "start" address for some other commands like savetap/savesna/...).
в другом, хорошем, компиляторе - пофиг на расположение.
Nice, so you can use whatever you like and you have options.
But JFYI, if you are talking about https://github.com/sjasmplus/sjasmplus ... it has the same quote in the documentation. So if the END doesn't stop assembling in it, in my view it is a bug (I'm used to treat docs as source of truth, so for me it was clearly bug in the code, but as I wrote, with the experience I collected in recent months, I'm not that sure about it, changing the docs post-fact may be sometimes better solution, than "fixing bug" in the code).
The examples you posted work as intended.
(`END` at beginning of line is label, after whitespace it's keyword, the --dirbol does NOT enable END at beginning of line (fully fixed in 1.14.3) ... plus add the syntax ambiguity of sjasmplus, where every directive can be prefixed with single dot, so the same rules apply to ".END" string, beginning of line = local label, after white space = stopping assembler)
Shadow Maker
08.01.2020, 14:13
It was always directive, documented as: http://z00m128.github.io/sjasmplus/documentation.html#po_end
(it's more than 10 years old paragraph)
But it didn't work as documented, so I fixed it around v1.11 or v1.12 to work as the docs describe.
*Today* I'm not sure if that was the smartest idea, maybe I should have kept the dirEND() as it was, and change the documentation to describe what the code really does (was just setting "start" address for some other commands like savetap/savesna/...).
By me you should just change the docs instead of changing the behavior, as in 10 years people have lot of source code and probably there are quite a lot of similar things, which make people frustrate on such trivial matter.
I would rather write
So I can easily change the variable name I pass instead of having to change all of them every time I want to change filename.
Вот так можно:
define filename "test.tap"
savetap filename, BASIC,"noAutorun",label,100
....
Shadow Maker
08.01.2020, 18:26
Вот так можно:
define filename "test.tap"
savetap filename, BASIC,"noAutorun",label,100
....
Ясно, я что-то не подумал. Ок.
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.4
v1.14.4 changelog:
* in lua scripts: sj.calc(..) (alias _c(..)) now substitutes defines and macro arguments
* error reporting inside LUA and MACRO refactored to give better info about origin of error
* macro-arguments parser now recognizes C++ numeric literals with apostrophe as digits-group separator
* added few example utility macros in tests/macro_examples/sj_library.asm (neg r16)
* added SAVENEX SCREEN BMP sub-command to include BMP loading-screen
* added support for V1.3 of NEX file format (new commands: CFG3, PALETTE, COPPER, new screen modes)
* the assembler will instantly exit when run at Big-Endian platform (the rest of code is broken on BE)
* updated syntax-highlight file for KDE5 editors (Kate)
As always, if you have some issue, post small source example here and describe the problem, hopefully I will be able to figure out what is going on, and fix it.
-------
I have seen the question in the other thread:
Народ, а насколько возможно переделать Sjasm под другие процы типа мотороловских 6800 или наших 1801ВМ1 и так далее. Вроде исходники ассемблера есть. Никто не заморачивался этим вопросом?
The Z80 instructions parsing is quite heavily baked into the code, so it's not super simple to change it to other CPU (like just replacing some table, you have to write the code for instructions parsing). And the parsing helper functions are not 100% beautiful with amazing API, although it's getting very slowly better, but I'm not going to do big rewrite for v1.x of sjasmplus, because of lack of time.
If you don't mind any of this, and you want to write the 6800/1801BM1 instructions parser, I believe the rest of the assembler will mostly fit nicely along, and in case of some hard friction I can help.
I'm not going to do the 6800 myself, because I have no experience with the CPU and no spare time for this, but I would welcome (and help with final details) pull request if the changes would be reasonably confined, covered well with automated tests and there would be done some research between current 6800/1801BM1 developers what syntax is useful and acceptable... It's just not in my interest, so I basically don't care too much, except helping with the final stage.
https://github.com/z00m128/sjasmplus/releases/tag/v1.14.5
v1.14.5 changelog:
* fix crash when opening source file fails
* DISP / ORG warns about being used inside DISP block (also docs extended)
Shadow Maker
03.02.2020, 00:10
Ped7g could you add to your fork this patch to support 2 more commands for interactive debugging? https://zx-pk.ru/threads/9361-breakpoints-v-svyazke-sjasmplus-unrealspeccy.html?p=178902&viewfull=1#post178902 Not the patch per se, but the main idea to create a file with list of breakpoints.
Ped7g could you add to your fork this patch to support 2 more commands for interactive debugging? https://zx-pk.ru/threads/9361-breakpoints-v-svyazke-sjasmplus-unrealspeccy.html?p=178902&viewfull=1#post178902 Not the patch per se, but the main idea to create a file with list of breakpoints.
Sure I can.
But I spent about 1h reviewing the patch and web, and I got to a point where I am a bit confused.
The old patch seems to create file with list of 4-character long hexa addresses, i.e.:
1234
BCDE
I have very little idea about what is the current version of unreal and it's specifications, but if I would guess by this project:
https://github.com/mkoloberdin/unrealspeccy/blob/master/dbgbpx.cpp#L679
the breakpoints file format is now more complicated, allowing for various conditional expressions, but just simple 4char hexa data will be not read at all.
Can you please confirm what kind of breakpoints file can be used with what emulator, and at which version? Should I add the original form from patch? Would it help to add also some new form compatible with that parser in source I link above?
I'm planning to add also ZEsarUX type of output, which will look like this (and can be used by mixing it into the command line while launching the emulator):
--enable-breakpoints --set-breakpoint 1 "PC=1234h" --set-breakpoint 2 "PC=0BCDEh"
Maybe I can even add support for any-expression (the ZEsarUX allows for something like "PC=1234 AND B=255 AND C=123", etc...), although I'm not sure how useful that will be, if I will add it, I will probably not verify the syntax too much, so it will require good knowledge of emulator on the side of the coder writing asm, to use it correctly.
Also with the machines having extra memory beyond 64kiB address range, if you can give me info how to add also memory paging info to the breakpoint, it will be even better (I'm not even sure how to do that in ZEsarUX, will take a look, maybe it does support something like "PC=... AND somethingLikeMemoryPage=...", or I can ask Cesar to add it maybe... (just talking loud while thinking).
...
So, please specify correct format with list of emulator+version which supports it, so I can add that to documentation, and add examples of different types of breakpoints output for different emulators. And some examples how the output file should look (please make it explicit if hexa values like "BCDE" need initial zero or not, and if they need suffix/prefix like 0xBCDE or 0BCDEh - the old patch seems to produce only "BCDE"? That's a bit weird.)
Thanks.
Shadow Maker
03.02.2020, 14:13
Sure I can.
But I spent about 1h reviewing the patch and web, and I got to a point where I am a bit confused.
The old patch seems to create file with list of 4-character long hexa addresses, i.e.:
1234
BCDE
I have very little idea about what is the current version of unreal and it's specifications, but if I would guess by this project:
https://github.com/mkoloberdin/unrealspeccy/blob/master/dbgbpx.cpp#L679
the breakpoints file format is now more complicated, allowing for various conditional expressions, but just simple 4char hexa data will be not read at all.
Can you please confirm what kind of breakpoints file can be used with what emulator, and at which version? Should I add the original form from patch? Would it help to add also some new form compatible with that parser in source I link above?
I'm planning to add also ZEsarUX type of output, which will look like this (and can be used by mixing it into the command line while launching the emulator):
--enable-breakpoints --set-breakpoint 1 "PC=1234h" --set-breakpoint 2 "PC=0BCDEh"
Maybe I can even add support for any-expression (the ZEsarUX allows for something like "PC=1234 AND B=255 AND C=123", etc...), although I'm not sure how useful that will be, if I will add it, I will probably not verify the syntax too much, so it will require good knowledge of emulator on the side of the coder writing asm, to use it correctly.
Also with the machines having extra memory beyond 64kiB address range, if you can give me info how to add also memory paging info to the breakpoint, it will be even better (I'm not even sure how to do that in ZEsarUX, will take a look, maybe it does support something like "PC=... AND somethingLikeMemoryPage=...", or I can ask Cesar to add it maybe... (just talking loud while thinking).
...
So, please specify correct format with list of emulator+version which supports it, so I can add that to documentation, and add examples of different types of breakpoints output for different emulators. And some examples how the output file should look (please make it explicit if hexa values like "BCDE" need initial zero or not, and if they need suffix/prefix like 0xBCDE or 0BCDEh - the old patch seems to produce only "BCDE"? That's a bit weird.)
Thanks.
Basically it is same as ZEsarUX PC=1234h. Of course breakpoints support conditionals and stuff, but realistically speaking, when you develop in assembler, then all you would need is a PC breakpoint, to stop on the exact routine you want to develop. Anything complex would be not really usable through the assembler and would be done through debugger itself (I am speaking about my own experience, it can vary between coders I think, but I really fail to see usability of complex breakpoints inside the assembler - you generally set them while you are deep in debugging, and you do not know the conditions when you write the code, and usually you find these conditions when you debugged a lot from the starting point, so you would not really need such breakpoint, as, naturally, you're right now is in correct place and in debugger already, not in assembler).
So, this format works good enough. You cannot set a breakpoint to a precise page in Unreal (IIRC, maybe it is different now, but I think no), so nothing really complex is needed. It is just a plain format, it treats any number as hex, so 4 characters is enough (Unreal works with hex only, so no need in prefixes). In any case, if something more complicated would be needed, we can extend the format further later.
I think latest Unreal source codes are here http://dlcorp.nedopc.com/viewtopic.php?f=27&t=1525 but there are tons of forks nowadays, so hard to tell.
Basically it is same as ZEsarUX PC=1234h.
...
I think latest Unreal source codes are here http://dlcorp.nedopc.com/viewtopic.php?f=27&t=1525 but there are tons of forks nowadays, so hard to tell.
So I downloaded the `us0.39.0.src.7z`, and checked quickly the source (not full of course, I'm not *that* fast), and I don't see any code capable to load file like this:
1234
BCDE
So I believe that old patch format is not usable with latest unreal (but also from unreal changelog I can't easily guess which old versions of unreal did support such simple format).
If you have some emulator which works with such simple breakpoint file, please try it to be 100% sure, and then post the emulator name + version - otherwise I think this format is useless and I'm not going to add it.
The 0.39 emulator seems to expect file like this (reading the source in text editor, so not sure if it is using regular clib "sscanf" or some custom-patched which will then read different things):
r0=0x1234-0xBCDE
x1=07654
w0=12345
Notice the values have prefixes (and "07654" is octal value 4012 and "12345" is DECIMAL!).
First character must be one of "r, w, x" (I guess it's read-mem, write-mem, exec-instruction type?).
Second character is single digit to select index of CPU. The two address values form a range (if only start of range is specified, then end of range is equal to start).
(EDIT: this range is not sanitized everywhere, so it can cause segfault if you specify large number in the file
- but also it may mean it can set breakpoint to large memory, if the variable "cpu.membits" is more than 64kiB, but I'm not going to hunt this down, would need to open the project in regular IDE first)
I.e. this again does not match your info. I don't need "like/similar" info, I need *precise* info (I don't know how to run unreal emulator, and I'm not going to spend another day trying to compile it and to learn how to use it and looking for some test files or rom files, etc... => so I can't try these things by myself easile => not easy, not happening soon)
From the source of 0.39 and help files there seems to be some debugger console or something, where it is maybe possible to export/save current breakpoints (there is SaveBpx() function).
Can you try open some app in the emulator, add few breakpoints at two-three addresses (like 0x1234 / 0xBCDE), and export them, and then post the resulting "bpx.ini" here?
Or try to build the "bpx.ini" file the way how I'm describing it above (trying out also different prefixes for octal/hexa/decimal), and try to load that into emulator, if it loads correctly.
Or if some other format works for you, then just confirm it works with that unreal 0.39 and post example file which was working (if you can even find source code parsing the file, that will be excellent, because I did find so far only these "bpx.ini" parsers).
Shadow Maker
03.02.2020, 21:51
So I downloaded the `us0.39.0.src.7z`, and checked quickly the source (not full of course, I'm not *that* fast), and I don't see any code capable to load file like this:
Or if some other format works for you, then just confirm it works with that unreal 0.39 and post example file which was working (if you can even find source code parsing the file, that will be excellent, because I did find so far only these "bpx.ini" parsers).
Yes, you're right, format was changed while I was not aware. Sorry for that. I used outdated build.
So yes, format is as you told:
r0=0x1000-0x1100
r - breakpoint would execute on r/w/x
0 - always 0
Why do you want to compile it from source files? There is binary right next to them http://dlcorp.nedopc.com/download/file.php?id=3013 You can run it just executing "unreal.exe"... or "wine unreal.exe" if you're not using windows...
Example of bpx.ini I want:
x0=0x5FFB
x0=0x70EF
x0=0x7246
x - means execution breakpoint (could be r for memory read breakpoint or w for write memory breakpoint)
0 - always 0 for spectrum breakpoint
If you want, I can attach it as a file, but it is really same, I just copy-pasted from existing working bpx.ini
So basically it is same as what I told before, but with static x0=0x for every line. It is also possible to make an area breakpoint like x0=0x5000-0x6000 but I do not think this have much use, but it is up to you. You can also support type of breakpoint (r/w/x).
Regarding system - I suppose you can use any of these according to
int n = sscanf(Line, "%c%1d=%i-%i", &Type, &CpuIdx, &Start, &End); but Unreal itself uses hexadecimal notation, when you save breakpoints, so I suppose better to use hex.
Did I describe everything clear?
"Why do you want to compile it from source files? There is binary right next to them http://dlcorp.nedopc.com/download/file.php?id=3013 You can run it just executing "unreal.exe"... or "wine unreal.exe" if you're not using windows..."
I prefer to be able to rebuild the project, so I can also debug it or modify for experiments... but even bigger issue is the "exe", I don't have windows, and my "wine" config is kinda flaky and broken, as I don't use it very often and can't remember what experiments I did with it, but I can't run windows executables easily... Anyway, it would highly likely take me at least half a day to make it work and to learn how to use it, probably whole day.
So it's quicker just to take a look at the source code and let *you* confirm if I understand correctly how it works :)
The new info is perfect, now I'm sure the code I have seen is used, and I did understand it correctly, so I know how to produce working bpx.ini from sjasmplus.
If you will pull latest sources of sjasmplus from github, it's now implemented.
(check the last commit and new asm test files to see the usage, the docs are not updated yet... next thing to do)
Shadow Maker
03.02.2020, 23:35
"Why do you want to compile it from source files? There is binary right next to them http://dlcorp.nedopc.com/download/file.php?id=3013 You can run it just executing "unreal.exe"... or "wine unreal.exe" if you're not using windows..."
I prefer to be able to rebuild the project, so I can also debug it or modify for experiments... but even bigger issue is the "exe", I don't have windows, and my "wine" config is kinda flaky and broken, as I don't use it very often and can't remember what experiments I did with it, but I can't run windows executables easily... Anyway, it would highly likely take me at least half a day to make it work and to learn how to use it, probably whole day.
You're very optimistic. You cannot make unreal working in any other OS, as it is strongly tied to WinAPI :( But I would use it gladly if you really make it working. (PS: yes, I understand that you mean wine, not unreal, I told it just to illustrate that it is windows-only tool and no point in trying to compile it anyway).
So it's quicker just to take a look at the source code and let *you* confirm if I understand correctly how it works :)
Actually I also do not use windows for years. So I am in the same boat, I am using wine for that. But as I was the one who asked for it... I did not have a choice, I guess? :)
The new info is perfect, now I'm sure the code I have seen is used, and I did understand it correctly, so I know how to produce working bpx.ini from sjasmplus.
If you will pull latest sources of sjasmplus from github, it's now implemented.
(check the last commit and new asm test files to see the usage, the docs are not updated yet... next thing to do)
Ok, thanks. I will take a look, but on weekend. Maybe you will write update the doc in meantime, hehe :)
yup, docs are now added and uploaded too.
I did test the ZEsarUX mode myself, had to patch the ZEsarUX a bit as it's currently not working as expected with the command line options (loading the snapshot from command line will disable breakpoints, so I patched it in my fork). Anyway, the command line options outputted by sjasmplus are correct, so the sjasmplus part is done.
I will not test the Unreal myself, but the content of file seems to me correct, so let me know if it fails for some reason.
Shadow Maker
04.02.2020, 00:37
yup, docs are now added and uploaded too.
I did test the ZEsarUX mode myself, had to patch the ZEsarUX a bit as it's currently not working as expected with the command line options (loading the snapshot from command line will disable breakpoints, so I patched it in my fork). Anyway, the command line options outputted by sjasmplus are correct, so the sjasmplus part is done.
I will not test the Unreal myself, but the content of file seems to me correct, so let me know if it fails for some reason.
Sure, thanks. Will test on weekend and will send you a message here with results.
NEO SPECTRUMAN
18.02.2020, 15:35
Ped7g, а можно сделать отдельный
i Case insensitive instructions/directives
для названий макросов, меток итд ?
то есть нужно чтоб компилировало
macro aaa
nop
endm
bbb = 3
l1
AAa
aAA
AAA
aaa
jp l1
jp L1
ld a,bbb
ld a,BBB
как
macro aaa
nop
endm
bbb = 3
l1
aaa
aaa
aaa
aaa
jp l1
jp l1
ld a,bbb
ld a,bbb
или мне приходится городить
macro AAa
macro aAA
macro AAA
macro aaa
для каждой комбинации символов...
так как я не могу предсказать какая комбинация попадется
нужно для моего набора макросов для компиляции chip8 кода
щас у меня это выглядит так...
macro scleft ;00FC SCLEFT
defb $00, $FC
endm
macro SCLEFT
defb $00, $FC
endm
macro scl
defb $00, $FC
endm
macro SCL
defb $00, $FC
endm
и работать с таким исходником очень не удобно
так же у всех команд окончание выглядит как e*** end***
dup
edup
if
endif
а
macro
endm (что совершенно не логично)
хотелось бы чтобы асм переваривал все варианты окончания команды
dup edup enddup
if eif endif
macro emacro endmacro
итд
так же не помешало бы
кроме
$ current program counter
$$ current page at program counter (in virtual device mode)
еще иметь и
$$$ current code line number
чтоб использовать так
1 macro aaa b
2 if (b) > $FFF
3 display $$$," error"
4 endif
5 defb b
6 endm
7
8 aaa $FFE
9 aaa $1000
чтобы выдавало
>9 error
Unfortunately the "syntax=i" does exist because it was reasonably easy to add to current code.
The planned "I" for labels, and making the "i" or "I" affect also macros and defines is surprisingly high-friction in current sjasmplus.
I will take a look again, what is the exact problem, but it did look to me it's lot less problematic to fix the asm source to use correct case, than add case insensitivity to labels/macros. But maybe I just didn't find the simple solution.
"endX" vs "eX" - I agree with your idea, to bring better consistency into the "language", but code written for sjasmplus already does use current keywords, and just adding dozen new keywords for future will maybe break someone source (if they use the keyword as label or macro name), and will make even bigger mess.
I think I will keep this as compatibility-breaking change for v2.x, if it ever happens (cleaning up the directives keyword, maybe even removing some duplicities like rept vs dup, and similar), as the v2.x will be presented as not 100% compatible (there will be more syntax changes, not big, but enough to break old sources).
But I have still no idea when v2.x will happen, currently I have no time and no energy/incentive to work on it, the v1.x is quite OK currently. I don't like everything about it, but I can live with the current version.
The "$$$" is the only simple thing to add, which also looks like it would not break anything, but if I will add it, I think I would prefer the GCC-ification of it, i.e. __LINE__, __FILE__, etc... to copy the standard C/C++ macros when possible. I'm pretty sure I even have __LINE__ somewhere in my notes for v2.x.
... so, thanks for ideas, it's increasing priority of some things I have in plans, but I don't have any particular date when these things will happen.
-------------------
Meanwhile the next version will be v1.15.0, the planned changes so far:
- reworking the virtual device state for zx48/zx128+ to make the virtual memory closer to the fake "CLEAR x : LOAD "" CODE : RANDOMIZE USR y" state, which will change SAVESNA snapshot binaries (will hopefully break only minimum of projects, but fix the few issues I have seen recently, like the ROM keyboard routine reading BASIC keywords instead of characters, or the examples/Fros4k intro was broken in v1.13.0..v1.14.4 because the snapshot stack was $FFxx, in older versions it was $6000 ... after new changes it will be around $5D00 or something like that (impossibly low fake CLEAR).
- hopefully the larger memory spectrum-like devices, if I don't forget about it again
- maybe removing few more VS-specific calls and using the same source under every compiler
... I was hoping to release v1.15.0 around end of Feb initially, but currently I have no time to develop sjasmplus, so maybe toward end of March or April.
(and I will check again, if there's some simple trick for case insensitive macros, but I can't promise anything, last time the code did look very fragile and difficult to modify without affecting the assembling speed a lot)
BTW, about assembling speed... I was for fun trying out older versions, and seems the v1.14.5 is about two times slower than 1.10.4 ... Then again I personally prefer +0.2s per assembling instead of +100 bugs in assembler... :D
NEO SPECTRUMAN
19.02.2020, 16:50
И еще
можно сделать игнорирование ошибок?
error: Not enough arguments for macro:
error: Too many arguments for macro:
и продолжать использовать макрос несмотря не на что
в sjasm-е всегда не хватало макросов с переменным числом аргументов
сейчас сделав так
macro mc xx
cc = xx
ld a,cc
endm
mc 3
mc
этим можно пользоваться и пытаться отличать макрос с аргументом от макроса без аргумента
не смотря на ошибки
184+ 0286 mc 3
184+ 0286 >cc = 3
184+ 0286 3E 03 > ld a,cc
184+ 0288 >
185+ 0288 ;ld a,3
test_code.asm(186): warning: [Macro argument parser] empty value:
186+ 0288 mc
test_code.asm(175): error: Expression error:
test_code.asm(186): ^ emitted from here
186+ 0288 >cc =
186+ 0288 3E 00 > ld a,cc
186+ 028A >
187+ 028A ;ld a,0
а вот повторить такое же с
macro mc xx,yy
уже не получается
(когда делаешь только mc xx)
сразу сыпяться
error: Not enough arguments for macro:
и макрос даже не копируется
test_code.asm(184): error: Not enough arguments for macro: mc
184+ 0286 mc 3
185+ 0286 ;ld a,3
test_code.asm(186): warning: [Macro argument parser] empty value:
test_code.asm(186): error: Not enough arguments for macro: mc
186+ 0286 mc
187+ 0286 ;ld a,0
так же была бы полезно иметь
проверку есть ли аргумент или нет
macro mc a,b,c,d
ifdef a
ifdef b
ifnotdef c
xor a
endif
endif
endif
ifdef a
ifdef b
ifdef c
ifnotdef d
xor b
endif
endif
endif
endif
mc a.b
;xor a
mc a,b,c
;xor b
yep, definitely variable-arguments for macros are on my TODO list, but it always felt to me this is "v2.x" feature, because it's both quite some work to implement it, and I'm worried about backward syntax compatibility (although I guess correct v1.15.0 syntax would not trigger macro var-args feature by accident, so it's just FUD on my side?). I guess it's mostly my feel that this needs serious amount of work, also adding new operators to manipulate with the var-arg list (some kind of "shift" operator), and needs good syntax design - I don't think I will add these as some kind of quick-hack to v1.x in hurry.
(of course if somebody will show me reasonable pull request with nice implementation and prove me wrong in terms of syntax-clash fear, it would be very nice addition to current sjasmplus)
NEO SPECTRUMAN
20.02.2020, 21:23
I don't think I will add these as some kind of quick-hack to v1.x in hurry.
Но переменное число аргументов
работает уже сейчас
если число аргументов 0...1
пример я дал выше
такой код сейчас вроде работает
не смотря на то что выводятся ошибки (и это меня устраивает :) )
macro mc xx
cc = xx
if cc = 0
ld a,1
else
xor cc
endif
endm
правда он не отличает
mc 0 от mc
дальше все упирается в то что
sjasm не использует макрос
когда у макроса 2 аргумента
а 1 из них не указан
можно было бы просто выдавать ошибку
но продолжать использовать макрос
и на обратную совместимость это бы не повлияло
наверно
не смотря на то что выводятся ошибки (и это меня устраивает )
А может все проще сделать?? :)) Чем городить огород из макросов, может проще попросить автора впилить поддержку асм-а? там то команд 36 штук. Всего-ничего. для некст-а же он сделал.
Только мнемонику все же какую то определенно-распространенную сделать, а то мне как минимум три варианта попалось.
NEO SPECTRUMAN
20.02.2020, 21:58
А может все проще сделать??
по моему он где то говорил
что не особо горит желанием делать отдельный новый асм
а поддержал только те что очень похожи на асм z80
и где не нужно было много дополнительной работы
Только мнемонику все же какую то определенно-распространенную сделать, а то мне как минимум три варианта попалось.
лично я за поддержку всех существующих и не конфликтующих между собой мнемоник
ну а я знаю 4 варианта :)
в придачу там
разные трактования некоторых команд
и требуются дополнительные опции у компилятора
ну а я знаю 4 варианта
онлайн асм-дизасм попадался со своей мнемоникой?? ну и в анб-шной гидре тоже своя мнемоника.
ну нет, так нет. оффтоп это тут)
NEO SPECTRUMAN
20.02.2020, 22:26
онлайн асм-дизасм попадался со своей мнемоникой??
угу
зоветсо octo
у него даже не асм а редкостное неизвестно что
v0 := va
v1 := vb
v2 := vc
v3 := vd
i := player-position
save v3
пришлось ручками переписывать ВСЁ под свой асм
mov V0,VA
mov V1,VB
mov V2,VC
mov V3,VD
mvi player_position
str v0-V3
(по моему я ругался на этот счет в текстовичках самого nschip-а :) )
ну и в его комплекте
жменя софтварей
которые работают только в самом octo
там вообще не удосужились прочитать мануалы
и сделали по своему...
...но та софтварь по качеству на уровень выше
чем все что было выпущено до этого
зоветсо octo
Нее, мне внешне этот понравился, 3-в-1, но то жи своя мнемоника
http://adrianton3.github.io/chip8/src/assembler/assembler.html
Shadow Maker
21.02.2020, 01:00
Вы прям как не программисты, уж конверторы мнемоник текста туда-сюда написать можно на коленке за пять минут.
NEO SPECTRUMAN
21.02.2020, 01:11
можно на коленке за пять минут.
у меня для кодинга на ПЦ
только FASM :v2_dizzy_biggrin2:
а я вообще не программист, так, мимо проходил. А был бы программистом, то бы в гидре отредактировал файлек chip8.slaspec, чтобы он дизасмил и сразу правильно транслировал в мнемоники от NS. но, увы :(((
the 0 vs 1 argument is known bug to me, but there's no simple fix... and *some* error is displayed ("wrong" one, but that's not critical for me).
I'm glad you are posting suggestions and feedback. But my original goal was to write some ZX Next SW, so I just did need some decent Z80 assembler (and I use almost exclusively only open source SW for last ~15 years, so Zeus was not an option for me) ... then the czech/slovak scene guys tricked me into taking a short look at sjasmplus source code... and what has been seen can't be unseen ... so I ended up fixing sjasmplus, instead of writing Z80 asm projects.
Now it's mostly "good enough" for me, you can still expect some bugfixes happen and new versions released, but if you really want some big change, rather start working on it yourself, my days have only 24h unfortunately, and I even need to sleep sometimes.. and do the paid-work too.
If my goal would be "create best Z80 assembler", I would be already working on "sjasmplus2", but not now... maybe couple of years later. :)
Shadow Maker
21.02.2020, 18:26
the 0 vs 1 argument is known bug to me, but there's no simple fix... and *some* error is displayed ("wrong" one, but that's not critical for me).
I'm glad you are posting suggestions and feedback. But my original goal was to write some ZX Next SW, so I just did need some decent Z80 assembler (and I use almost exclusively only open source SW for last ~15 years, so Zeus was not an option for me) ... then the czech/slovak scene guys tricked me into taking a short look at sjasmplus source code... and what has been seen can't be unseen ... so I ended up fixing sjasmplus, instead of writing Z80 asm projects.
Now it's mostly "good enough" for me, you can still expect some bugfixes happen and new versions released, but if you really want some big change, rather start working on it yourself, my days have only 24h unfortunately, and I even need to sleep sometimes.. and do the paid-work too.
If my goal would be "create best Z80 assembler", I would be already working on "sjasmplus2", but not now... maybe couple of years later. :)
Worry not, that's good that you're working on fixes, as it was in stall condition for years without any bugfixes. It is already in quite decent state, so tidying the bugs and/or upgrades sometimes is more than enough by me.
- - - Добавлено - - -
а я вообще не программист, так, мимо проходил. А был бы программистом, то бы в гидре отредактировал файлек chip8.slaspec, чтобы он дизасмил и сразу правильно транслировал в мнемоники от NS. но, увы :(((
Не надо для этого быть программистом, надо просто доку почитать. Там одни плюсы, ифы и goto.
- - - Добавлено - - -
у меня для кодинга на ПЦ
только FASM :v2_dizzy_biggrin2:
А как же powershell? Да даже в батниках небось можно конвертор сделать.
давно хотел попросить, но толи забывал, толи стеснялся... в общем. почему бы не добавить в компилятор тестер тактов? например, директива подобная .display, указали начало тестируемого блока и конец и в процессе сборки кода компилятор выдавал бы количество тактов в указанном блоке.
NEO SPECTRUMAN
22.02.2020, 06:59
указали начало тестируемого блока и конец и в процессе сборки кода компилятор выдавал бы количество тактов в указанном блоке.
а как компилятор отличит за сколько выполняется
jp nz,xxxx
или тот же
ldir ?
разве что совсем грубый подсчет
и когда нет ветвлений
давно хотел попросить, но толи забывал, толи стеснялся... в общем. почему бы не добавить в компилятор тестер тактов? например, директива подобная .display, указали начало тестируемого блока и конец и в процессе сборки кода компилятор выдавал бы количество тактов в указанном блоке.
There is some plugin for VSC https://github.com/theNestruo/z80-asm-meter-vscode which can calculate ticks in selected block (I believe, I don't use VSC (yet), so I only heard about this).
I'm also thinking about adding ticks in the listing file + disassembly of produced machine code like some 6502 assembler has, but I guess it would be only single instruction related, not trying to interpret whole blocks. I don't think assembler should be too smart about this, its main task is assembling, but it can produce good raw data, to be processed by further tools/scripts -> but not anytime soon, as this will break current tools parsing sjasmplus listing, like https://github.com/maziac/DeZog (again VSC related... I'm really tempted to try it out, although I generally avoid MS software as much as possible ... also I heard the whole solution is currently unstable and needs some more fixing, mostly on ZEsarUX side, but I love the concept and I guess the bugs will be fixed over time). So this is again mostly in the "v2.x" ideas list.
NEO SPECTRUMAN
03.03.2020, 17:11
Ped7g, что то похожее на баг репорт
macro mcr ccc
if ccc = 9
nop
endif
endm
label1 nop
mcr label1
mcr label2 ;< [IF/IFN] Forward reference
label2 nop
SjASMPlus Z80 Cross-Assembler v1.11.0
SjASMPlus Z80 Cross-Assembler v1.12.0
SjASMPlus Z80 Cross-Assembler v1.13.1
SjASMPlus Z80 Cross-Assembler v1.13.2
без ошибок
SjASMPlus Z80 Cross-Assembler v1.13.3
SjASMPlus Z80 Cross-Assembler v1.14.0
SjASMPlus Z80 Cross-Assembler v1.14.3
sjchipasm.asm(1674): error: [IF/IFN] Forward reference: if label2 = 9
SjASMPlus Z80 Cross-Assembler v1.14.5
sjchipasm.asm(1662): error: [IF/IFN] Forward reference: if label2 = 9
sjchipasm.asm(1674): ^ emitted from here
даже так
if ccc = 9
nop
endif
ccc nop
- - - Добавлено - - -
хотя это только в первом проходе
но когда их сыпется 100500 штук
они мешают заметить другие более важные ошибки
- - - Добавлено - - -
ну и было бы полезно иметь
opt --msg=none
чтобы скрывать кучу ошибок в части кода
если то нельзя поправить
I guess you simplified the example, but so much, that it doesn't make sense to me.
The code will in 1.13.2 emit error:
"Issue_fwd_ref_in_macro.asm(13): warning: Label has different value in pass 3: previous value 10 not equal 9"
if label2 is 9 (put "org 8" ahead of "label1 nop" line). It's no error only when the condition is always false. If you know it's always false, you can just delete the macro. If it's true sometimes, it will produce error even in older versions (didn't check how many of them, but as the code is wrong, the error should be there).
The later versions just warn you about the problem sooner and more consistently.
The forward-references can be sometimes worked out in multi-pass assemblers, but you can still produce code which will never settle down, like:
ORG 9
IF label = 9
nop
ENDIF
label nop
This will in every odd pass get "false" in IF and set label to 9, and in every even pass then the IF is "true" and label becomes 10, this will never settle down, even in multi-pass assembler = this source can't be assembled.
So I don't understand what are you trying to achieve, but as sjasmplus is only 3-pass assembler, you should write source in a way to produce stable amount of machine code through all three passes (especially second pass must produce same amount of machine code as third pass, some changes after first pass may work, if you know what you are doing).
if those label1/label2 are more like config-constants affecting which parts of code are produced, define them ahead of the first macro usage.
if they are really labels inside the code and the IF block can move them, then you should rethink your code architecture to avoid the forward-reference, as it's not clear what is the correct output in such case (even to me, and of course not to assembler).
The small examples - as is - doesn't make sense, you can just delete the macros completely, they don't do anything useful. (I guess the true purpose was lost as you tried to make it small)
NEO SPECTRUMAN
04.03.2020, 09:45
I guess you simplified the example, but so much, that it doesn't make sense to me.
так и есть
вот настоящий макрос
тут используется для определения ошибок типа
mvi $FFFF
которые будут заменены на mvi $FFF при компиляции
macro mvi ch8_xxx ;Axxx MVI xxx
if (ch8_xxx) > $FFF
display $," error mvi > $FFF (",ch8_xx,")"
endif
defb ($A0 + ($0F and (high (ch8_xx)))), (low (ch8_xx))
endm
вот кусок реального кода
весь на подобных макросах с проверками "правильности"
sne v9,0x1 ;
ld v4,0x1
add v9,v4 ;
drw v0,v9,6
add v0,0x9 ; адрес след знакоместа
mvi SPRITE_05
drw v0,va,6
sne va,0x14
ld v5,0xff
SPRITE_05
db 00111100b ; ; 8
db 11000011b ;
db 00111100b ;
db 11000011b ;
db 11000011b ;
db 00111100b ;
потом сыпется куча ошибок
которые по сути не ошибки
(это было бы ошибкой на 3 проходе
на 1-м это еще не ошибка)
https://jpegshare.net/images/b0/09/b0094dcad7118c45bc3410b3808334b1.png
среди которых тяжело увидеть более важные "настоящие" ошибки
in older versions
в старых версиях SjASMPlus Z80 Cross-Assembler v1.07 RC7 (build 02-04-2008)
это тоже было
error: [IF] Forward reference
ну и проблему можно было бы решать
временным включением opt --msg=none
которого сейчас нет
да и в принципе хотелось бы иметь возможность
менять все параметры на ходу через opt
а не только одни
--nofakes, --syntax, --zxnext, --reversepop and --dirbol.
Hm, this is quite good example when the test is safe (not emitting any machine code bytes, so forward-reference is not a problem).
possible workarounds:
- define sprites earlier in the assembling, so the labels are known ahead
- or use ASSERT instead of IF + DISPLAY to report errors
macro mvi ch8_xxx ;Axxx MVI xxx
assert ch8_xxx <= $FFF
defb ($A0 + ($0F and (high (ch8_xx)))), (low (ch8_xx))
endm
I don't think I can easily change `--msg` mode for small part of source, but I can probably suppress warnings/errors (i.e. making it more silent is possible, making it more vocal like switching on listing-mode would be probably impossible) ... so I will think about it a bit more, but I'm not a great fan of this solution at this moment.
I'm sort of more interested into making "forward-reference" error automatically silent, if there is no real damage (like your example of "DISPLAY" function), that would make all the conditional assembling more powerful and useful, I'm taking note about this.
Cheers.
NEO SPECTRUMAN
05.03.2020, 06:47
- define sprites earlier in the assembling, so the labels are known ahead
ну это легко может быть disasm-ом чужого кода
где результат должен с точностью совпадать
- or use ASSERT instead of IF + DISPLAY to report errors
но с if + display
можно написать в какой именно команде ошибка
а assert немногословен
sjchipasm.asm(1053): error: [ASSERT] Assertion failed: $FFFF <= $FFF
sjchipasm.asm(1714): ^ emitted from here
вот как сейчас
https://jpegshare.net/images/79/32/7932308944d9b1c501da3effbc76e043.png
ну это легко может быть disasm-ом чужого кода
где результат должен с точностью совпадать
If you are using the virtual DEVICE memory, you can position the resulting gfx data with ORG (and after that use other ORG for code), so it is *possible* to move their definition ahead and get same binary output in the end (it's about assembling order, not about memory position).
I'm not claiming it's easy, or pretty, or that it is possible to do this with every project, but most of the time it's at least possible to use this kind of workaround. (edit: the whole point of "workaround" is, that you can use it *now*, while if I will fix anything in the sjasmplus, you must wait for my fix, and then if you don't compile sjasmplus from source, you need to wait for release, so I'm posting here possible workaround to give you at least not-nice solution for this moment, I don't want you to be stuck)
About display -> well, since v1.14.5 there is that "emitted from here" error, which brings you in editor directly on the macro invocation, like "mvi $FFFF"). Now the errors in macro produce two error lines, so I can easily switch in the editor between the lines. I guess you are using editor which doesn't parse the error output of sjasmplus, so you can't navigate through error list quickly? Then having display message would be probably better. But I would rather check how to parse the errors with your text editor, so you can use the list of errors. I could probably also show full line at the "emitted" error, but it felt to me like too much noise (for me the "display" errors are useless, as those are not parsed by the text editor, so I would definitely prefer ASSERT in my own code).
Anyway I still think relaxing the forward-reference errors a bit would be best in the end, making also your example work, but it would also support many other use-cases... The forward-reference can be a real problem, so I can't remove it completely, but making the check smarter to report only cases when some damage happens would be better.
ну это легко может быть disasm-ом чужого кода
где результат должен с точностью совпадать
So, I tried to implement smart detection of IF/IFN blocks which are unstable because of forward-reference, and I had to give up, it's too complicated in current sjasmplus architecture.
So instead I did change the error to warning, and you can suppress it explicitly with the "ok" comment at end of line, if you are sure you know what you are doing, i.e. in your example:
macro mvi ch8_xxx ;Axxx MVI xxx
if (ch8_xxx) > $FFF ; ok - forward reference warning suppressed
display $," error mvi > $FFF (",ch8_xx,")"
endif
defb ($A0 + ($0F and (high (ch8_xx)))), (low (ch8_xx))
endm
So I'm delegating the responsibility to use the IF/IFN correctly to the programmer. After all, it's assembly, if the programmer wants to shoot himself into foot, the assembler should help to pick the biggest gun possible, not stop him... :)
Will be released in v1.15.0 (probably in a week or two) (and I will push it in few minutes to the github, if you want to build from sources the work-in-progress version).
NEO SPECTRUMAN
09.03.2020, 04:44
"ok"
может лучше
"ignore forward reference warning"
или
"warning skip"
"not error"
или что то в этом духе
такое уже нельзя будет вписать случайно
не зная что оно делает
"ok" может случайно оказаться обычным коментарием
и потом не выдать нужную ошибку :)
- - - Добавлено - - -
на случай если нельзя пробел
"errorless"
и такая функция
наверно была бы полезна
для многих других команд
the "ok" comment is already used by other warnings (low memory access, fake instruction, and something else) and I'm thinking about making it general mechanism for *all* warnings in v2.x
I will think about the choice of the word, but:
a) I don't expect that many accidental "ok" in comments of assembly source (you can search all your sources and tell me if you did find some?)
b) if you know about sjasmplus using it to suppress warnings, it's even less likely you will write it by accident
The longer words will eat more comments space, and warning-specific words will be difficult to remember (what to use to suppress the warning), so I did like "ok" for this, but I'm taking a note and will think about it more.
about searching your sources:
The regex for search can be like "(;|//)\s*ok", that may find few false positives like some string or full-line comment, but you could easily tell which is serious. I did run it over sjasmplus directory, and there are two lines "DB #FF ; OK" in BS-ROM bios source code, other "ok" comments were in tests, testing the warning suppression mechanism. Looks to me quite ok, I'm not worried about causing too much damage by this, but if few more people can search through their code base and report how many end-line comments with "ok" they have in old sources, it may change my mind.
NEO SPECTRUMAN
09.03.2020, 14:08
"ok" for this, but I'm taking a note and will think about it more.
например "ok" можно поставить возле отлаженной рабочей части когда
которую уже не нужно трогать
"ok" может быть что либо в самой программе
https://excelpedia.ru/wp-content/uploads/2019/02/kartinka-4.png
и может быть лекго поставлено в части кода
которое это "ОК" обрабатывает
есть вероятность что его напишут не зная что это отменяет ошибки
- - - Добавлено - - -
b) if you know about sjasmplus using it to suppress warnings, it's even less likely you will write it by accident
ну я только о нем узнал
инструкция для sjasmplus большая и часто обновляемая
для того чтобы ее хорошо знать всю
я часто туда заглядываю для дополнительных уточнений
- - - Добавлено - - -
вощем предлагаю подумать еще в пользу "errorless"
или другое слово
которое обозначает явную отмену или отсутствие ошибок
вот такайя строка
cad82 defb 'Input machine\'s name', 0
компилицца во всех приличных версиях sjasmplus без ошибок. Кроме этой ветки.
Что теперь не так в этой версии и что делать? (с)
вот такайя строка
cad82 defb 'Input machine\'s name', 0
компилицца во всех приличных версиях sjasmplus без ошибок. Кроме этой ветки.
Что теперь не так в этой версии и что делать? (с)
v1.11.0 change, the docs claimed the apostrophe strings are not parsed for escape chars, so I fixed the assembler.. and added the double apostrophe as extra escape sequence: http://z00m128.github.io/sjasmplus/documentation.html#s_numeric (a bit down, Example 4.1)
Sorry for the inconvenience. (in the distant future, in v2.x version - if it ever happens - I plan to align the assembler even more with C++, bringing back the backslash escaping of single apostrophe, but I'm not planning to modify this further for v1.x versions)
But in this case you can just use double quotes (this should be compatible with all different variants of sjasmplus):
cad82 defb "Input machine's name", 0
NEO SPECTRUMAN
19.03.2020, 18:09
Ped7g, кстати
в вашей версии sjasm-а не получается сохранить лог командной строки
не таким образом
sjasmplus.exe code.asm >log.txt & type log.txt
не таким
sjasmplus.exe code.asm >log.txt
не таким
sjasmplus.exe code.asm >>log.txt
в итоге log.txt
0 байт
в других ветках sjasm-а это работает
it's modified to follow common compilers, output is STDOUT (you can assemble with machine code going to STDOUT), and errors/info is going to STDERR.
So to redirect the errors into log file use "sjasmplus file.asm 2> log.txt" (at least in linux/bash, not sure if this works in windows and in which shell, google how to capture STDERR in your shell, if the "2>" doesn't work).
NEO SPECTRUMAN
19.03.2020, 20:36
вроде работает
и в таком виде тоже
2> log.txt & type log.txt (чтобы одновременно видеть и выводит результат в log.txt)
:v2_dizzy_indy:
- - - Добавлено - - -
тем временем я дописал новую версию
своего набора макросов для компилияции chip8 кода в sjasm-е
удалось реализовать практически все команды
(раньше были только 8080 подобные команды)
https://zx-pk.ru/threads/27501-chip8-emulator.html?p=1052202&viewfull=1#post1052202
https://jpegshare.net/images/b8/2c/b82c3d480eed2a0ef9aa0c33b3795eb9.png
NEO SPECTRUMAN
05.04.2020, 23:09
по моему такая конструкция не работает
aaa = "ABCD"
defb aaa ; = defb "D"
хотя ожидается что будет так
defb aaa ; = defb "A","B","C","D"
просмотрел инструкцию
ничего подходящего не нашел :v2_dizzy_tired2:
mastermind
05.04.2020, 23:18
define aaa "ABCD"
NEO SPECTRUMAN
05.04.2020, 23:23
define aaa "ABCD"
а я будто такое уже не пробовал :)
ошибок сыпется куча
хотя щас еще попробую
сделать строку на lua в моем случае не получиться
mastermind
05.04.2020, 23:25
а я будто такое уже не пробовал :)
Так в чем проблема?
.lst:
1 0000 define aaa "ABCD"
2 0000 41 42 43 44 defb aaa
3 0004
NEO SPECTRUMAN
06.04.2020, 00:12
Так в чем проблема?
.lst:
ХЗ непонятно
именно на выбранное имя не работало о_О
хотя оно НИГДЕ не используется и было выделено только для строки
добавил _1 сзади и получилось о_О
щас буду копать
- - - Добавлено - - -
Глючит такая конструкция
define aaa "ABC DE"
label_aaa
defb aaa
bug.asm(11): error: Invalid labelname: label_"ABC
bug.asm(11): error: Unrecognized instruction: DE"
11 0000 label_"ABC DE"
12 0000
13 0000 41 42 43 20 defb "ABC DE"
13 0004 44 45
но в упор не могу искуственно повторить
чтоб "ABC DE" компилировалось как "E"
да и часть глючного кода вне исходника компилируется полностью
The `aaa = "abcd"` line defines new symbol (label), i.e. 32 bit integer. The assembler will use the value when it does parse any expression using "aaa" symbol.
the `DEFINE aaa "abcd"` works more like C preprocessor, it will replace almost all aaa in source with "abcd" *before* the line is parsed by assembler.
Now because sjasmplus is what it is, it's a bit more tricky... the "define" `aaa` is replaced only as stand-alone word, or when it is part of longer word separated by underscores, so:
`my_other_aaa_label: db 1234` will become `my_other_"abcd"_label: db 1234` and the assembling will fail.
`myaaa: db 1` will be not replaced.
So if you are using DEFINE, make sure you use really distinct name, which can't collide by accident with anything else, you can also prepend it with "_" underscore to prevent inside-word substitutions.
It usually helps to check listing file to see how the line was substituted (I think it's sometimes visible in listing).
----
In your new code example you can avoid partial substitution like this:
define _aaa "ABC DE"
label__aaa
defb _aaa
or use different name for label/define, or don't use "_" in label (`label!aaa defb aaa`)
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved. Перевод: zCarot