Multiple vm files

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

Multiple vm files

javalilly
I am slightly confused about what is being said in the book about the multiple .vm files that hold separate commands. It is not talking about the subtract, add, and, or...command correct? These files are more like having methods in a higher level object oriented program right? So, for example, I could make a .vm file that multiplied 3 numbers togetherm but within the file are the stack commands that multiply the 3 numbers using the stack arithmetic commands?

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

Re: Multiple vm files

javalilly
Just to clarify: I know that the book says that what is within the files are more like methods, but I don't understand why my logic above would be incorrect.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple vm files

cadet1620
Administrator
In reply to this post by javalilly
javalilly wrote
I am slightly confused about what is being said in the book about the multiple .vm files that hold separate commands. It is not talking about the subtract, add, and, or...command correct? These files are more like having methods in a higher level object oriented program right? So, for example, I could make a .vm file that multiplied 3 numbers togetherm but within the file are the stack commands that multiply the 3 numbers using the stack arithmetic commands?
You are mostly correct. Each VM file holds all the functions, methods and constructors of an object class.  You might want to take a look at chapter 9 to get a preview of how Jack object classes work. In chapter 8 you will learn how the "function," "call" and "return" VM commands work.

--Mark
Loading...