Assembler Optimizer

صفحة 51/57
44 | 45 | 46 | 47 | 48 | 49 | 50 | | 52 | 53 | 54 | 55 | 56

بواسطة max_iwamoto

Hero (600)

صورة max_iwamoto

05-11-2021, 15:13

santiontanon wrote:

I just uploaded a new version (same link as before: https://github.com/santiontanon/mdlz80optimizer/releases/tag... ).

Thank you. That was fast! It works great now. I can run all 3 optimizers. But the INCLUDE error is still there...

I can run -so at the moment but it will show some errors during execution but then continue and finishes the search. Here is the picture of it: https://drive.google.com/file/d/1Z5tzrITRCbsY32f5m9WX0e6xehPxI1RS/view?usp=sharing

"-do" & "-ro" runs without issues.

santiontanon wrote:

The issue with the labels like "c000h" should be fixed. But I would advise against using this type of constant though. For example, you have a line that looks like this:

_EOM:			EQU	FAh

Notice that "fah" could perfectly be a variable name. So, MDL was interpreting it as such. Same with "c000h", etc. I have added an exception for the "tniasm" dialect to parse these as hex constants (now, using tniasm dialect, if after parsing the input assembler files there are symbols that could be interpreted as hex constants and that have not been defined, they will be converted to hex constants). But most assemblers will give you errors with those. The usual recommendation is to insert a leading 0, like this, to prevent ambiguities:

_EOM:			EQU	0FAh

One of the reasons I like TNIASM is that I don't have to use 0 or 0x in the front of the hex constants. It gives code a cleaner look IMHO. The older version required it, but a new one is not.

santiontanon wrote:

In any case, that should work now. Oh, and I also added a new optimization pattern based on your idea haha (I credited you in the source code for the idea for that pattern, but let me know if you want your name removed) :)

Also, I wonder if the "include" error was also due to the labels issue. Not sure! In any case, I hope this version works better! :)

I will try to find more optimizations to add to the MDL. INCLUDE as mentioned above still gives error but thats not a big deal. The new version is awesome! Huge improvement for TNIASM.

بواسطة max_iwamoto

Hero (600)

صورة max_iwamoto

05-11-2021, 15:22

I have another suggestion about self-modified code. I use it a lot and it produces a lot of optimizations based on the code below:

	LD	A,00h		; ROOM width
.cnt:	equ	$ - 1
	DEC	A
	JR	NZ,.same_l

It suggests changing LD A,00h into XOR A. Is it possible to detect a self-modified code and disable optimizations for it, even if by using a special option to turn it on/off?

---

Another question I have is about similar blocks of code. Is there an option to search for repeating blocks and make them into subroutines that can be accessed using CALL?

بواسطة Grauw

Ascended (10604)

صورة Grauw

05-11-2021, 15:29

max_iwamoto wrote:

Another question I have is about similar blocks of code. Is there an option to search for repeating blocks and make them into subroutines that can be accessed using CALL?

If you’re interested, read this thread from this point onwards and there’s a bunch of posts discussing that topic.

بواسطة max_iwamoto

Hero (600)

صورة max_iwamoto

05-11-2021, 16:31

Grauw wrote:
max_iwamoto wrote:

Another question I have is about similar blocks of code. Is there an option to search for repeating blocks and make them into subroutines that can be accessed using CALL?

If you’re interested, read this thread from this point onwards and there’s a bunch of posts discussing that topic.

Wow! That would take me a few days to read...

بواسطة santiontanon

Paragon (1639)

صورة santiontanon

05-11-2021, 17:50

haha, yeah, this thread is getting long hahaha.

I'll take a look at the "include" issue and the errors you see with "-so", and see what could be going on! Smile

As for self-modifying code, yeah, I think it'd be great to detect it, I'll see if there is any easy way! In any case, you can always "protect" instructions from optimization manually by adding ```; mdl:no-opt```, something like this:

	LD	A,00h		; ROOM width ; mdl:no-opt
.cnt:	equ	$ - 1
	DEC	A
	JR	NZ,.same_l

Any line that contains "mdl:no-opt" in a comment will not be considered for optimization. You can also mark a whole block with ```mdl:no-opt-start``` and ```mdl:no-opt-end```. (the specific keywords can be changed via the ```-no-opt-pragma```, etc. flags, if you don't like "mdl:no-opt" Smile haha).

And about detecting repeating blocks, MDL does not support this yet! As Grauw mentions, he was doing some experiments on algorithms for detecting this, but that is not incorporated into MDL (yet!).

بواسطة santiontanon

Paragon (1639)

صورة santiontanon

06-11-2021, 05:01

I was looking tonight at the -so and include issues. And made an update with some small fixes (among other things I Was working on), same link: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

I am not sure what the "-so" issue is yet, but the exception reported in your screenshot was due to a small bug in the code. I've fixed it, but that's not the source of the error. With the fix, I hope that at least MDL might print a more meaningful error message though haha.

But I am a bit puzzled about the include issue. I wonder if it's a matter of Windows vs Unix paths. I do not have access to any Windows machine, so, I have never tested Windows-style paths very thoroughly. I think MDL handles the "\" path separator Windows uses just fine, but I am not sure if it will know what to do with the drive indicator "C:" at the beginning. Maybe that's the problem? I will see if I can setup some Windows virtual machine at some point next week to test this.

بواسطة max_iwamoto

Hero (600)

صورة max_iwamoto

06-11-2021, 15:45

santiontanon wrote:

I was looking tonight at the -so and include issues. And made an update with some small fixes (among other things I Was working on), same link: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

I am not sure what the "-so" issue is yet, but the exception reported in your screenshot was due to a small bug in the code. I've fixed it, but that's not the source of the error. With the fix, I hope that at least MDL might print a more meaningful error message though haha.

But I am a bit puzzled about the INCLUDE issue. I wonder if it's a matter of Windows vs Unix paths. I do not have access to any Windows machine, so, I have never tested Windows-style paths very thoroughly. I think MDL handles the "\" path separator Windows uses just fine, but I am not sure if it will know what to do with the drive indicator "C:" at the beginning. Maybe that's the problem? I will see if I can setup some Windows virtual machine at some point next week to test this.

I will get spoiled this way... Waking up every morning to a new version...

I tested the new version. And got a new error, here is the screenshot, hopefully, it will explain where is the issue.

https://drive.google.com/file/d/17yl17bro3Xr_nRRRRJQHPxTcGFSC0NWE/view?usp=sharing

The error with F6800h is back again, but only one of them.

About the INCLUDE issue. I was suspecting path being an issue. I tried every possible way and even put the included file into the same directory, so the path wouldn't be needed. I also tried to use "/", "\", and uppercase/lowercase letters. The issue is still there. Let me know if you have any other ideas so I can test them.

بواسطة santiontanon

Paragon (1639)

صورة santiontanon

06-11-2021, 20:15

Ah, ok, that gives me some more clues!! Thanks for testing so quickly Smile I'll try a few things tonight, and will also try to see what is the problem with the "f6800h" (my first guess is that I might have some rule to only parse 16bit numbers, and "f6800h" is a 32bit constant, nut not sure! in any case, I think this is easily fixable Smile ).

بواسطة santiontanon

Paragon (1639)

صورة santiontanon

07-11-2021, 03:41

I didn't want to change the tradition and I just uploaded a new version (same link: https://github.com/santiontanon/mdlz80optimizer/releases/tag... ). The "F800h" was a bug (usual copy/paste error that happened to pass by unit test by chance!). So, it should be fixed now.

As for the include issue, I'm still puzzled. Is there any other error printed before the "ERROR: error parsing source file test3.asm in test3.asm#8108: INCLUDE ""c:\downloads\ao\eggerland_2_rooms_03.asm""?

The new version includes a few more changes, but not important to this issue (I'm working on adding the z180 and z80n extended instructions definitions to the project so MDL works on projects for those cpus too).

بواسطة max_iwamoto

Hero (600)

صورة max_iwamoto

07-11-2021, 18:20

santiontanon wrote:

I didn't want to change the tradition and I just uploaded a new version (same link: https://github.com/santiontanon/mdlz80optimizer/releases/tag... ). The "F800h" was a bug (usual copy/paste error that happened to pass by unit test by chance!). So, it should be fixed now.

As for the include issue, I'm still puzzled. Is there any other error printed before the "ERROR: error parsing source file test3.asm in test3.asm#8108: INCLUDE ""c:\downloads\ao\eggerland_2_rooms_03.asm""?

The new version includes a few more changes, but not important to this issue (I'm working on adding the z180 and z80n extended instructions definitions to the project so MDL works on projects for those cpus too).

I tested the new version. F800h issue is gone. All 3 optimizations execute without an issue. Just execution time increased now. "-ro" is the fastest, "-po" medium speed and "-so" is the slowest.

INCLUDE issue was my doing, so there is no real issue there!!! When I copied files into test directory, I forgot to include a folder that used to INCBIN files from the included ASM file!!! After I copied folder there the issue is gone!!! Yahoo!!!

After running new optimizations I noticed an interesting line that printed twice in the optimization report:

INFO: Pattern-based optimization in eggerland_2_0143.asm#312: replace rrc ?reg0; rrc ?reg1 with rrca; rrc ?reg1 (1 bytes, 3 t-states saved)
INFO: Pattern-based optimization in eggerland_2_0143.asm#312: replace rrc ?reg0; rrc ?reg1 with rrca; rrc ?reg1 (1 bytes, 3 t-states saved)

Line 312 consists of LDIR only, here is the code that leads to it:

	LD	HL,E280h	          ; save data for disk operations
	LD	DE,D000h
	LD	BC,1100h
	LDIR                            <-- LINE 312

---

Great news that TNIASM support has no more glitches!!!

صفحة 51/57
44 | 45 | 46 | 47 | 48 | 49 | 50 | | 52 | 53 | 54 | 55 | 56