Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions nand2tetris/projects/7/VMTranslator/docs/popPointer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
`push pointer i`
----

For `pointer` we get the _address_ pointed to by THIS/THAT.

We translate
* `pointer 0` to `THIS` and
* `pointer 1` to `THAT`.

Store it in `segmentPointer`.

Output
----

```
addr <- segmentPointer # D_eq_RAM_i.asm
D <- RAM[addr] # ^--
RAM[SP] <- D # RAM_SP_eq_D.asm
SP++ # SPpp.asm
```
17 changes: 17 additions & 0 deletions nand2tetris/projects/7/VMTranslator/docs/popSegment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
`pop segment i`
----

where `segment in ["local", "argument", "this", "that"]`.

We cannot actually directly store `RAM[SP]` in `RAM[D]`, since we have to store `RAM[SP]` in `D`.
So, intermediately, we store `RAM[D]` in `R13`, then retrieve `RAM[SP]` in `D` and finish.

Output
----

```
D <- segmentPointer + i # D_eq_segmentPointer_p_i.asm
SP-- # SPmm.asm
R13 <- D # R13_eq_D.asm
RAM[R13] <- RAM[SP] # RAM_R13_eq_RAM_SP.asm
```