Need help understanding VM vs VMTranslator

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

Need help understanding VM vs VMTranslator

AlexKrel
Whenever I would think of the Java virtual machine, I thought of it as a program that acts like a machine by translating the intermediate instructions at run time (along with doing a lot of other run time tasks). This seems a lot different from our VMTranslator, which translates the VM code before run time.

Can someone help me understand this?

Thanks,
Alex
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need help understanding VM vs VMTranslator

cadet1620
Administrator
The n2t VM Emulator is the equivalent of Java's JVM.  It runs the n2t VM language.

The Jack Compiler translates Jack to VM similar to the Java Compiler translating Java to bytecode.

The VM Translator functions as a "back end" to the Jack Compiler to produce a machine language program that can run on the Hack CPU Emulator.

You can see how this works by looking at Pong in the distribution.

Running JackCompiler on projects/11/Pong/Pong*.jack
    generates Pong*.vm files
Running (your) VM Translator on Pong*.vm and tools/OS/*.vm
    generates Pong.asm
Run Pong.asm on the CPU Emulator to play the game (albeit rather slowly).

projects/06/pong/Pong.asm is an example of the output from a VM translation of Pong.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need help understanding VM vs VMTranslator

ivant
In reply to this post by AlexKrel
You can also check my answer about various types of virtual machines ‚Äčhere.
Loading...