Order of processing for multiple .vm files

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

Order of processing for multiple .vm files

cyboman
I am confused about directory processing of .vm files. Since we generate a single .asm file, in what order should we process the .vm files? Also since we combine output into a single file, won't the results of operations from one .vm file affect the calculations from the other .vm file?
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

cadet1620
Administrator
cyboman wrote
I am confused about directory processing of .vm files. Since we generate a single .asm file, in what order should we process the .vm files? Also since we combine output into a single file, won't the results of operations from one .vm file affect the calculations from the other .vm file?
It doesn't matter in what order you process the .vm files. Symbols that might conflict between vm files are decorated with the module (vm file) name or function name. See the table at the end of end of 7.3.1 and figure 8.6 for details. For project 7 you only need to worry about the "static" segment.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

ybakos
In reply to this post by cyboman
Also note that the first VM tests inject a little "initialization" code before running your generated instructions.

You'll add this initialization code yourself at the end of your vm construction.

It's this initialization code that kicks off the execution of Main.main.
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

Andrew
Should a single, consolidated, master .asm file as described be able to run any of the test scripts at the chapter seven stage? I was able to run it on test scripts by renaming it to the script being run, but the outputs do not compare. Individually, the mini .asm files put together by my Virtual Machine have been passing the tests, but when I String them together it does not achieve the same result.

I imagine things are orchestrated a bit by the startup code. And I also see why it would fail all but the last file parsed. But since producing a single file was specified, I'm wondering if I can test it to make sure it's correct.

By the way, if I haven't said so before, I am really enjoying this course. A big thank you to anyone making it possible.
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

cadet1620
Administrator
Andrew wrote
Should a single, consolidated, master .asm file as described be able to run any of the test scripts at the chapter seven stage? I was able to run it on test scripts by renaming it to the script being run, but the outputs do not compare. Individually, the mini .asm files put together by my Virtual Machine have been passing the tests, but when I String them together it does not achieve the same result.
I don't understand what you mean by stringing your .asm files together.  Each of the 5 tests in project 7 are single .vm files that are to be translated to single .asm files of the same name. Each resulting .asm file is an independent program.

When you get to chapter 8 you will encounter tests that have multiple .vm files. Then your VM translator will process all the .vm files in the directory generating a single .asm file with the same name as the directory.

Note that the chapter 7 tests are in directories that have the same name as the single .vm file so that you can process either the single file or the entire directory, with the same results.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

Andrew
I see thank you. I thought they might be meant to run together as a single program file at some point. So these are separate programs and would each have their own directories on a hard drive, and would be its own complete rom instruction set. To use a gaming machine as an example, each would be its own separate game cartridge?
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

cadet1620
Administrator
Yes, each of the tests builds its own complete ROM image. That's why they're in their own directories.

A more complex example can be seen in the projects/08/FunctionCalls/StaticsTest test. There you will see three .vm files (Class1, Class2 and Sys) that need to be processed as a directory to produce StaticsTest.asm.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Order of processing for multiple .vm files

Andrew
Thanks a bunch, it's clear to me.