Go to file
Cyrill Gorcunov bd38c8f231 preproc.c: expand_smacro -- break endless loop for interminable macro recursion
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>
2009-11-21 11:11:29 +03:00
contrib/VSrules Visual Studio 2008 NASM integration 2009-09-25 20:49:51 +04:00
doc changes.src: document removal of DREX instructions 2009-11-09 14:58:45 -08:00
headers headers/c: strip off useless spaces 2009-08-09 10:28:27 -07:00
inttypes Add _MIN and _MAX macros for the fixed-size types. 2007-08-20 20:09:11 +00:00
lcc Fixed distinction between char and int8_t data types. 2007-04-13 16:47:53 +00:00
lib Add strlcpy() function 2009-08-10 15:59:34 -07:00
macros Add copyright headers to standard macro packages 2009-06-28 17:18:13 -07:00
misc misc/release: *.ico are binary files 2009-09-23 09:54:10 -07:00
Mkfiles Merge elf header files 2009-11-06 22:00:41 +03:00
nsis New NSIS script 2009-09-14 23:17:03 +04:00
output outcoff: BuildExportTable -- tab/space fix 2009-11-17 23:25:15 +03:00
perllib phash: canonicalize order, fix handling of ignored duplicates 2008-05-25 18:44:44 -07:00
rdoff Use fputs instead of fprintf for plain strings 2009-08-13 15:07:59 +02:00
test Update test files 2009-11-11 08:09:03 +01:00
.gitignore Merge branch 'master' into new-preproc 2009-07-13 21:41:33 -04:00
aclocal.m4 autoconf: detect the broken bool in OpenWatcom 1.8 2009-03-01 13:57:40 -08:00
assemble.c Comment out matches() operand flags logic 2009-11-06 00:08:38 +03:00
assemble.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
AUTHORS Add Cyrill Gorcunov to AUTHORS 2009-06-26 14:57:33 -07:00
autogen.sh autogen.sh: remove config.status 2008-04-10 14:54:02 -07:00
ChangeLog Documention Changes for Release 2.00 2007-11-25 14:25:13 -08:00
CHANGES Move the revision history into the documentation 2008-07-14 02:45:57 -04:00
compiler.h Add strlcpy() function 2009-08-10 15:59:34 -07:00
configure.in Add strlcpy() function 2009-08-10 15:59:34 -07:00
crc64.c Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
directives.dat directives: split global directives from backend-specific ones 2009-07-13 14:57:48 -04:00
directives.pl directives: split global directives from backend-specific ones 2009-07-13 14:57:48 -04:00
disasm.c continue using is_class helper 2009-10-18 12:41:14 +04:00
disasm.h NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
eval.c Various tab/space/comment cleanup 2009-10-31 20:05:32 +03:00
eval.h NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
exprlib.c NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
float.c style cleanup 2009-10-13 19:41:37 +04:00
float.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
hashtbl.c hash_init: check for size being power of two 2009-11-06 22:00:37 +03:00
hashtbl.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
insns.dat insns.dat: remove non-DREX SSE5 instructions 2009-11-09 16:53:43 -08:00
insns.h Enable fuzzy matching of operand sizes 2009-07-25 18:15:28 -07:00
insns.pl insns.pl: remove redundant empty line in enum opcode 2009-08-08 14:00:47 -07:00
INSTALL Update the INSTALL file to match current reality 2008-06-28 18:53:55 -07:00
install-sh NASM 0.98.30 2002-04-30 21:09:12 +00:00
labels.c Fix some format strings for nasm_error 2009-08-11 02:43:41 +02:00
labels.h Drop the ofmt and errfunc arguments to label definition functions 2009-07-18 18:43:58 -07:00
LICENSE NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
listing.c listing: preserve list file on error, include errors 2009-07-07 12:04:12 -07:00
listing.h NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
macros.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
Makefile.in Merge elf header files 2009-11-06 22:00:41 +03:00
mkdep.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
nasm.1 nasm.1 -- update contents 2009-07-31 14:30:33 +04:00
nasm.c stdscan: switch to stdscan_get/set routines 2009-10-31 20:02:43 +03:00
nasm.h opflags: more int32_t -> opflags_t conversions 2009-10-13 12:29:01 -07:00
nasm.nsi nasm.nsi: use "delete recursively" specificator 2009-09-27 16:00:06 +04:00
nasm.spec.in spec: change License to BSD 2009-07-06 11:14:38 -07:00
nasmlib.c nasmlib: Introduce idata_bytes helper 2009-10-31 20:02:14 +03:00
nasmlib.h Don't boundcheck 64-bit numbers, it gives problems due to overflows 2009-11-11 07:39:21 +01:00
ndisasm.1 Update manual pages 2007-09-19 21:41:27 -07:00
ndisasm.c Use fputs instead of fprintf for plain strings 2009-08-13 15:07:59 +02:00
opflags.h opflags: more int32_t -> opflags_t conversions 2009-10-13 12:29:01 -07:00
parser.c Revert "BR 2887108: Use overflow_ helper to catch inappropriate imm optimization" 2009-11-01 10:24:48 +03:00
parser.h Drop efunc and evaluate argument to parse_line() 2009-07-18 18:49:55 -07:00
phash.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
pptok.dat pptok: change %rimacro to %irmacro 2009-07-14 21:00:40 -05:00
pptok.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
preproc.c preproc.c: expand_smacro -- break endless loop for interminable macro recursion 2009-11-21 11:11:29 +03:00
preproc.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
quote.c quote: use nasm_assert() instead of plain assert() 2009-07-15 16:30:30 -04:00
quote.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
raa.c Remove function pointers in output, simplify error handling 2009-07-18 18:43:12 -07:00
raa.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
rbtree.c Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
rbtree.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
README BR 2826669: update licensing information in README 2009-07-26 15:40:38 -07:00
regs.dat Add copyright notices to other *.dat files 2009-06-28 16:58:10 -07:00
regs.pl opflags: more int32_t -> opflags_t conversions 2009-10-13 12:29:01 -07:00
saa.c Remove function pointers in output, simplify error handling 2009-07-18 18:43:12 -07:00
saa.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
standard.mac NASM: relicense under the 2-clause BSD license 2009-07-06 11:09:11 -07:00
stdscan.c stdscan.c: use TOKEN_EOS and string helpers 2009-10-31 20:05:50 +03:00
stdscan.h stdscan: switch to stdscan_get/set routines 2009-10-31 20:02:43 +03:00
strfunc.c Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
sync.c sync.c - introduce swap_sync helper 2009-07-20 17:59:00 +04:00
sync.h Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
syncfiles.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
tables.h opflags: more int32_t -> opflags_t conversions 2009-10-13 12:29:01 -07:00
TODO General push for x86-64 support, dubbed 0.99.00. 2007-04-12 02:40:54 +00:00
tokens.dat Add copyright notices to other *.dat files 2009-06-28 16:58:10 -07:00
tokhash.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00
ver.c Add copyright headers to the *.c/*.h files in the main directory 2009-06-28 17:13:04 -07:00
version NASM 2.08rc4 2009-11-13 14:12:37 -08:00
version.pl Add copyright verbiage to Perl scripts; update LICENSE 2009-06-28 16:54:44 -07:00

              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.