Ok, this may end up being a stupid question but...

When I tried to compile a test proggy to check some text macros I wrote, masm moans that the nesting is too deep. How exactly is the nesting worked out, because I'm only calling macros one after another.

Example.

CreateFunct MACRO arg1,arg2
LOCAL str
str CATSTR <arg1>,<arg2>
DoesFunctExist str <-- macro
if _not_exist_ <-- global equate
AddFunct str <-- macro
endif
ENDM

I just made this up, but it shows how I've written the macros.

I thought the nesting would be like nested loops in C.

Any help would be appreciated

:confused:
Posted on 2001-11-16 20:25:37 by Maelstrom
Most likely you have an infinite loop somewhere.
Post the code for more detailed responses.
I have macros that nest several levels deep - no problems.
Even recursive macros. :)
Posted on 2001-11-16 20:34:36 by bitRAKE
With a nice little test, I found out that macro nesting can be 20 levels deep:
fib MACRO num:REQ

IF num LE 1
EXITM <1>
ELSE
EXITM %(fib(num - 1) + fib(num - 2))
ENDIF
ENDM

i TEXTEQU fib(20) ;; this is text number
;; ECHO only works with text
% ECHO i
Posted on 2001-11-16 22:27:39 by bitRAKE
If you want to compute larger Fibonocci numbers:
fib MACRO y:REQ

LOCAL a,b,e
IF y LE 1
EXITM <1>
ELSE
e = y ;; this is because 'y' is text
a = fib(e/2)
b = fib(e/2 - 1)
IF (y MOD 2) EQ 1
EXITM %(a * (a + 2 * b))
ELSE
EXITM %(a*a + b*b)
ENDIF
ENDIF
ENDM

i = fib(46) ;; look it is a number now...
% ECHO @CatStr(%i) ;; convert to text for ECHO
Posted on 2001-11-17 00:24:45 by bitRAKE
bitRAKE

Thanks for the replys.

I think you were right about a loop being the problem.

Something else I learned from your examples was that I can use EXITM to return values from an IF-block, I though you could only return values if the EXITM was at the end of the macro.

So I'm assuming from your examples that EXITM will stop expanding the macro when it is encountered. So would the following macro work correctly.



blobby MACRO
WHILE 1
IF test_successful
EXITM result
ENDIF
ENDM
ENDM


Maelstrom
Posted on 2001-11-18 03:12:13 by Maelstrom
Yes, nothing after the EXITM is executed! Try this:
Tester MACRO a:REQ

EXITM <&a>
This text here is totally ignored...
ENDM
Funny huh? :)
Posted on 2001-11-18 10:07:06 by bitRAKE