Assembler Optimizer

Page 19/21
12 | 13 | 14 | 15 | 16 | 17 | 18 | | 20 | 21

By santiontanon

Paragon (1072)

santiontanon's picture

08-08-2020, 07:42

Hey! I was starting to look at SDCC-generated assembler, and I was not able to find documentation on the generated assembler syntax in the user guide ( http://ecee.colorado.edu/~mcclurel/sdccman_3.6.0.pdf ). There are directives like ".area", syntax like ".area _DABS (ABS)", or even some predefined functions like "___sdcc_enter_ix", that I am not 100% about their semantics. Does any one know any good source on documentation for this?

Thanks in advance!

By pgimeno

Master (230)

pgimeno's picture

08-08-2020, 13:20

The assembler is sdas. There's documentation here: http://svn.code.sf.net/p/sdcc/code/trunk/sdcc/sdas/doc/asmln...

By santiontanon

Paragon (1072)

santiontanon's picture

08-08-2020, 22:01

Perfect!! Thanks pgimeno!! Big smile

By santiontanon

Paragon (1072)

santiontanon's picture

10-08-2020, 00:48

Alright, one more weekend, one more version of MDL! I just pushed alpha v9 to GitHub: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

In addition to lots of internal improvements to the optimizer (it generates about 20% more optimizations than the previous release), this release includes support for sdcc output aswell! So, now these dialects are supported: mdl/asmsx/glass/sjasm/tniasm/winape/pasmo/sdcc

I've also enhanced the testing scripts, to make sure MDL gets more and more robust. So, I have a set of 19 open source assembler projects that I use for testing. For example, this table shows how many bytes does MDL (in the default settings) saves off each project. I have similar tables for optimizing for size (-po size) or speed (-po speed):

Project Name              bytes saved
-------------------------------------
transball (-)                   96
Tales of Popolon (-)            44
XSpelunker (-)                  49
XRacing (-)                     54 
Phantomas 2.0 (-)               70
threed (glass)                  48
VGMPlay (glass)                 96
pong (asmsx)                    14
mine (asmsx)                    27
robots (asmsx)                   7
gmonkey (asmsx)                  4
World Rally (asmsx)             40
MetalGear (sjasm)              124
Uridium (sjasm)                 64
Deep Dungeon Adventure (sjasm)  23
SCCReplayer4c (sjasm)           13
PyramidWarp Enhanced (tniasm)   63
Subcommander (winape)          119
Flappy Bird (pasmo)             32

Other than 1 million thing sin the to do list (hahaha), there are a few things that I'm unsure about moving forward, and I'd appreciate any feedback any of you might have!

  1. MDL currently issues "coding style warnings". Currently 3 types are issues: labels without colons, unofficial spelling of Z80 ops, and soem dialect specific (e.g. using reusable sjasm labels which are quite dangerous). But I remember someone did not like the "label without colons" warning. I thought that one is important as otherwise, many assembler lines are very ambiguous, and would parse differently depending on the assembler you use... So, what do you think? should I turn those warnings off by default? and activate via flags, or keep then on and deactivate via flags?
  2. I have initial SDCC support, but I don't think it's very useful right now, as probably the person using it would have to apply those optimizations manually as MDL does not generate SDCC compatible assembler output yet. So, for any SDCC user reading this, what would be the most useful "ideal" way in which MDL should work with SDCC output?
  3. Any other open source MSX project that I'm missing in the list above? I wanted to add the Sword of Ianna, but the project is structured in a very complex way (every MegaROM page is a different assembler file, and they are linked manually with a makefile, so, I'd have to run ML separately in each part, which was complicated and I gave up...). The more projects I can use for testing, the more robust MDL can get :)

Anyway, that's all for this week :)

By santiontanon

Paragon (1072)

santiontanon's picture

10-08-2020, 07:50

I just found a few other projects searching in github for MSX and filtering by assembly language! I'll be adding these to my test suite this week. I hope they all work first-try! haha

But again, if anyone knows of other projects that would be interesting to add to my test suite, please let me know! :)

By ToriHino

Hero (561)

ToriHino's picture

10-08-2020, 08:02

The SDCC support looks interesting, and I would like to try it on RoboPlay (https://gitlab.com/torihino/roboplay), just to see what the effect is. Ideally this would mean only adding an additional step to the make file, making in part of the regular build steps.

By theNestruo

Master (179)

theNestruo's picture

10-08-2020, 08:57

Friendly reminder that SDCC already had the peep hole optimizer (e.g.: rather scarce peep-rules.txt example)

By santiontanon

Paragon (1072)

santiontanon's picture

10-08-2020, 09:18

Thanks ToriHino for the link, I'll see if I can make the process as seamless as possible!!

And @theNestruo, yes! True. I actually went through the set of peep rules in SDCC at some point to see if there was any interesting one to add to MDL Smile In the couple of example sdcc source code samples people shared with me, MDL was still able to find further optimizations though. So, I think the set of peep rules that come with SDCC is not very comprehensive.

But in any case, the peep-hole optimizer is just the first optimizer that MDL implements. In my mind it was just something quick-n-dirty to start playing with MDL before moving to some search-based techniques, but then it started growing and growing and I still see many more ways to improve it haha Smile

By ARTRAG

Enlighted (6429)

ARTRAG's picture

10-08-2020, 09:25

Look at this other project too
https://github.com/cornelisser/TriloTracker-Re-player
It is for sjasm

By theNestruo

Master (179)

theNestruo's picture

10-08-2020, 09:41

santiontanon wrote:

And @theNestruo, yes! True. I actually went through the set of peep rules in SDCC at some point to see if there was any interesting one to add to MDL Smile In the couple of example sdcc source code samples people shared with me, MDL was still able to find further optimizations though. So, I think the set of peep rules that come with SDCC is not very comprehensive.

I'm not sure I'm getting your point... I'm no SDCC developer, but it seems that you can feed your own peep-rules.txt to the peep hole optimizer.
It is probably less flexible than MDL (namely, the patterns from the latests versions: repetitions, half-values, etc.), but I guess that, beside those, most of the patterns from MDL can be translated to peep-rules.txt syntax.
I'm not against MDL supporting SDCC! Just thinking out loud because I don't understand the excitement about the SDCC support when SDCC already had a similar functionality... ¯\(°_o)/¯

About the other questions: I vote for coding style warnings being disabled by default. "Implicit accumulator syntax"-gang member here... Cool

Page 19/21
12 | 13 | 14 | 15 | 16 | 17 | 18 | | 20 | 21