mirror of
https://github.com/avinal/The-VM-to-HACK-Translator.git
synced 2026-01-10 07:08:32 +05:30
Test Files
This commit is contained in:
31
BasicTest.vm
Normal file
31
BasicTest.vm
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// 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/BasicTest/BasicTest.vm
|
||||||
|
|
||||||
|
// Executes pop and push commands using the virtual memory segments.
|
||||||
|
push constant 10
|
||||||
|
pop local 0
|
||||||
|
push constant 21
|
||||||
|
push constant 22
|
||||||
|
pop argument 2
|
||||||
|
pop argument 1
|
||||||
|
push constant 36
|
||||||
|
pop this 6
|
||||||
|
push constant 42
|
||||||
|
push constant 45
|
||||||
|
pop that 5
|
||||||
|
pop that 2
|
||||||
|
push constant 510
|
||||||
|
pop temp 6
|
||||||
|
push local 0
|
||||||
|
push that 5
|
||||||
|
add
|
||||||
|
push argument 1
|
||||||
|
sub
|
||||||
|
push this 6
|
||||||
|
push this 6
|
||||||
|
add
|
||||||
|
sub
|
||||||
|
push temp 6
|
||||||
|
add
|
||||||
22
PointerTest.vm
Normal file
22
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
|
||||||
9
SimpleAdd.vm
Normal file
9
SimpleAdd.vm
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// 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/StackArithmetic/SimpleAdd/SimpleAdd.vm
|
||||||
|
|
||||||
|
// Pushes and adds two constants.
|
||||||
|
push constant 7
|
||||||
|
push constant 8
|
||||||
|
add
|
||||||
45
StackTest.vm
Normal file
45
StackTest.vm
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
// 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/StackArithmetic/StackTest/StackTest.vm
|
||||||
|
|
||||||
|
// Executes a sequence of arithmetic and logical operations
|
||||||
|
// on the stack.
|
||||||
|
push constant 17
|
||||||
|
push constant 17
|
||||||
|
eq
|
||||||
|
push constant 17
|
||||||
|
push constant 16
|
||||||
|
eq
|
||||||
|
push constant 16
|
||||||
|
push constant 17
|
||||||
|
eq
|
||||||
|
push constant 892
|
||||||
|
push constant 891
|
||||||
|
lt
|
||||||
|
push constant 891
|
||||||
|
push constant 892
|
||||||
|
lt
|
||||||
|
push constant 891
|
||||||
|
push constant 891
|
||||||
|
lt
|
||||||
|
push constant 32767
|
||||||
|
push constant 32766
|
||||||
|
gt
|
||||||
|
push constant 32766
|
||||||
|
push constant 32767
|
||||||
|
gt
|
||||||
|
push constant 32766
|
||||||
|
push constant 32766
|
||||||
|
gt
|
||||||
|
push constant 57
|
||||||
|
push constant 31
|
||||||
|
push constant 53
|
||||||
|
add
|
||||||
|
push constant 112
|
||||||
|
sub
|
||||||
|
neg
|
||||||
|
and
|
||||||
|
push constant 82
|
||||||
|
or
|
||||||
|
not
|
||||||
17
StaticTest.vm
Normal file
17
StaticTest.vm
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// 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/StaticTest/StaticTest.vm
|
||||||
|
|
||||||
|
// Executes pop and push commands using the static segment.
|
||||||
|
push constant 111
|
||||||
|
push constant 333
|
||||||
|
push constant 888
|
||||||
|
pop static 8
|
||||||
|
pop static 3
|
||||||
|
pop static 1
|
||||||
|
push static 3
|
||||||
|
push static 1
|
||||||
|
sub
|
||||||
|
push static 8
|
||||||
|
add
|
||||||
Reference in New Issue
Block a user