Login  Register

Problem with staticsTest.tst

classic Classic list List threaded Threaded
7 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Problem with staticsTest.tst

nandona
17 posts
Is it supposed to set RAM[0] to 256? because then the test fails even if all my output, relatively to the stack starting at 256, are -2 and 8.
My final stack looks like this
RAM[256] -2
RAM[257] 8
RAM[0] 258
However in the vmtest the stack starts at 261 so if I change my test file to set RAM[0] to 261 at the beginning my program passes the test
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

WBahn
Administrator
1541 posts
What is your bootstrap code doing?

It sounds like you are not calling Sys.init().

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

nandona
17 posts
I ran my translator on Sys.vm and then changed the file name lol. I probably needed to make like a StaticsTest.vm which contains call Sys.init 0 and then run it on this one. Did I get that right now?
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

WBahn
Administrator
1541 posts
nandona wrote
I ran my translator on Sys.vm and then changed the file name lol. I probably needed to make like a StaticsTest.vm which contains call Sys.init 0 and then run it on this one. Did I get that right now?
I don't follow what you are trying to say. Changed the name of what file? To what? Why?

All of the .vm files you need are right there in the StaticsTest directory.

At the point where you are performing this test, you are supposed to have your full-up translator implemented, which includes the bootstrap code. What the bootstrap code does is detailed at the end of Section 8.3.1.

If you have implemented your translator correctly, all you need to do is run it on the StaticsTest folder and then run the StaticsTest.tst file using the CPU Emulator.

If all else fails, walk through the execution of the .vm files by hand with pen and paper to see why the values in the comparison file are what they are.


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

o.shmalko
3 posts
In reply to this post by nandona
Hello! I Encountered this problem with .cmp file also. After all calculations, I make a decision that RAM[0] = 263 is incorrect absolutely. You can go through all commands in this Sys.vm and understand that SP should change like that:

SP = 257 after return from Class1.set 2
SP= 256 after pop()
SP = 257 after return from Class2.set 2
SP = 256 after pop()

SP = 257 after Class1.get 0
SP = 258 after Class2.get 0

And another thing that is looks wrong is that .cmp file expects -2 and 8.
Probably earlier there was another code, but I have next Sys.init:
function Sys.init 0
        push constant 6
        push constant 8
        call Class1.set 2
        pop temp 0 // dumps the return value
        push constant 23
        push constant 15
        call Class2.set 2
        pop temp 0 // dumps the return value
        call Class1.get 0
        call Class2.get 0
label END
        goto END

So, there twice setting different values into static segment by call Class[1or2].set2.
After both, static segment is: RAM[16]= 23, RAM[17]=15
And Class[1or2].get 0 should produce their sub: 23-15 = 8. So, there is no -2 should be.

Please, share your thoughts.
I think that developers of this test should review it.
Regards, Oleksandr Shmalko

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

o.shmalko
3 posts
Okey, I got another one detail. StaticTestVME.tst makes SP to look at 261 at the start. But in my case it don`t forces SP to 261, because of bootstrap code makes SP to look at 256 ( it overrides 261 probably ).

But how -2 can appear, it is a secret. Still looks like a incorrect expected value
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Problem with staticsTest.tst

o.shmalko
3 posts
Oh. I GOT IT. Each .VM file should operate it`s own Static segment.
So, each Set,Get function uses different RAM addresses for static pointer.