Frank reported:
|
| From the "expert questions" forum comes this:
|
| ---------------------
| By: jasper_neumann
|
| How can I delegate %undef?
|
| In the example below the assembler (called with "nasm.exe -t -f rdf q.asm")
| bemoans my code, displays
|
| "q.asm:19: error: interminable macro recursion"
|
| and hangs.
|
| q.asm
| -----
| bits 32
| CPU P4
|
| %macro my_def 2
| %xdefine %1 esp+%2
| %endmacro
|
| %macro my_undef 1
| %undef %1
| %endmacro
|
| global check_it
| check_it:
| my_def x,4
| mov eax,[x]
| my_undef x
|
| my_def x,8
| add eax,[x]
| my_undef x
| ret
|
So in case of interminable macro recursion we should break
the expansion procedure that way to not return back and start
expand macro again.
This address a part of the original problem.
Nasm64developer pointed out:
|
| Btw, after you manage to fix this recursion problem, the code
| in question still faces the same fundamental issue -- the arg
| to the my_undef invocations (i.e. x) gets expanded first; thus
| the %undef inside the macro sees esp+4 and esp+8 instead
| of x, and fails. What you'd need is a means to prevent the ex-
| pansion -- look for e.g. %# in 4.1.4 of the manual.txt which is
| attached to SF #1842438; it implements exactly that -- I once
| filed SF #829879 for this feature.
|
In turn Keith Kanios said:
|
| Anon is also correct in that we would need a special directive to instruct
| the delay of macro expansion, although I don't see this as critical or even
| high priority at the moment. The intermediate solution for this is, don't
| use indirection if it is not needed... an inline %undef should be
| sufficient.
|
Reported-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: Keith Kanios <keith@kanios.net>
NASM, the Netwide Assembler.
Many many developers all over the net respect NASM for what it is
- a widespread (thus netwide), portable (thus netwide!), very
flexible and mature assembler tool with support for many output
formats (thus netwide!!).
Now we have good news for you: NASM is licensed under the "simplified"
(2-clause) BSD license. This means its development is open to even
wider society of programmers wishing to improve their lovely
assembler.
The NASM project is now situated at SourceForge.net, the most
popular Open Source development site on the Internet.
Visit our website at http://nasm.sourceforge.net/ and our
SourceForge project at http://sourceforge.net/projects/nasm/
See the file CHANGES for the description of changes between revisions.
With best regards,
NASM crew.