santiontanon / mdlz80optimizer

MDL (a Z80 assembler optimizer)
Apache License 2.0
73 stars 6 forks source link

-po issues Release 2.5 vs 2.4 for Pasmo Asm ? #49

Open deringenieur71 opened 6 months ago

deringenieur71 commented 6 months ago

Hi,

found your tool today and startet experimenting. With 2.5 Release I could not use -po option.

java -jar .\mdl.jar .\F_EngineCPC.asm -po -cpu "z80cpc" -dialect "pasmo" -asm .\F-ropo_CPC.asm Exception in thread "main" java.lang.NoSuchMethodError: java.lang.String.isBlank()Z at parser.Tokenizer.isDashPlusLabel(Tokenizer.java:598) at parser.Tokenizer.isDashPlusLabelContinuation(Tokenizer.java:609) at parser.ExpressionParser.parseInternal(ExpressionParser.java:767) at parser.ExpressionParser.parse(ExpressionParser.java:135) at workers.pattopt.Pattern.<init>(Pattern.java:154) at workers.pattopt.PatternBasedOptimizer.loadPatterns(PatternBasedOptimizer.java:232) at workers.pattopt.PatternBasedOptimizer.initPatterns(PatternBasedOptimizer.java:169) at workers.pattopt.PatternBasedOptimizer.optimize(PatternBasedOptimizer.java:278) at workers.pattopt.PatternBasedOptimizer.work(PatternBasedOptimizer.java:269) at cl.MDLConfig.executeWorkers(MDLConfig.java:254) at cl.Main.main(Main.java:85)

After trying a lot, I downloaded 2.4 Release, which gives me:

java -jar .\mdl24.jar .\F_EngineCPC.asm -po -cpu "z80cpc" -dialect "pasmo" -asm .\F-ropo_CPC.asm INFO: Pattern-based optimization in .\F_EngineCPC.asm#210: Remove unused ld a,(combyt) (3 bytes, 4 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#265: Replace jp dbox2 with jr dbox2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#571: Replace ld de,MAP; and a; sbc hl,de with ld de,-(MAP); add hl,de (2 bytes, 2 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#896: Replace jp star0 with jr star0 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#901: Replace jp star9 with jr star9 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#905: Replace jp star9 with jr star9 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#908: Replace jp star8 with jr star8 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1116: Replace jp mloop with jr mloop (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1126: Replace jp tidyup with jr tidyup (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1267: Remove unused ld c,253 (2 bytes, 2 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1268: Remove unused ld b,255 (2 bytes, 2 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1276: Replace ld bc,62976 with ld c,(62976) & #00ff (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1282: Replace ld bc,62976 with ld c,(62976) & #00ff (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1489: Replace jp dobj1 with jr dobj1 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1535: Replace jp dobj1 with jr dobj1 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1542: Replace ld de,70 with ld e,(70) & #00ff (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1666: Replace jp dscor2 with jr dscor2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1692: Replace jp incsc with jr incsc (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1760: Replace ld d,0 with ld d,e (as e == 0 here) (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#1967: Replace jp ptxt1 with jr ptxt1 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2013: Replace jp btxt1 with jr btxt1 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2067: Remove unused ld a,d (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2266: Replace call ldchk; ret with jp ldchk (1 bytes, 5 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2288: Replace call lrchk; ret with jp lrchk (1 bytes, 5 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2288: Replace jp lrchk with jr lrchk (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2310: Replace call plchk; ret with jp plchk (1 bytes, 5 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2310: Replace jp plchk with jr plchk (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2339: Replace call lrchk; ret with jp lrchk (1 bytes, 5 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2339: Replace jp lrchk with jr lrchk (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2392: Replace ld de,MAP; and a; sbc hl,de with ld de,-(MAP); add hl,de (2 bytes, 2 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2982: Replace jp dspr2 with jr dspr2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3002: Replace jp dspr2 with jr dspr2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3007: Replace jp dspr2 with jr dspr2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3024: Replace jp gspra0 with jr gspra0 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3107: Replace jp sspri2 with jr sspri2 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3258: Replace jp sktyp1 with jr sktyp1 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3266: Replace jp colty0 with jr colty0 (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#3417: Replace jp evftf with jr evftf (1 bytes, 0 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#135: Replace ld hl,fopt with ld l,(fopt) & #00ff (1 bytes, 1 nops saved) INFO: Pattern-based optimization in .\F_EngineCPC.asm#2886: Replace ld b,TABSIZ with ld b,c (as c == TABSIZ here) (1 bytes, 1 nops saved) DIGGEST: PatternBasedOptimizer: 40 patterns applied, 46 bytes, 39 nops saved. INFO: mdl optimization summary: 46 bytes, 39 nops saved. Pattern-based optimizer pattern applications: 40.

Seems to work in 2.4, but not 2.5 for my example. What did I do wrong ?

santiontanon commented 6 months ago

Oh, interesting! it seems that is a Java version issue. I might have started using the "isBlank()" function of the String class in version 2.5, which was added in Java 11 if I remember correctly. Could it be that the Java version in the machine you are testing is older than 11? Let me know if that's the case, and I will see if it's easy for me to remove calls to that method, to make MDL more compatible (or at least mention the Java version that is required)

deringenieur71 commented 6 months ago

It seems my JAVA is very outdated ;) - it's java version "1.8.0_391" (Java 8?)