Slight problem

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

Slight problem

pawdwanlearner
I sense a disturbance in the force.<smiley image="anim_confused.gif"/> I am testing my vm translator using the supplied test in chapter 8. The test i am working on is simple function. When i look at the tst file, in the setup section for the CPU emulator Ram[312] = 1000 however in the VM emulator tst file Ram[312] = 9. Has anyone else seen this. If so which one is the correct value at that location.

Oh and by the way. Many thanks to all those who helped me Especially you Cadet.  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Slight problem

cadet1620
Administrator
Good eyes! I don't recall anyone else asking about that.

Those 5 values after the 2 arguments are the stack frame that the "call SimpleFunction.test 2" would have set up before it entered the function. The saved pointer values will be copied into their registers by the "return".
arg -> RAM[310] 1234,
       RAM[311] 37,
       RAM[312] 1000,      // return IP
       RAM[313] 305,       // saved LCL
       RAM[314] 300,       // saved ARG
       RAM[315] 3010,      // saved THIS
       RAM[316] 4010,      // saved THAT
lcl, sp -> 317
The return IP is a ROM address in the CPUEmulator and a VM code line number in the VMEmulator.
For the CPUEmulator, your code will return to 1000 and continue running for up to 300 empty instructions.
For the VMEmulator, the return instructions is the last instruction executed.

--Mark
Loading...