Init nand2tetris
This commit is contained in:
2
projects/07/MemoryAccess/PointerTest/PointerTest.cmp
Normal file
2
projects/07/MemoryAccess/PointerTest/PointerTest.cmp
Normal file
@@ -0,0 +1,2 @@
|
||||
|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
|
||||
| 6084 | 3030 | 3040 | 32 | 46 |
|
||||
20
projects/07/MemoryAccess/PointerTest/PointerTest.tst
Normal file
20
projects/07/MemoryAccess/PointerTest/PointerTest.tst
Normal file
@@ -0,0 +1,20 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/07/MemoryAccess/PointerTest/PointerTest.tst
|
||||
|
||||
load PointerTest.asm,
|
||||
output-file PointerTest.out,
|
||||
compare-to PointerTest.cmp,
|
||||
output-list RAM[256]%D1.6.1 RAM[3]%D1.6.1
|
||||
RAM[4]%D1.6.1 RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;
|
||||
|
||||
set RAM[0] 256, // initializes the stack pointer
|
||||
|
||||
repeat 450 { // enough cycles to complete the execution
|
||||
ticktock;
|
||||
}
|
||||
|
||||
// outputs the stack base, this, that, and
|
||||
// some values from the the this and that segments
|
||||
output;
|
||||
22
projects/07/MemoryAccess/PointerTest/PointerTest.vm
Normal file
22
projects/07/MemoryAccess/PointerTest/PointerTest.vm
Normal file
@@ -0,0 +1,22 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/07/MemoryAccess/PointerTest/PointerTest.vm
|
||||
|
||||
// Executes pop and push commands using the
|
||||
// pointer, this, and that segments.
|
||||
push constant 3030
|
||||
pop pointer 0
|
||||
push constant 3040
|
||||
pop pointer 1
|
||||
push constant 32
|
||||
pop this 2
|
||||
push constant 46
|
||||
pop that 6
|
||||
push pointer 0
|
||||
push pointer 1
|
||||
add
|
||||
push this 2
|
||||
sub
|
||||
push that 6
|
||||
add
|
||||
20
projects/07/MemoryAccess/PointerTest/PointerTestVME.tst
Normal file
20
projects/07/MemoryAccess/PointerTest/PointerTestVME.tst
Normal file
@@ -0,0 +1,20 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/07/MemoryAccess/PointerTest/PointerTestVME.tst
|
||||
|
||||
load PointerTest.vm,
|
||||
output-file PointerTest.out,
|
||||
compare-to PointerTest.cmp,
|
||||
output-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1
|
||||
RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;
|
||||
|
||||
set RAM[0] 256, // initializes the stack pointer
|
||||
|
||||
repeat 15 { // PointerTest.vm has 15 instructions
|
||||
vmstep;
|
||||
}
|
||||
|
||||
// outputs the stack base, this, that, and
|
||||
// some values from the the this and that segments
|
||||
output;
|
||||
Reference in New Issue
Block a user