Notes on the CPU Emulator
For more in-depth information
about the test script file format
the Appendix B of the nand2tetris book.
How to implement “RAM[RAM[x]] = RAM[y]”?
The test script file
works as follows.
if your program doesn't finish all the computations
within the number of clocks (the value after repeat)
the CPUEmulator may conclude that your program
think this is the case, just
increase the number of clocks for
(Note that this may increase the running time.)
- Set the operands
(RAM[R0] and RAM[R1]).
- Run the program for some
time (repeat xxx)
- Print the output (RAM[R0],
How to implement
To pass a negative constant value.
(We can pass only a positive value
using an A-instruction
due to its 15-bit limit.)
Example: to store -123 in RAM[x].
(For MacOS users)
You should install the Java SDK
(not the JRE)
to make the screen work correctly.
this page for more information.