nand2tetris/vm
Nemo 286df5b147 [08] Finishes call/init implementation
Found 2 bugs:

0. ic+=10 is incorrect jump for the boolean compare methods
1. Another bug was in the write() method, which was increasing the instruction
counter even for label commands, which aren't supposed to do that.

Another minor issue in my interpretation of the "call" to `Sys.init`
which I was so far just doing via a jump. Changed that to a proper call
2020-06-04 15:48:49 +05:30
..
CodeWriter.php [08] Finishes call/init implementation 2020-06-04 15:48:49 +05:30
CommandType.php [08] Implement Return/Function/Init 2020-06-04 15:48:32 +05:30
Parser.php Break into multiple files for easier navigation 2020-06-02 03:19:28 +05:30
README.md [07] Initial work on VM Translator 2020-06-01 19:49:55 +05:30
VMTranslator.php [08] Implemented call, but it is breaking somewhere 2020-06-04 15:48:44 +05:30

README.md

VM Implementation

We have 8 segments:

  • argument
  • local
  • this/that
  • pointer
  • static (shared)
  • constant (shared)
  • temp (shared)

RAM Address | Usage ============|================= 0-15 | Virtual Registers 16-255 | Static Variables (shared) 256-2047 | Stack 2048-16384 | Heap 16384-24575 | Memory mapped I/O

Register | Name | Usage ==========|========|========= RAM[0] | SP | Stack Pointer RAM[1] | LCL | local RAM[1] | ARG | argument RAM[3] | THIS | this RAM[4] | THAT | that RAM[5-12] | temp Segment RAM[13-15]| General Purpose Registers

The implementation is written in Modern PHP with static typing. Uses the following 3 classes

  • CommandType as a Enum for using command types as constants
  • Parser, mostly as defined in the specification
  • CodeWriter, mostly as defined in the specification
  • VMTranslator which combines the above