MathTest.tst fails even with provided OS .vm files
This post was updated on .
After I finished implementing Math.jack, I copied all of the provided OS .vm files into the MathTest directory, and compiled my Math.jack file, replacing the provided Math.vm file with my own.
Then I loaded the provided MathTest.tst file, and ran it in the VM EMulator. I noticed that the output had all zeros in every register, and couldn't figure out how to debug it. Eventually I realized that it was failing because it wouldn't finish execution within the 1000000 vmsteps allotted within the provided MathTest.tst.
This indicated to me that I had an inefficient implementation of the algorithm, or a simple bug, but after some time I couldn't figure it out. Eventually I replaced my Math.jack and Math.vm files with the Math.vm file provided to us (in the tools/OS directory). Surely now it has to be able to complete execution, but surprisingly it did not.
I double, and triple, checked that I was using the provided Math.vm file and not my own version.
I tried setting the number of vmsteps to 2000000, and it worked.
I also tried keeping the number of vm steps at 1000000, and instead removing all .vm files, forcing the VM Emulator to use the built-in .java implementation of the OS. That worked as well.
The instructions however clearly state to use the provided OS .vm files, and replace only the .vm file that you're currently working on.
It seems unlikely that they would have set the number of vm steps at 1000000, without a good reason, so it's really weird to me that it fails to execute, even when using only the provided OS .vm files. It's even weirder to me that I can't find a post in this forum where anyone else had the same issue, since we're working with the same files. It probably means I'm doing something wrong, but I can't figure out what. All I'm doing is using only the provided .vm files and .tst file (including the provided Math.vm file), and clicking run. It only finishes when I manually increase the number of vm steps in the .tst file.
Has anyone else had this issue? Any suggestions on how to address it without manually changing the number of vm steps?
* EDIT: To be specific, it takes exactly 1117931 vm steps for the execution to complete successfully using only the provided OS .vm files (including the provided Math.vm file). An less than that, and it fails. Would be curious to know if anyone else has the same results.