Skip to content

Commit 2a27bff

Browse files
committed
[08] Update notes
1 parent aed6f0a commit 2a27bff

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

NOTES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,17 @@ I think there are definitely some tricks with reducing lookup table sizes, but I
6767

6868
# VM (1)
6969

70-
See `vm/README.md` for more details. Observations go here, implementation notes are there.
70+
The implementation is written in Modern PHP with static typing. Uses the following 3 classes
71+
72+
- `CommandType` as a Enum for using command types as constants
73+
- `Parser`, mostly as defined in the specification
74+
- `CodeWriter`, mostly as defined in the specification
75+
- `VMTranslator` which combines the above
7176

7277
# VM (2)
7378

7479
Learnt quite a lot. Interesting gotchas:
7580

7681
1. Stack manipuation is hard. Keeping track of registers is hard. I was going by the diagrams which always have "arguments" going from 0..n, which screws up the one case where you don't have arguments for a function, and ARG points to the same location where the return address is stored. In case the VM writes the return value to ARG[0], and you have zero arguments - it will also overwrite the return address, and your whole stack will go haywire (I got cool designs on my screen because of this).
82+
83+
2. I got into a weird state where FibonacciElement test was passing, but the SimpleFunction was failing for me. Ended up wasting a lot of time reverting back and forth to figure out the differences. If you're stuck here, check the [project page](https://www.nand2tetris.org/project08) for details on the intermediate `NestedCall.vm` testcase, which comes with a [detailed survival guide](https://www.nand2tetris.org/copy-of-hdl-survival-guide) and RAM states at various points in the call history: https://www.nand2tetris.org/copy-of-nestedcall.

vm/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ Register | Name | Usage
2727
`RAM[4]` | `THAT` | `that`
2828
RAM[5-12] | `temp` Segment
2929
RAM[13-15]| General Purpose Registers
30-
31-
32-
The implementation is written in Modern PHP with static typing. Uses the following 3 classes
33-
34-
- `CommandType` as a Enum for using command types as constants
35-
- `Parser`, mostly as defined in the specification
36-
- `CodeWriter`, mostly as defined in the specification
37-
- `VMTranslator` which combines the above

0 commit comments

Comments
 (0)