Assembler Optimizer

Page 37/49
30 | 31 | 32 | 33 | 34 | 35 | 36 | | 38 | 39 | 40 | 41 | 42

By pgimeno

Champion (288)

pgimeno's picture

12-03-2021, 21:03

santiontanon wrote:

A bit more problematic is that I also discovered yesterday that different assemblers are assigning different precedence to different operators. So, in some assemblers the expression "1 << 4 + 1" is interpreted as "(1 << 4) + 1" and in others as "1 << (4 + 1)".

If someone borrows an operator from another language, they should borrow its precedence as well, to avoid creating a mess like the one you mention (or like the one in PHP's ternary ? : operator). In this case, 1 << 4 + 1 should be equivalent to 1 << 5.

If you intend to support Pasmo, beware also the case of unary plus/minus, which in this assembler has less precedence than addition/subtraction (to my dismay!).

https://notabug.org/pgimeno/vdptest/src/master/test-ack-timi...
forcing me to do
https://notabug.org/pgimeno/vdptest/src/master/test-ack-timi...

By santiontanon

Paragon (1389)

santiontanon's picture

13-03-2021, 02:08

Agreed!! And good to know about Pasmo! thanks for the note. I do have it as part of the current set of dialects, but I didn't realize that precedence issue! Just added a to do item to take that precedence difference into account.

By Ped7g

Rookie (31)

Ped7g's picture

14-03-2021, 01:55

santiontanon wrote:

Do you know of any assembler code base that uses this and I could use to test?

The ZX Next stuff? All my recent stuff, but I'm afraid I'm too often using sjasmplus features to the extent it may be difficult to parse (without re-creating sjasmplus Big smile ... ehm), but you can try scavenge them to see yourself, maybe something will work well for your tests (I think the Misc/Layer2FadeOut and Misc/ReadingAtariDrivingController are probably simplest ones in terms of assembler-feature usage):

The coding tutorial: https://github.com/ped7g/SpecBong
Next tests: https://github.com/MrKWatkins/ZXSpectrumNextTests
various small examples/experiments: https://github.com/ped7g/ZXSpectrumNextMisc
(I'm building all of that with sjasmplus of course)

By mzoran

Expert (110)

mzoran's picture

14-03-2021, 09:45

Just tried to run 1.7 but it quickly failed
ERROR: parseRestofTheLine: Cannot parse line ffrom.asm#27: ALIGN 16384, 255 left over tokens: [,, 255]
I did specify -dialect sjasmplus

By santiontanon

Paragon (1389)

santiontanon's picture

14-03-2021, 15:26

Hi mzoran, thanks for the report! Indeed that form of "align" is not yet supported (I didn't even know you could pass a second parameter to align! haha). Added to my todo list, and should be supported in the next version.

By santiontanon

Paragon (1389)

santiontanon's picture

15-03-2021, 02:13

New version (v1.8 beta) is up! https://github.com/santiontanon/mdlz80optimizer/releases/tag/v1.8

- I have been focusing on bug fixing and improving compatibility with pasmo this week (so, mdl can now pase/optimize/assemble "The Sword of Ianna", for example), but also a bit of asmsx and sjasmplus (@mzoran, the issue you mentioned above should be fixed now).
- I also managed to add two new functionalities to the code reorganizer optimizer: identification of unreachable code (blocks of code that have no incoming arrow in the code-flow graph), and "block merging", which identifies identical pieces of code and tries to eliminate the copies (this is only done for simple blocks of code that start with a label and end in a jump/ret to avoid corner cases for now).

For 1.9 I want to see if I can squash all the small bugs/unsupported things I have on my list, and hopefully that'll give me enough confidence to remove the "beta" tag from the version name. Maybe I'll then take a little break, since the next optimizer I want to implement (to change to version 2.0) might require a significant amount of work, haha. But might release "maintenance versions" if there are bug reports in the mean time :)

That being said, I'm interested in improving compatibility with sjasmplus, but I haven't found any significantly complex open source projects in Github that use it so I can test (all the sjasmplus projects I find are for the ZX Spectrum next, which I still do not support). If any one has any pointers, that'd be great!

By Ped7g

Rookie (31)

Ped7g's picture

15-03-2021, 09:15

ad sjasmplus projects - what about Coloristic game?
https://github.com/mborik/coloristic

I guess it may be PITA to have full build working (requires few more 3rd party tools), but if you extract just the sjasmplus part assembling the source, it may be decent example of "real" project?
(I'm not familiar with the code base, so I'm not sure what awaits you inside and if it really is feasible as test-bed for your project, I just know the author and that he released the source together with the game).

By jltursan

Prophet (2502)

jltursan's picture

15-03-2021, 09:20

sjasmplus seems to be more ZX oriented. I've asked in another forum, let's see if anyone is able to help.

Just out of curiosity, is the optimizer capable of identify a subroutine that's only called once?, if so, it could replace the call with the inline subroutine code...

By jltursan

Prophet (2502)

jltursan's picture

15-03-2021, 10:24

Here's one: amstrad-diagnostics

By santiontanon

Paragon (1389)

santiontanon's picture

15-03-2021, 14:38

Awesome!! thanks a lot Ped7g and jltursan!!! That was fast! Super useful! I'll add check these two project out! About projects being a PITA, haha, I know! I have about 30 projects in my evaluation set right now, and each of them is a different "adventure" to get to compile, so I have a reference binary, haha

As for the "identify a subroutine that's only called once": yes! since a couple of versions ago, the "-ro" flag should be able to do that (unless you deactivate it with "-ro-no-inliner -ro"), but it's currently limited to subroutines that:
- only have a single "ret" statement
- do not contain any "jp/jr/djnz" to any label outside of their own code (i.e. the code from the function label to the "ret" statement)
- there is no "jp/jr/djnz" from outside their own code that jumps to any label in the middle of the subroutine
- are defined and called on the same page
- are not defined as "public" (in the dialects that support such type of keywords)

Page 37/49
30 | 31 | 32 | 33 | 34 | 35 | 36 | | 38 | 39 | 40 | 41 | 42