NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: cinolt on May 11, 2017, 05:27:36 AM

Title: "interminable macro recursion" error
Post by: cinolt on May 11, 2017, 05:27:36 AM
Straight from the docs in section 4.1.1:

Code: [Select]
%define a(x)    1+a(x)

        mov     ax,a(3)

a(3) is supposed to expand only once, but NASM complains with "error: interminable macro recursion".

So, this is either a bug in NASM itself or a bug within the docs.

Tested with versions 2.10.07 and 2.13.01.
Title: Re: "interminable macro recursion" error
Post by: Frank Kotler on May 11, 2017, 06:03:28 AM
Hi cinolt,

Welcome to the Forum.

What I see in the Friendly Manual is:
Code: [Select]
%define a(x)    1+b(x)
%define b(x)    2*x

        mov     ax,a(8)
which is not the same as the code you've posted.

Code: [Select]
%define a(x)    1+a(x)
is, in fact, interminable.

Am I looking in the wrong place in the Manual?

Best,
Frank

Title: Re: "interminable macro recursion" error
Post by: Frank Kotler on May 11, 2017, 06:34:26 AM
Okay, my apologies, I didn't read far enough. It does say it'll do that. Although it may be an error in Nasm, I'd treat it as an error in the documentation. Seems to me like an "obviously wrong" thing to try to do.

Do you have something in mind for this? What would you like it to expand to?
Code: [Select]
mov ax, 1 + a(3)
?

Straighten me out here...

Best,
Frank

Title: Re: "interminable macro recursion" error
Post by: cinolt on May 11, 2017, 06:58:11 AM
My use-case for this feature isn't really simple to explain, basically I was trying to do something like:

Code: [Select]
%define BLAH BLAH
for some hacky work-around stuff I was trying to do. In either case the documentation should be updated.