Assembler Optimizer

Page 40/49
33 | 34 | 35 | 36 | 37 | 38 | 39 | | 41 | 42 | 43 | 44 | 45

By pgimeno

Champion (288)

pgimeno's picture

30-03-2021, 20:31

santiontanon wrote:

- tniam fails to parse lines like this:

ld hl,(10+5)+1

It seems that if the very first character of an expression in an instruction that allows for an indirection is a "(", tniasm already assumes that this is going to be an indirection, and ignores the "+1" when parsing the expression, which then sees as "unexpected extra characters" and fails to parse the line.

Same as Pasmo.

santiontanon wrote:

but the tniasm one I found quite funny, since I think it's clearly a bug Smile

Just a limitation of the parser. In Pasmo, with the --bracket option, you can use [] for indirection, leaving () free for grouping expressions without these surprises.

By santiontanon

Paragon (1388)

santiontanon's picture

30-03-2021, 20:56

The funny thing is that the tniASM expression parser actually can handle those expressions fine! For example cp (10+5)+1 parses fine! It's just when it thinks it's an indirection Smile

But good to know this also happens with Pasmo! I didn't know that! I'll make a note to make sure this is covered for Pasmo as well.

By Ped7g

Rookie (31)

Ped7g's picture

31-03-2021, 16:07

the real [evil] test is `ld a,(1)+(2)` ... Wink

(or anything else from the sjasmplus tests... this particular stuff is somewhat exercised in https://github.com/z00m128/sjasmplus/blob/master/tests/z80/t... - (the expected result is in listing file, some lines are not valid) - but there's lot of sjasmplus-specific syntax in those tests, so posting it here rather like curiosity, how the expression parser is being exercised/tested in sjasmplus project)

By Grauw

Ascended (9809)

Grauw's picture

31-03-2021, 16:21

If the expression parser emits unary operators for groups, then the instruction selector can match on whether the expression root is a group operator.

By santiontanon

Paragon (1388)

santiontanon's picture

31-03-2021, 16:40

haha, yes! lots of corner cases! I have actually checked the sjasmplus test set a few times to see examples of how sjasmplus is supposed to interpret a few things. So, those tests are extremely useful! (and a great idea to have them!)

By ToriHino

Paladin (699)

ToriHino's picture

04-04-2021, 11:35

I tried it on my sources written in Glass but it gives an error on REPT statements:
This is the piece of code

CONST: PROC

CHARS: PROC
OUTSIDE equ 0
   ENDP

LEFT_X1  equ 5 

  REPT LEFT_X1 - 1
  db CHARS.OUTSIDE
  ENDM

  ENDP

And this is the result (also goes wrong on other lines)

ERROR: Undefined symbol LEFT_X1 in src\fall-constants.equ.z80#70:   ENDM
ERROR: Could not evaluate REPT argument LEFT_X1 - 1
ERROR: Problem instantiating macro rept in src\fall-constants.equ.z80#70:   ENDM

Note that I use PROC quite a lot to scope the variables and functions.

By santiontanon

Paragon (1388)

santiontanon's picture

04-04-2021, 16:47

Thanks ToriHino! I just tried it and I can replicate the same exact error! I also know what is the problem (I missed one case in my label scoping logic Smile), so thanks a lot for the report!!

By santiontanon

Paragon (1388)

santiontanon's picture

04-04-2021, 23:52

Alright, and bug fixed. It'll be there when I release the next version (I've been busy over the past couple of weeks and haven't been able to dedicate that much time to MDL, but I have the next release almost ready: 58 / 63 "to-do items" done for this version. So, only 5 left to go and I'll upload version 1.9 with all these fixes. Hopefully some time this week.

By ToriHino

Paladin (699)

ToriHino's picture

05-04-2021, 08:59

Great Big smile

By santiontanon

Paragon (1388)

santiontanon's picture

08-04-2021, 06:20

Alright, finally got around completing the new version (v1.9), which can be found as usual in GitHub: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

I hope this version fixes all the issues reported above! But if it doesn't by all means let me know, and I'll be more than happy to fix any outstanding issues!

In any case, other than bug fixes, I think I'm ready to get started on the next optimizer. I haven't decided yet if I want to start with the register-allocation optimizer, or with a search-based optimizer ("super-optimizer"-style). I'll take a few days to decide while I take a break haha :)

Page 40/49
33 | 34 | 35 | 36 | 37 | 38 | 39 | | 41 | 42 | 43 | 44 | 45