I wrote a large package of macros for a niche assembler using M4. It has some sophisticated things like a code generator for non-infix expressions. M4 was a blessing and a curse. It is very powerful and saved me from implementing my own macro language but debugging is not for the faint of heart once you get into anything complicated.
These are macros that generate user configurable codegen macros. I couldn't hard code register assignments so everything dynamically generated is prepared with these monstrosities. They also can't have fixed names since some need to be invoked multiple times with different parameters.
FWIW I didn't intend for things to go this far. I just started with some simple macros and it snowballed.
https://github.com/kevinpt/opbasm/blob/master/opbasm/picobla...
Michael Breen's notes are indispensable documentation on how to make effective use of the language.