Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - stackavail() return the size of available stack memory http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 stackavail()        Return the size of available stack memory
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   func uint stackavail extern

 Arguments
   None.

 Return
   Number of bytes available on the stack.

 Description
   The stackavail() function returns the current size of free stack memory.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   proc Test1
   // Function that uses much stack space
   vardef
      byte aBig[ 10000 ] // produces runtime error if compiled/linked with
   enddef                // too small stack size!
   ? stackavail()
   endproc
   
   proc Test2
   // Function that itself does not use the stack
   ? stackavail()
   endproc
   
   proc Test_stackavail
   ? stackavail()  // Displays nearly the full amount of stack.
   Test1()         // Displays small value as much of the stack is in use.
   Test2()         // Displays again big value demonstrating that stack used
                   // by local variables is discarded after the call.
   ? stackavail()  // Displays the original value.
   endproc

   proc main
   Test_stackavail()
   endproc

See Also: __stackmin

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson