diff --git a/nand2tetris/projects/7/VMTranslator/docs/popPointer.md b/nand2tetris/projects/7/VMTranslator/docs/popPointer.md new file mode 100644 index 0000000..0e03cdb --- /dev/null +++ b/nand2tetris/projects/7/VMTranslator/docs/popPointer.md @@ -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 +``` \ No newline at end of file diff --git a/nand2tetris/projects/7/VMTranslator/docs/popSegment.md b/nand2tetris/projects/7/VMTranslator/docs/popSegment.md new file mode 100644 index 0000000..bbf9c68 --- /dev/null +++ b/nand2tetris/projects/7/VMTranslator/docs/popSegment.md @@ -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 +``` \ No newline at end of file