Related articles |
---|
Preprocessor for an assembler using m4? prak@axpb.cdotb.ernet.in (1996-07-31) |
Re: Preprocessor for an assembler using m4? oz@nexus.yorku.ca (1996-08-09) |
From: | prak@axpb.cdotb.ernet.in (Prakash R.) |
Newsgroups: | comp.compilers |
Date: | 31 Jul 1996 19:30:44 -0400 |
Organization: | Compilers Central |
Keywords: | macros, assembler, question |
Can I use "m4" as a front end to the assembler that I'm building? I
remember seeing something to this effect in one of the postings. I tried
to check out the documentation available on "m4". Wasn't clear to me if
I could do it & if I could, how?
The assembler preprocessor has the following facilities:
- macro substitution
- file inclusion
- conditional compilation
Can I write a "m4-script" which will take care of all these? I have listed
some examples of the preprocessor facilites required below. If m4 can take
care of the above, then I don't have to write the preprocessor part of
the assembler. Will I be able to tune m4-script to match the syntax of the
assembler I'm developing?
Can I have nested macros? What about nested conditional compilation?
Any examples of how m4 is used on the net? Any references.
Any help would be greatly appreciated.
Regards,
-Prakash
//-------------------------------------------------------------------
// Examples
*) macro substitution:
- #define <identifier> <token string>
- #undef <identifier>
eg. #define QUEUE .space 2*10+4
for every occurence of QUEUE in the program text, the line
.space 2*10+4
is substituted.
*) file inclusion:
#include "filename"
*) Conditional assembly:
#ifdef <identifier>
#ifndef <identifier>
#if <absolute expression>
#else
#endif
eg.
#define DEBUG 1
....
#ifdef DEBUG
....
#else
...
#endif
//-------------------------------------------------------------------
[Should be doable if you have a sufficiently twisted mind to think in M4.
-John, old Trac hacker]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.