Macros - How Many levels deep can your go?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

Macros - How Many levels deep can your go?

Post by Ron »

Hi,

I am writing my first macros and I was wondering what the limits are regarding macros calling other macros.

In my case everything is completely linear.

My main flowchart calls MACRO 1.

MACRO 1 will call one of 4 other "MACROS XX" based on a parameter tested by MACRO 1.

MACROS XX will call one of two possible MACROS YY.

Then MACROS YY will complete, return to MACRO XX which will complete, and then return to MACRO 1 which will complete and return to the main flowchart.

This is a pure tree structure, there are no "stars" at any point.

Am I to deep with macros calling other macros?

What are the limits?

Thanks

Ron

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello Ron

The absolute maximum subroutine levels in a PICmicro is 8. However it is always good practise to leave at least two of these levels free incase an interrupt or something similar occurs. If a interrupt did occur that went over the 8 levels of return adress stack then the PICmicro would become lost and may start to execute code in a random manner.

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Although there are only 8 levels of stack in the PICmicro's hardware, the underlying C compiler is a bit more clever and can be set to use a software stack. So in theory, you should be able to use a lot more macro calls than 8.

Look at the "BoostC.pdf" help file - search for "stack" or "-swcs" for more information.

Post Reply