Bootstrap code

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

Bootstrap code

hemasaad
I read other posts but I get that sometimes you need to comment your bootstrap code in some test files and in other you need to activate them but in general i don't know when activate and deactivate for any directory contains vm files.
what I wrote in my code is: if(isexist(sys.vm)){WriteInit();} else {nothing}
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

Sai krishna
Is that the correct way to implement? I also wanted to do the same. If the directory contains sys.vm file it needs bootstrap code. Else no. But I believe not for all the tests directory is passed to the translator. Only for the Fibonacci element, statictest, nested call the directory is passed. In the other test cases we need not write bootstrap code right? Please clarify. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

WBahn
Administrator
Once your translator is finished, it should ALWAYS insert the bootstrap code unless you are intentionally using if for purposes other than what it is intended, which is to translate the VM code generated by the compiler into executable assembly code.

Chapters 7 and 8 merely allow you to walk in baby steps as you complete your translator. First is being able to translate single files in which the test scripts set up memory in such a way that you don't need the bootstrap code or the OS files. Then you translate entire directories, but again without needing the bootstrap code. In the last two test programs, your translator needs to be completed and performing according to the VM specification, which includes the specified bootstrap code.

Within the scope of the Nand2Tetris project, once you have completed the VM Translator, it would only be used to translate compiled programs, all of which are expected to contain the OS files, or at the very least Sys.vm. In fact, I'm pretty sure that once you finish Chapter 8, you are never actually required to use the VM Translator again -- all of the later projects use the VM Emulator. I'd have to check to be sure of that, but one of the goals is that you are supposed to be able to do the projects in any order (Chapters 7 and 8 are a single project, as are Chapters 10 and 11) and since the authors don't provide a VM Translation tool, it stands to reason that you can accomplish all of the later projects without one.

Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

Sai krishna
Thank you for your kind reply. It helped. Could you please provide some additional final clarification regarding whether for all the tests the entire program directory is passed or for what specific tests only the entire program directory is passed? Thank you. Hoping a reply.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

WBahn
Administrator
I'm not sure what clarification I can provide beyond what it says in the text, which is pretty explicit. For instance, towards the end of Section 8.5 it states, "The first three test programs in this project assume that the bootstrap code was not yet implemented, and include test scripts that effect the necessary initializations 'manually'. The last two test programs assume that the startup code is already part of the VM implementation."

Each of the first three test programs also consists of a single .vm file. For each of the other two it says something like, "Since the overall program consists of two .vm files, the entire directory must be compiled in order to produce a FibonacciElement.asm file"

Could you please be more specific about what the point of confusion is?
 
You might look at the authors website. https://www.nand2tetris.org/project08

They basically say the same thing, but I think their verbiage and terminology is a bit cleaner and more precise.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

Sai krishna
What I meant to ask is that when I submit my VMtranslator in coursera for grading, will you test my VMtranslator by passing explicitly the .vm file to my translator for the first three tests and then the directory containing the .vm files  for the Fibonacci element, StaticTest, Nested call tests(these are the tests that have sys.vm file in them)? Or only the directories containing .vm files for all the tests? Because if you pass the program directory having .vm files to BasicTest, Fibonacci series, Simplefunction(first three tests) tests the tests will fail since it is instructed that bootstrap code be written in .asm file only if a 'directory' of .vm files is passed to the translator. Which one of the above is the case? Hope I am clear. Sorry if I am still unclear.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

WBahn
Administrator
That's much clearer. Thanks.

Unfortunately, I have nothing to do with the Coursera course and so I don't know how that is handled. Perhaps someone else that sees this knows the answer.

Are you sure that you only submit a single version of your VM Translator for grading? If so, I would imagine (pure speculation on my part) that you will submit just the final version that inserts the bootstrap code and the test scripts will take that into account. As for whether you translate just one file or the entire directory, that's not up for interpretation (at least the version spec'ed in the text isn't). It has to be capable of doing both and the nature of the command line argument determines which.

It's obviously something that has been dealt with, so I'm guessing that if you read the material very closely with an eye specifically on the lookout for this issue, you will find it explained.

If you do, then by all means post what you discover -- others are bound to have the same question.

If you find something that seems to be related but can't figure out how to interpret it, then post a link to it (if it's publicly accessible) or copy and paste the relevant portions here and we can see if someone can help unravel it.
Reply | Threaded
Open this post in threaded view
|

Re: Bootstrap code

Sai krishna
Thank you for the reply. I will surely post it here if I come to know the answer.