Ah, true, good point!! Alright, I just added a few to-do items to my list. This might not make it to the next v2.2 release (planned for this weekend), but I'll try to add a first preliminary version for v2.3
After a long time without any major release, I just uploaded a new version of MDL (v2.2) to GitHub: https://github.com/santiontanon/mdlz80optimizer/releases/tag...
Other than bug fixing and general improvements, the 2 major new things are:
- support for the extended instructions in z180 and z80next cpus
- significant improvements to the search-based optimizer (which is starting to generate more and more optimizations, finally!). As a result it became a bit slower to run (about 1 minute in my computer for a normal-sized project), but I know the bottleneck, and I'll work on this for next version.
Next I want to try to add the functionality we were discussing above to detect duplicated data blocks! (plus lots of small improvements on the search-based optimizer that I have in my list and didn't make it to this version)
After a long time without any major release, I just uploaded a new version of MDL (v2.2) to GitHub: https://github.com/santiontanon/mdlz80optimizer/releases/tag...
Other than bug fixing and general improvements, the 2 major new things are:
- support for the extended instructions in z180 and z80next cpus
- significant improvements to the search-based optimizer (which is starting to generate more and more optimizations, finally!). As a result it became a bit slower to run (about 1 minute in my computer for a normal-sized project), but I know the bottleneck, and I'll work on this for next version.
Next I want to try to add the functionality we were discussing above to detect duplicated data blocks! (plus lots of small improvements on the search-based optimizer that I have in my list and didn't make it to this version)
Great to have the new version. I will test it tonight.
I have tested the new version and indeed it produces more optimizations than before.
But I found new features of TNIASM that are not supported. I didn't use them in the previous version of the code.
The features in question are %if, %else, %endif
Here is a code example of it:
%if (GAME_VERSION == "2") ADD A,0Ah %endif %if (GAME_VERSION == "4") SUB 08h %else ADD A,0Ah %endif
Would be great to add support for them to the MDL.
---
Now, there is one more thing that I didn't use but also exists in TNIASM - macros.
Here is an example:
%macro ips_cls %n , %n , %n ; start address, size, fill byte %if (#1 > FFFFFFh) | (#2 > FFFFh) | (#3 > FFh) %if (#1 > FFFFFFh) \ %error "ips_cls offset address is too big!" \ %endif \ %if (#2 > FFFFh) \ %error "ips_cls size is too big!" \ %endif \ %if (#3 > FFh) \ %error "ips_cls fill byte is too big!" \ %endif %else DB (#1 / 10000h) DB (#1 / 100h) & FFh DB (#1 % 100h) DW 0000h DB (#2 / 100h) DB (#2 % 100h) DB #3 %endif %endmacro
I assume it is harder to add macros to the MDL compare to other features, but maybe it would be possible in one of the future versions
Oh, thanks for those examples!! "macro"s and "if"s are easy (as those are already implemented for other dialects, so it's just a matter of associating the right tniasm keywords). But I see an interesting syntax here, using "\" to break lines! I don't have that implemented either! I'll look into it later today when I get back home!
Alright, al of those should be handled in the latest "dev" build: https://github.com/santiontanon/mdlz80optimizer/releases/tag...
(and also, the search-based optimizer should already be 30%-40% faster to execute, which is nice)
Great advances!
What you call search-based optimization is actually superoptimization, right?
If so, this paper might be of interest: https://web.stanford.edu/class/cs343/resources/superoptimize...
Oh, very nice paper!! Thanks! I'll make sure to read it! The abstract looks like it is EXACTLY what I'm trying to build here!
And yes! exactly! there is a "superoptimizer" inside of MDL that can be used in two ways: to generate code from scratch given a specification, or to optimize existing code. When used to optimize existing code, what it does it to go through the original code line by line, and take small blocks of code (by default "2 instructions at a time"), and exhaustively search all instruction combinations, trying to find a faster/shorter way to do the same. It is currently limited to only a subset of the z80 instruction set, but I'm expanding bit by bit.
I tryed your assembler. It looks nice. I just two remarks.
1/ I think it would be better if the assembled file was created in the same folder as the default source code instead of being created in the user's folder.
2/ I tryed the option -st. I'm happy to do that on my Mac. The only small flaw is that sometimes a label is renamed (eg. "END:" is remaned by __mdlrenamed__end:). So I have to rename manually to avoid this.
Thanks for testing gdx! As for the output assembler file, you mean with the "-asm" flag? That flag takes a path as an argument. So, if you specified a filename, then yeah, I see it would have taken it as just saving it in whichever your current folder was
And yeah, the "end" symbol is special in many assemblers. Some assemblers fail if you use "end" as a label, hence if MDL finds such label, it renames it for safety. Which assembler are you using? Maybe I should see which of the currently supported dialects have troubles with "end", and leave the label be if you are using a dialect that has no troubles with it.