aboutsummaryrefslogtreecommitdiff
path: root/projects/07/StackArithmetic
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-20 15:41:49 +0100
committerYuchen Pei <me@ypei.me>2018-01-20 15:41:49 +0100
commitd3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 (patch)
treed58df9ec2480e2a9ec6240f9c797f83d1a0b1056 /projects/07/StackArithmetic
parent3571f998b28fbc8d9250ba04c983935f10a16c15 (diff)
rearranged the dir for github
- removed tools and pdfs - rearranged the projects dirs - added md files - other minor changes
Diffstat (limited to 'projects/07/StackArithmetic')
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm32
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp2
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out2
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst17
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm9
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst17
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.asm426
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.cmp4
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.out4
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.tst22
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.vm45
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTestVME.tst22
12 files changed, 0 insertions, 602 deletions
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm
deleted file mode 100644
index faa8af7..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm
+++ /dev/null
@@ -1,32 +0,0 @@
-@256
-D=A
-@SP
-M=D
-@7
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@8
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M+D
-@SP
-A=M
-M=D
-@SP
-M=M+1
-(END)
-@END
-0;JMP \ No newline at end of file
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp
deleted file mode 100644
index 7a3585b..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp
+++ /dev/null
@@ -1,2 +0,0 @@
-| RAM[0] | RAM[256] |
-| 257 | 15 |
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out
deleted file mode 100644
index 6b3b20e..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out
+++ /dev/null
@@ -1,2 +0,0 @@
-| RAM[0] | RAM[256] |
-| 257 | 15 |
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst
deleted file mode 100644
index 02dece3..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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.tst
-
-load SimpleAdd.asm,
-output-file SimpleAdd.out,
-compare-to SimpleAdd.cmp,
-output-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;
-
-set RAM[0] 256, // initializes the stack pointer
-
-repeat 60 { // enough cycles to complete the execution
- ticktock;
-}
-
-output; // the stack pointer and the stack base
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm
deleted file mode 100644
index cfd4ee9..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm
+++ /dev/null
@@ -1,9 +0,0 @@
-// 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
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst b/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst
deleted file mode 100644
index 5010f4f..0000000
--- a/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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/SimpleAddVME.tst
-
-load SimpleAdd.vm,
-output-file SimpleAdd.out,
-compare-to SimpleAdd.cmp,
-output-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;
-
-set RAM[0] 256, // initializes the stack pointer
-
-repeat 3 { // SimpleAdd.vm has 3 instructions
- vmstep;
-}
-
-output; // the stack pointer and the stack base
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.asm b/projects/07/StackArithmetic/StackTest/StackTest.asm
deleted file mode 100644
index 560ec6c..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTest.asm
+++ /dev/null
@@ -1,426 +0,0 @@
-@256
-D=A
-@SP
-M=D
-@17
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@17
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M-D
-@EQ2
-D;JEQ
-@SP
-A=M
-M=0
-@SP
-M=M+1
-@ENDIFEQ2
-0;JMP
-(EQ2)
-@SP
-A=M
-M=-1
-@SP
-M=M+1
-(ENDIFEQ2)
-@17
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@16
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M-D
-@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P
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M|D
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-AM=M-1
-D=M
-@SP
-A=M
-M=!D
-@SP
-M=M+1
-(END)
-@END
-0;JMP \ No newline at end of file
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.cmp b/projects/07/StackArithmetic/StackTest/StackTest.cmp
deleted file mode 100644
index f90fa1b..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTest.cmp
+++ /dev/null
@@ -1,4 +0,0 @@
-| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] |
-| 266 | -1 | 0 | 0 | 0 | -1 |
-| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] |
-| 0 | -1 | 0 | 0 | -91 |
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.out b/projects/07/StackArithmetic/StackTest/StackTest.out
deleted file mode 100644
index cb182ec..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTest.out
+++ /dev/null
@@ -1,4 +0,0 @@
-| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] |
-| 266 | -1 | 0 | 0 | 0 | -1 |
-| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] |
-| 0 | -1 | 0 | 0 | -91 |
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.tst b/projects/07/StackArithmetic/StackTest/StackTest.tst
deleted file mode 100644
index f9c5396..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTest.tst
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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.tst
-
-load StackTest.asm,
-output-file StackTest.out,
-compare-to StackTest.cmp,
-output-list RAM[0]%D2.6.2
- RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;
-
-set RAM[0] 256, // initializes the stack pointer
-
-repeat 1000 { // enough cycles to complete the execution
- ticktock;
-}
-
-// outputs the stack pointer (RAM[0]) and
-// the stack contents: RAM[256]-RAM[265]
-output;
-output-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;
-output;
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.vm b/projects/07/StackArithmetic/StackTest/StackTest.vm
deleted file mode 100644
index bfe78e0..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTest.vm
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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
diff --git a/projects/07/StackArithmetic/StackTest/StackTestVME.tst b/projects/07/StackArithmetic/StackTest/StackTestVME.tst
deleted file mode 100644
index b66bd05..0000000
--- a/projects/07/StackArithmetic/StackTest/StackTestVME.tst
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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/StackTestVME.tst
-
-load StackTest.vm,
-output-file StackTest.out,
-compare-to StackTest.cmp,
-output-list RAM[0]%D2.6.2
- RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;
-
-set RAM[0] 256, // initializes the stack pointer
-
-repeat 38 { // StackTest.vm consists of 38 instructions
- vmstep;
-}
-
-// outputs the stack pointer (RAM[0]) and
-// the stack contents: RAM[256]-RAM[265]
-output;
-output-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;
-output;