NestedCall Test failure

classic Classic list List threaded Threaded
3 messages Options
bin
Reply | Threaded
Open this post in threaded view
|

NestedCall Test failure

bin
FibonacciElement  Test success
SimpleFunction Test success
StaticsTest Test success
NestedCall Test failure

I compared the results of VM emulator and CPU emulator and found that the temp segment was not correct.
This is two pictures of the CPU test.



This is a picture of the VM test.


I checked the code of my VM translator again, but I still couldn't find the problem.
I hope someone can give me some help and point out where my problems are located.
Thank you very much
Reply | Threaded
Open this post in threaded view
|

Re: NestedCall Test failure

cadet1620
Administrator
Check that the "pop temp N" code is accessing RAM[5+N]. It looks like the "pop temp 1" in Sys.init wrote into RAM[5] and left RAM[6] untouched. (The -1 was set by the test script before running your code.)

If you have not already done so, you may want to write the VM source code as comments in the generated .vm file. This makes debugging quite a bit easier:
// function Sys.init 0
(Sys.init)
// push constant 4000	// test THIS and THAT context save
    @4000
    D=A
    @SP
   ... more asm ...
// pop pointer 0
   ... more asm ...
    @3
    M=D
...
// call Sys.main 0
    @$RIP$2
    D=A
    @R13
    M=D
    @Sys.main
   ... more asm ...
($RIP$2)
bin
Reply | Threaded
Open this post in threaded view
|

Re: NestedCall Test failure

bin
Thank you for your reply.

I have found the reason.

Temp 0 should be R5+0.

I understand that the value of R5 is taken as an address and then the value of this address is added to it, plus 0.

Pop temp 0

I understand it

@R5

A=M

M+0

In fact, it is

@R5

A+0