EgonOlsen71 / basicv2

A Commodore (CBM) BASIC V2 interpreter/compiler written in Java
https://egonolsen71.github.io/basicv2/
The Unlicense
85 stars 15 forks source link

Adds phase 2 of the PCode optimizer - joining lines together #11

Closed ciplogic closed 5 years ago

ciplogic commented 5 years ago

The code seems to pass at least Games tests and I have few ideas to improve on top, but it looks OK for me as the first skeleton for what it does.

After this transform it is possible to add few optimizations kind of easy:

I am not sure, but if it is accepted, it should reduce the output number of GOTOs.

EgonOlsen71 commented 5 years ago

I've merged it, but the results don't really work. Yes, it compiles the games just fine, but the compiled code doesn't work. Almost all examples crash with an out of data error, which seems to be "correct" judging from the output of your optimizer. It looks like as if it does some strange things to DATAs at least.

ciplogic commented 5 years ago

So I will make a new PR (I think in the evening) when I will not touch the DATA lines.

ciplogic commented 5 years ago

I also have an idea to reduce the output, as very likely lines: 1..6 are let's say merged, and output is like: 1 and 2 is merged 1 and 3 is merged, and so on.

This will be also hopefully be addressed before moving to the next item.

I assume you mean this kind of DATA, right?

https://www.c64-wiki.com/wiki/DATA

EgonOlsen71 commented 5 years ago

Yes, that kind. It shouldn't be a problem to put them into one line, but I assume you are doing something strange to them at least. When compiling the games, I saw quite a lot of output like

10000 and 34510 is merged,...DATA 12,3,22,3,123,2:DATA 123,33,33...

I found it very strange that seemingly very far away lines got merged into one. Maybe that's an indicator of the problem?

ciplogic commented 5 years ago

I will investigate this evening. I am at work time, so no clue just from your log :)