Re: [cc65-devel] CA65 .define macros broken?
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Vorsichtphysiker <vor...@gm...> - 2025-09-29 19:11:49
|
I just want to tell that I will open an issue, soon. I found out several things. In short: The CA65 assembler does not distinguish between parentheses in the macro parameter list and parentheses as part of expressions. The white space between the macro name and replace expression does not terminate an eventual parameter list. The assembler just takes the first pair of parentheses as the start/end of the macro parameters. This is broken at least since january 2022. Macros containing a parameter list did not show the issue, because then the assembler considers eventual following parentheses as part of the replace expression and not part of the parameter list. This enabled a simple workaroundm so that one could define macros with parentheses in the expression part, anyway. If you just put an empty pair of parenthesis directly after the macro name, the following parentheses were also considered as part of the replace expression and not part of the parameter list like in the case above. Due to a code change in july this year, the workaround is not working anymore. This is the reason I just realized the problem now and not already some years ago. I will provide a bisect log, my testcode and my conclusion. However, it needs a little time to write all that down into the ticket. So I beg for a little patience. This is a typical example of the manifestation of a long existing bug due to some apparently unrelated code change. Yours Monte Am 28.09.25 um 13:17 schrieb Physiker via cc65-devel: > I would like to tell the last version I know which worked, but the > hash before the pull scrolled out of my terminal buffer. So I realized > too late to give you that info. Hope I can add later on. > > 28.09.2025 13:04:13 groepaz--- via cc65-devel > <cc6...@li...>: > > Am Sonntag, 28. September 2025, 12:11:00 Mitteleuropäische > Sommerzeit schrieb > Stefan via cc65-devel: > > I recently pulled my cc65 checkout, recompiled, installed and > then realized > that some CA65 macros I use for years don't work anymore. > Version: cc65 > V2.19 - Git 93c1b659e > > > It seems that parentheses in arguments are not avaluated > correctly, anymore. > However, parentheses in parameter definitions seem to work but > not the same > as before. > Here is an isolated testcase: > > (1) .define foo 100 > (2) .define bar foo+200 > (3) .define baz (foo+200) > (4) .define x1() foo+200 > (5) .define x2() (foo+200) > (6) .define x3(par) foo+par > > (1), (2) are unproblematic, (6) also. > I can understand that (4) and (5) are conercases, anyway they > worked before. > (3) does not work too. > > Here is the assembler output: > > ca65 define_test.s > Assembling include file #3 > define_test.s:11: Error: Expected a parameter name but found > ‘100’ > define_test.s:9: Note: Expanded from macro here > define_test.s:11: Error: Expected ‘)’ but found ‘100’ > define_test.s:9: Note: Expanded from macro here > define_test.s:12: Error: Expected a parameter name but found ‘)’ > define_test.s:13: Error: Expected a parameter name but found ‘)’ > > > Please open a bug ticket - and provide a complete test case for > each :) > Without one its not really possible to tell what is happening, and > why. > > -- > > http://hitmen.eu http://rr.pokefinder.org > http://vice-emu.sourceforge.net http://magicdisk.untergrund.net > > Digital files cannot be made uncopyable, any more than water can > be made not > wet. > > > > > > > _______________________________________________________ > cc6...@li... > https://lists.sourceforge.net/lists/listinfo/cc65-devel > > > > _______________________________________________________ > cc6...@li... > https://lists.sourceforge.net/lists/listinfo/cc65-devel |