So I pass every single test except Fibonacci element. From my searches through the forum it seems the issue arises from the fact that FibonacciElement is recursive so there is some sort of overwrite happening to the varisbles LCL, ARGs, etc if we don't make them static.
However I'm having a hard time visualizing why that is the case and what would be the solution. In another thread it was suggested that we should push the variables in writeCall as if they were static. Why?
Re: FibonacciElement, recursion and pushing variables
As before, I can't do much without seeing the code, or at least decent pseudocode.
The key with recursion is that when Fred() calls Fred(), it is treated EXACTLY the same as when Fred() calls Sue(). In either case, all of the information the the called function needs has to be placed on the stack and the state registers (LCL, ARG, THIS, and THAT) updated as necessary for the called function. These then have to be restored when the called function returns, leaving the SP one location higher than it was before the call to reflect the single return value that is left on the stack by the called function.
When you don't have recursion, you can get incorrect code to pass the tests. But then actually making a recursive call puts enough additional stress to break the code.