You want to hack NASM's preprocessor, to give it the ability to call your custom functions.
The current version of NASM does not have "hooks" for that.
Modifying NASM is not that difficult. It is one of the tasks I have planned when I get the time.
I need to add support for user-defined types.
If you do hack NASM, just make sure it is crystal clear that a user knows he is using your upgrade.
I WARN all programmers to resist the temptation to indulge in what I call MACRO MADNESS.
Sure, you can write a macro to mimic just about anything in an HLL, but such macros turn into
programs unto themselves. This can seriously set back someone trying to get something done quickly, but
they have to wade through huge macros to understand how to use them. I try to keep my macros as short
as possible, and leave the argument juggling to the called procedure.