project 8: fibonacci_element and static_test .tst files errors

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

project 8: fibonacci_element and static_test .tst files errors

minchopaskalev
Hi, I found the following errors in the mentioned files:

--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst
+++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst
@@ -11,6 +11,8 @@ output-file FibonacciElement.out,
 compare-to FibonacciElement.cmp,
 output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;

+set RAM[0] 261, // missing initial SP value
+
 repeat 6000 {
   ticktock;
 }

--- a/projects/08/FunctionCalls/StaticsTest/StaticsTest.tst
+++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.tst
@@ -8,7 +8,7 @@ output-file StaticsTest.out,
 compare-to StaticsTest.cmp,
 output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1;

-set RAM[0] 256,
+set RAM[0] 261, // wrong initial SP value, given the comparison file

 repeat 2500 {
   ticktock;
Reply | Threaded
Open this post in threaded view
|

Re: project 8: fibonacci_element and static_test .tst files errors

dolomiti7
Hi,

These are not bugs. It is a similar topic as discussed in this thread.

In project 8 your VM translator is supposed to generate the bootstrap code. According to the convention in the book, the bootstrap has to initialize SP (to 256) and generate a call to Sys.init at the end of your bootstrap code. This will implicitly bring SP to 261. Your addition to the test file indicates that either you did not generate a bootstrap code at all, or your bootstrap does not initialize SP (and potentially your code just jumps to Sys.init instead of generating a call).

In the second example StaticsTest, the line set RAM[0] 256 is actually not wrong, but redundant. As described above it is your bootstrap code that should set SP properly at the beginning of the program, not the test script. You can actually remove this line and if your translator works properly, it should still pass the test. I assume the line is in the test script because of a copy&paste from project 7 (projects\07\MemoryAccess\StaticTest\). In project 7 this line is actually required since there is no bootstrap code yet. For project 8 the line should be removed, so if you want it can be considered as an error. In no case it should be replaced with your proposal.

Hope that helps
Reply | Threaded
Open this post in threaded view
|

Re: project 8: fibonacci_element and static_test .tst files errors

dolomiti7
Add on:

Whether or not to generate a bootstrap has been discussed here already.

However, I would argue the better criteria is if Sys.vm exists in the folder. As soon as this file is found by the translator, it should issue the bootstrap code at the beginning of the ASM output file.

Which means for the 4 tests under 08/FunctionCalls only the first test "SimpleFunction" does not require a bootstrap code in the generated ASM file.
Reply | Threaded
Open this post in threaded view
|

Re: project 8: fibonacci_element and static_test .tst files errors

minchopaskalev
I must have missed the bootstrapping part while watching the videos, since I'm doing the coursera course, free, and don't have the book also.

Adding the bootstrapping code (i.e setting SP at 256 and calling Sys.init) did it.

Thank you for the clarification!