Quote:
Do you intend to give your C preprocessor more assembly language-like macro facilities?
That is the intent. It will be a command-line switch to enable assembly language pre-processing. (a syntax setting ‘/S’). Many of the directives are the same except for the character indicating a pre-processor directive. “if”, “else”, “endif”, etc are supported.
The intent is to support repeat statements. They are treated like macros and have an instance counter that is available. “\@”. They can also have arguments passed to the repeat statement like a macro. I am not having much luck getting nested repeats to work, and they are needed if repeat is supported. There could always be a repeat statement in an included file resulting in a nest.
The current assembler pre-processor I have been using evaluates everything as numerics, it works great. This means it does not easily support text manipulations, however. FPP64 evaluates everything as text strings. The Verilog pre-processor in use does not support ‘ifdef’ ‘ifndef’ properly. It treats them like a ‘if’ expecting the symbol to be defined. I may use FPP instead.
The older version of FPP had huge buffers statically allocated (eg 10,000,000B) that it used for processing. This made it a bit of a memory hog. It has been changed to use buffers incrementing in size by a memory page (4kB) as needed.
Repeat statements will likely have a max iteration count (100). Otherwise, they could generate a lot of text.
Currently FPP uses memory to expand macros and repeat statements. A lot of memory may be required if there is a large macro repeated numerous times.
Here is a test sample that seems to work.
Code:
.macro MyMacr
mov %eax,%ebx
add %eax,%eax
.ifndef NODEF
shl $13,%eax
sub $21,%eax
.endif
.macro MyMacr2
Ha!Ha!
.endm
.endm
MyMacr2
.include "t00002.s"
MyMacr
MyMacr
MyMacr
MyMacr2
MyMacr2
Wow! It worked!
And result:
Code:
Ha!Ha!
An include test.
mov %eax,%ebx
add %eax,%eax
shl $13,%eax
sub $21,%eax
mov %eax,%ebx
add %eax,%eax
shl $13,%eax
sub $21,%eax
mov %eax,%ebx
add %eax,%eax
shl $13,%eax
sub $21,%eax
Ha!Ha!
Ha!Ha!
Wow! It worked!