Nesting of Subroutines

As should be obvious from the fact that these subroutines themselves use MIAMEX.SBR for parameter passing, it is possible to nest subroutine calls, regardless of whether the subroutines are written in BASIC or C. Each level of nesting, though, does use up memory and stack space so it is not recommended that you get too carried away with nesting, particularly with highly recursive subroutine calls.

If you are planning to nest subroutines, for maximum speed it is best to make sure the main memory partition has enough free space for the minimum SBX memory, plus the actual amount of SBX memory required for the number of levels of nesting. As long as there is sufficient free memory available in the partition for the minimum requirement (360K or as specified by the MEMORY= statement), then it will actually only use as much as is needed. So for example, if you have 500K free in the main partition and your SBX minimum is 360K, the first SBX call will simply take over the 500K available. But if the subroutine is small, it might only use up, say, 30K of that 500K, leaving 470K free for the next level down. You could repeat that process severa levels deep before the original 500K was used up, after which separate system memory allocations would have to be made for subsequent levels.