Hi Bryant,
......check your definem macro, as you seem to have unbalanced the number of %push/%pop directives (you have two %push mac and only one %pop). I'm not sure if that was intentional but if you end up using your code a lot, it might really slow your code down.
You are correct. This was accidental, as I have been trying different things. In the heat of the moment I got sloppy.
I'm pretty sure this behaviour is supposed to be expected. %? is getting expanded when your new macro is being created so I don't really know of any way around this. I'm honestly surprised your code worked.
I have attached a working program with source. The "context local " approach does not work and of course none of the "macro locals" work. I have found a workaround but its not satisfactory....
strcpy Start ;<< This is strcpy( Start )
; ExitProcess ,0 << This is ExitProcess( "", 0 )
You are right here again but I think the problem lies here...
%macro %[%1] 0-*
%warning %?? %0 ,%1,%2 %3 %0-1 ,%[%1]
The macro with name %[%1] gets created. Here however the preprocessor gets confused. Instead of using %[%1] as the new macro name, it reuses the previous macro name (mac), drops %[%1] and shifts the supplied parameters to the right and thus creates an empty parameter. I assume macro name mac is used as current macro name until it sees a matching %endm.
As you can see, the coma preceding your arguments creates a blank argument in %1.
printf missing1starg,Newline
This compiles and runs fine
printf string3 <--- correct invocation
This produces ERROR: Line 34: error: invalid combination of opcode and operands
The workaround works by defining %[%1] before the macro is created and then ignoring %1 and using %2 as first argument. There is a serious drawback in my implementation because %define name %1 creates persistence.
definem printf,ptr
definem scanf,ptr
printf, string