Hi,
I found the following two bugs with the use of macro's in IMC.
The first bug has to do with nested macro calls that use the same name
as parameter.
--------
.macro Test(X)
print .X
print "\n"
.endm
.macro XTest(X)
.Test(.X)
.endm
.sub _Main
.XTest("hi")
end
.end
--------
Expansion of .X results in an endless loop. The reason for this is that
arguments of a macro call are expanded not at the call but later on, and
the lookup finds a value .X for which the lookup finds .X and so on.
The second bug has to do with a local label as argument of a macro call.
--------
.macro Test(X)
print "Test label arg\n"
goto .X
.endm
.macro XTest()
.Test(.$end)
.local $end:
.endm
.sub _Main
.XTest()
end
.end
--------
This results in the following PASM code.
--------
_Main:
print "Test label arg\n"
branch local__XTest__end__3
local__XTest__end__1:
end
--------
Again, this is due to the fact that arguments of macro calls are expanded
at a later stage. Here, the label gets the wrong frame number (3 instead of 1).
The patch provided here as attachment solves both bugs.
It puts some code in the function expand_macro that expands the arguments
of the macro.
> I found the following two bugs with the use of macro's in IMC.
Good. Thanks, applied.
leo