jacklack wrote
The Hack architecture and assembler handle "jump if less or equal" and "jump if greater or equal", but the virtual machine and the jack language don't.
It should be easy to add them the Virtual machine, and will require one look ahead in the compiler ">=" or "<=".
It would also increase program performance, as we won't need to test for "if( a < b || a = b)
we would just write if( a <= b ).
Because operator precedence is
undefined in the Jack language (and is implemented as strictly left to right in JackCompiler) that needs to be "if( (a < b) | (a = b) )". Note that you can also use "~(a>b)" which is more efficient.
I tried to implement the Math.jack class with it, and changed my virtual machine and compiler accordinly, but when loading the program in the Java virtual machine it complains about "ge" and "le" (greater or equal and less or equal, as it understand only "gt", "lt" (greater than, less than).
Can this be added to the nandtotetris vm and compiler? I downloade the nandtotetris source to add them myself but found it a little bit difficult, as I got loads of errors from the new java compiler.
You should be able to test your Compiler and VM Translator by assembling the output and running it in the CPU Emulator.
I think you are on your own as far as modifying and rebuilding the VMEmulator program, though.
--Mark