I'll take a look at the Java in a bit. Could you email me the compete NestedCall.asm (or Sys.asm depending on how you generated it) file. It might be easier to step through the return code to see where it went wrong.
These temporaries are only used during the return code so they don't need to be unique.
The real cool thing about this is that then the return code is identical for all instances of return. You can put a ($RETURN) label at the start of it the first time you generate it and all other returns only need to jump to that label!
Ok, ok, I see; I was treating retAddr and endFrame as variables, stored in its own RAM. But in fact, those variables are virtual machine side only; from the vm's perspective, it is saying "use this address number," not "use this variable for your address number."
Reading through the other things you mentioned now.
My "call" starts exactly like this:
+ "//->push returnAddress\n"
+ "@retAddr"+_count+ "\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n"
The problem is that on CPU emulator the address becomes @73 and then A=73 and the ARG is wrong at the end of NestedCall test (RAM(5) I am getting 5 instead of 135). I had no problem with SimpleFunction and Call.
Please help. What am I doing wrong?