Bootstrap - SP Initialization

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

Bootstrap - SP Initialization

digitaladdictions
I just finished my VMTranslator from Chapters 7 and 8. There is one minor problem with it though and I don't know if its a bug in my implementation or in the test scripts.

My understanding is that the bootstrap code should set the SP to 256. However, both the FibonacciElement and StaticsTest fail with the SP initialized to 256. They both pass however if I move the SP to 261 in the bootstrap code.

The book claims both of these programs expect you to write the bootstrap so I don't know why the test scripts would assume 261.

Am I missing something? Is this part of the test? Should I be detecting this and setting the SP dynamically rather than hard coding 256 in the bootstrap?  

Thanks
-- Justin
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap - SP Initialization

digitaladdictions
I figured out my problem. As cadet1620 pointed out here.  I was jumping to Sys.init instead of calling it.

http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Why-is-the-sp-set-to-261-in-StaticsTestVME-tst-td4029015.html

And now I am officially done with Chapter 8.  *Phew*  Chapters 7 and 8 took me longer than chapters 1-6 did all together.  This is probably the longest program I have written.

On to Jack.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap - SP Initialization

ybakos
Great!