Nasm preprocessor - again
Mathieu Monnier
manao at melix.net
Fri Sep 15 11:25:11 PDT 2006
Hi,
Since I was not able to test much SSE4 instructions at home, I tried to
find the reason for the following file not to be preprocess correctly.
It basically concerns the use of local identifiers in multiline macros.
I tried to debug it, which allowed me to discover the fantastic maze
that the nasm preproc seems to be. Though I started pretty confident in
finding either why it didn't work or what was the bug, I failed at both
( this time, valgrind wasn't kind enough to directly point to the error ).
When I code in assembler - mostly SIMD code - I make a _heavy_ use -
some would say overuse - of macros. That allows most of the time a
single macro to create a MMX/SSE2/SSE3 function, and gives some more
maintainability.
Until recently, nasm preproc was filling most of my needs, but with the
macros getting more complicated, and my needs stronger, I more and more
find it lacking.
In the present state, what it's most needing is named parameters for
multiline macros. That would definitely improve things, because though
I'm becoming accustomed to write lines such as "%9 %1, [ %18 ]", I would
rather write "aligned_move RMM1, [ source ]"
That's why I began looking into the nasm preproc code. I thought
searching why the attached file wasn't working would be as good an
introduction to that code as any, but it proved me wrong. After looking
a few seconds at it, I felt an urgent need to rewrite it. Looking at it
some more time, I was even amazed it was working at all.
I now faced two possibilities :
- try to fix as much things as possible in the current code, cleaning
what I can without having to understand too much of the code, and trying
to grasp any insight on how the code work. Then try to implement the
named parameter macros.
- try to write a new parser - which with my almost inexistent
knowledge in parsers would not be an easy task, and which I feel would
be mostly a loss of time ( since most of the features I need are already
there ).
The third possibility, using another assembler such as FASM - which
seems to fill all my needs - has also crossed my mind.
I don't much like the third possibility ( new syntax, while I already
have a huge collection of nasm/yasm code I wouldn't like to translate ),
the second seems a bit ambitious, and the first one would make me meddle
with a code I don't like, so I don't quite know what to do.
That's why I diggressed so much on this ML, to hear what you thought of
those three possibilities.
I was also hoping that somebody with a good knowledge of the parser
would give me some pointers to start modifying it.
Regards,
Mathieu
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug_pp.asm
Url: http://cvs.tortall.net/pipermail/yasm-devel/attachments/20060915/251b4402/attachment.ksh
More information about the yasm-devel
mailing list