Henoktes722 wrote
Yeah, but to do my own simple VM translator, I need one example of .vm mapped to .hack file. So that I can check my VM translator output.
Why?
Let's consider the two commands you are using in your example, namely push and add.
What changes should the push command make to the machine state?
1) Place the value being pushed at the memory location pointed to by the stack pointer.
2) Increment the stack pointer.
For the case of pushing from the constant memory segment, what value is being pushed?
What sequence of assembly code will make this happen?
What changes should the add command make to the machine state?
1) Replace the value located two places below where the stack pointer points with the sum of the value already at that location and the value immediately above it.
2) Decrement the stack pointer.
Take you best shot at those two and then we can discuss it further, including perhaps tightening up the code some.