So far my VM translator has passedthe two program flow tests, as well as the SimpleFunction test. However, when I run the NestedCall test I get a CPU error because -1 ends up in the LCL register.
I walked through the code and it looks like all the returns, functions call etc. are working...until the return for Sys.main. At that point, it looks like the program is setting the LCL, ARG, THIS, and THAT pointers to M[260]-M[257]. This makes me think that somewhere in the program these pointers are improperly set. However, I can't see any issue with my VM code for the return and function commands, and they worked properly in SimpleFunction test. The call command also appears to work properly.
Would someone be willing to take a look at the assembly code my translator generates and help me identify what the issue is? Here's a link to my code:
https://drive.google.com/open?id=1LasX9WVKtxkJmtXJLlN1CvRgmxcieGXH
I would really appreciate any insight! However, if you do see what the problem is, I'd appreciate it if you only gave a hint for how to fix it.