VM to Assembly Translation

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

VM to Assembly Translation

javalilly
In Chapter 6, there was an example of a translation of assembly code to machine code (prog.asm -> prog.hack). Is there such an example for the translation of vm to assembly code in the book that I may be overlooking?

thanks
Reply | Threaded
Open this post in threaded view
|

Re: VM to Assembly Translation

cadet1620
Administrator
javalilly wrote
In Chapter 6, there was an example of a translation of assembly code to machine code (prog.asm -> prog.hack). Is there such an example for the translation of vm to assembly code in the book that I may be overlooking?
There are no examples of vm to assembly code; you are expected to develop these on your own.

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

Re: VM to Assembly Translation

javalilly
I thought we were to develop the software to translate the asm code?
Which leads me to another question. Are there multiple ways to write a function in assemly code? It seemed so straight forward that I thought all functions were pretty much written the same way.
Reply | Threaded
Open this post in threaded view
|

Re: VM to Assembly Translation

cadet1620
Administrator
javalilly wrote
I thought we were to develop the software to translate the asm code?
You should have already written your assembler that translates Hack Assembler source to machine code in chapter 6.

The big picture is that you will write a compiler to translate Jack (a simple object oriented language) to VM code in chapters 10 and 11, and you will write the VM translator that converts VM code to Assembler source in chapters 7 and 8.
Which leads me to another question. Are there multiple ways to write a function in assemly code? It seemed so straight forward that I thought all functions were pretty much written the same way.
There are many different ways to write the assembly code that implements the VM statements. The straightforward code is not always the most efficient. For your first pass through the book, don't worry too much about optimization. By the time you complete the book you will have likely have ideas about optimizing your code, and then you may want to go back to your VM translator and make it more efficient.

--Mark