pong vm to asm

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

pong vm to asm

trogne
This post was updated on .
My vm translator works fine for project 8, for "FunctionCalls" and "ProgramFlow".

Now I'm trying to use it with the Pong game from folder "projects/11/Pong".

In this folder, there are 4 jack files.
I compiled them to VM, and the game runs fine using the vm emulator.

But if I then try to translate the VM files using my vm translator, the generated ".asm" file will not work.


Is there something I have to take into consideration ?


I tried adding a "Sys.vm" file with "function Sys.init 0" and "call Main.main 0", but it's not working.


If I copy the "vm" files from "tools/OS" into the Pong directory, and translate again to .asm, then when I open this asm with the cpu emulator, I get "Program too large".


Anyone have a vm translator that can translate the pong vm to asm ?



Reply | Threaded
Open this post in threaded view
|

Re: pong vm to asm

ivant
The HACK architecture support programs of up to 32768 words. A naive VM to CPU translator with no optimizations will produce larger ASM program. The VM Emulator doesn't have such limit, so your program can run there.

Optimization is an interesting and fun (if you're into that kind of thing) topic. But I advise you to leave it for after you've done with the hole course. After that you can go back and check this post or search the forum for various discussions.
Reply | Threaded
Open this post in threaded view
|

Re: pong vm to asm

trogne
Great, thank you !
Reply | Threaded
Open this post in threaded view
|

Re: pong vm to asm

trogne
In reply to this post by ivant
Is it only a matter of optimization ?

Does moving all the "vm" files from "tools/OS" to the Pong folder, the right thing to do before applying the vm translator ?        (except for "Ball.vm" since there's already a "Ball.vm" in the Pong folder).
Reply | Threaded
Open this post in threaded view
|

Re: pong vm to asm

WBahn
Administrator
Yes, you need to have any of the O/S files that are actually used by the program available to the Translator.

Yes, it's a matter of optimization, but there are several kinds of optimization that you can use.