problems with zero arguments...solved

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

problems with zero arguments...solved

bubkas22
So I'm getting very close to the end of project 8.

I was having troubles with functions that had 0 arguments, like Class1.get.  I think I've boiled down the problem to the following:

In the case of a function with zero local variables, LCL and SP can point to the same address, this is not a problem, because there's not going to be any overwriting going on.

In the case of a function with zero arguments, originally I thought that ARG could point to the same address where the saved ReturnAddress was stored, but then found that the return address was being overwritten by my return value of -2, and return tried to jump there, and that didn't work.  Then I thought that ARG could point to *returnAddress - 1, but then my return value was consuming stack values....

______

And this is exactly the moment I realized my (return) logic was actually messed up from the beginning.  I was putting my return value where it was supposed to go, but that sometimes overwrites the return address.  I had started putting other wacky code into my calls to try to make it work, when I just needed to change the order of operations.

Anyway, I've made it run now, and I'm super excited to move on from these chapters.

Woot!