The stack frame for Sys.init

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The stack frame for Sys.init

rahulsubramanian
I was unable to pass the FibonacciElement test for quite a while despite cross-checking each individual function multiple times. Originally, the way I was implementing the Bootstrap code was by
- setting SP to 256
- making a traditional call to Sys.init

This however was not working, and after browsing through some of the discussions, I tried
- setting SP to 261
- jumping to Sys.init

This somehow works and passes the test. But I really don't understand why or how.

In the former case, here is what should happen:
- SP = 256
- push RET, LCL, ARG, THIS, THAT (SP becomes 261)
- ARG = 261 - 5 = 256
- LCL = 261
- jump to Sys.init and never returns

In the latter case, here is what should happen
- SP = 261
- Unsure about ARG and LCL
- jumps to Sys.init and never returns

What am I missing? Why does a traditional call to Sys.init not work?
Reply | Threaded
Open this post in threaded view
|

Re: The stack frame for Sys.init

rahulsubramanian
Fixed. The issue was not around this at all. I mishandled some labels, which was causing NestedCall to fail. Luckily for me, I was able to spot it due the same label name being used in NestedCall/Sys.vm

I'm able to set SP to 256 and make a call to Sys.init. All tests pass. :)