m4 macro language resources
Suite8080, a suite of Intel 8080 Assembly cross-development tools I'm writing in Python, includes also an assembler. I designed the latter to optionally read from the standard input, a feature that gives for free macro processing via a separate tool like
m4. I can feed macro Assembly source to
m4 and pipe the expanded output into the assembler.
The M4 language is a good choice thanks to its power and ubiquity on POSIX systems.
m4 is an obscure tool with a learning curve made steep by the unintuitive quoting and expansion rules. There are few resources and no books or tutorials. The very few code samples are abstract, short, and formatted with little or no whitespace and indentation, which doesn't help readability.
After extensive online research, I put together a list of the best learning and reference resources:
- GNU M4 manual: the complete reference
- Notes on the M4 Macro Language: an overview with a practical focus
- M4 Playground: a collection of research papers and commented examples
- Stack Overflow questions tagged
m4: practical applications and issues
- Working with the M4 Macro Language: a list of resources by James Howard
- M4 tutorial of the COHERENT Unix clone
- m4 support in Opbasm: the macro package of the Opbasm assembler for PicoBlaze microcontrollers (m4 source)