ROBOTC for Arduino - Call Stack  

The Call Stack debugger window was designed for the inclusion of recursion in ROBOTC. It tracks the order, or 'stack' of which functions are 'called' in a LIFO(Last In First Out) system.

An example of this (shown below) is three functions being called in a program; task main calls FunctionOne, FunctionOne calls FunctionTwo, and FunctionTwo calls FunctionThree (Last In). FunctionThree then calls itself (recursion) multiple times. When FunctionThree has completed its loop it exits (First Out) back to wherever it was called from (in this case, FunctionTwo) and program flow continues.



As shown above, the Call Stack debugger window tracks each function as it's called (starting with Task Main at address x00) and 'stacks' each function calling on top of the one that called it. The PC line shows where the program is currently running at, and as functions end the Call Stack will shrink to reflect the removal of those functions from the stack.


Copyright © 2012 Robotics Academy/Robomatter - http://robotc.net/