Well I am not passing the statics test. I have figured out that my return logic is incorrect. Question is it says in the book that the very next instruction after the call is the return address. So are they saying that the return address comes after the all the assembly code that calls the function or are they saying that it should be calculated in the vm implementation somehow.
The return address label goes after the jump to the called function, before the code for the next VM statement.
// call Sys.error 1
code to push D on the stack
code to build the stack frame
// pop temp 0
One of the tricky things to watch out for is that when a function with no parameters returns, argument 0 and the RIP are at the same location on the stack. Don't clobber the RIP when you preposition the return value.