aboutsummaryrefslogtreecommitdiff
path: root/projects/12/ArrayTest
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/12/ArrayTest
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/12/ArrayTest')
-rw-r--r--projects/12/ArrayTest/Array.jack26
-rw-r--r--projects/12/ArrayTest/Array.vm12
-rw-r--r--projects/12/ArrayTest/ArrayTest.cmp2
-rw-r--r--projects/12/ArrayTest/ArrayTest.out2
-rw-r--r--projects/12/ArrayTest/ArrayTest.tst15
-rw-r--r--projects/12/ArrayTest/Main.jack40
-rw-r--r--projects/12/ArrayTest/Main.vm131
7 files changed, 0 insertions, 228 deletions
diff --git a/projects/12/ArrayTest/Array.jack b/projects/12/ArrayTest/Array.jack
deleted file mode 100644
index 343c25c..0000000
--- a/projects/12/ArrayTest/Array.jack
+++ /dev/null
@@ -1,26 +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/12/Array.jack
-
-/**
- * Represents an array.
- * In the Jack language, arrays are instances of the Array class.
- * Once declared, the array entries can be accessed using the usual
- * syntax arr[i]. Each array entry can hold a primitive data type as
- * well as any object type. Different array entries can have different
- * data types.
- */
-class Array {
-
- /** Constructs a new Array of the given size. */
- function Array new(int size) {
- return Memory.alloc(size);
- }
-
- /** Disposes this array. */
- method void dispose() {
- do Memory.deAlloc(this);
- return;
- }
-}
diff --git a/projects/12/ArrayTest/Array.vm b/projects/12/ArrayTest/Array.vm
deleted file mode 100644
index c0cd797..0000000
--- a/projects/12/ArrayTest/Array.vm
+++ /dev/null
@@ -1,12 +0,0 @@
-function Array.new 0
-push argument 0
-call Memory.alloc 1
-return
-function Array.dispose 0
-push argument 0
-pop pointer 0
-push pointer 0
-call Memory.deAlloc 1
-pop temp 0
-push constant 0
-return
diff --git a/projects/12/ArrayTest/ArrayTest.cmp b/projects/12/ArrayTest/ArrayTest.cmp
deleted file mode 100644
index d1a9798..0000000
--- a/projects/12/ArrayTest/ArrayTest.cmp
+++ /dev/null
@@ -1,2 +0,0 @@
-|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|
-| 222 | 122 | 100 | 10 |
diff --git a/projects/12/ArrayTest/ArrayTest.out b/projects/12/ArrayTest/ArrayTest.out
deleted file mode 100644
index e9f4e75..0000000
--- a/projects/12/ArrayTest/ArrayTest.out
+++ /dev/null
@@ -1,2 +0,0 @@
-|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|
-| 222 | 122 | 100 | 10 |
diff --git a/projects/12/ArrayTest/ArrayTest.tst b/projects/12/ArrayTest/ArrayTest.tst
deleted file mode 100644
index 89934b9..0000000
--- a/projects/12/ArrayTest/ArrayTest.tst
+++ /dev/null
@@ -1,15 +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/12/ArrayTest/ArrayTest.tst
-
-load,
-output-file ArrayTest.out,
-compare-to ArrayTest.cmp,
-output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1;
-
-repeat 1000000 {
- vmstep;
-}
-
-output;
diff --git a/projects/12/ArrayTest/Main.jack b/projects/12/ArrayTest/Main.jack
deleted file mode 100644
index 439770a..0000000
--- a/projects/12/ArrayTest/Main.jack
+++ /dev/null
@@ -1,40 +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/12/ArrayTest/Main.jack
-
-/** Test program for the OS Array class. */
-class Main {
-
- /** Performs several Array manipulations. */
- function void main() {
- var Array r; // stores test results
- var Array a, b, c;
-
- let r = 8000;
-
- let a = Array.new(3);
- let a[2] = 222;
- let r[0] = a[2]; // RAM[8000] = 222
-
- let b = Array.new(3);
- let b[1] = a[2] - 100;
- let r[1] = b[1]; // RAM[8001] = 122
-
- let c = Array.new(500);
- let c[499] = a[2] - b[1];
- let r[2] = c[499]; // RAM[8002] = 100
-
- do a.dispose();
- do b.dispose();
-
- let b = Array.new(3);
- let b[0] = c[499] - 90;
- let r[3] = b[0]; // RAM[8003] = 10
-
- do c.dispose();
- do b.dispose();
-
- return;
- }
-}
diff --git a/projects/12/ArrayTest/Main.vm b/projects/12/ArrayTest/Main.vm
deleted file mode 100644
index 141f20a..0000000
--- a/projects/12/ArrayTest/Main.vm
+++ /dev/null
@@ -1,131 +0,0 @@
-function Main.main 4
-push constant 8000
-pop local 0
-push constant 3
-call Array.new 1
-pop local 1
-push constant 2
-push local 1
-add
-push constant 222
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 0
-push local 0
-add
-push constant 2
-push local 1
-add
-pop pointer 1
-push that 0
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 3
-call Array.new 1
-pop local 2
-push constant 1
-push local 2
-add
-push constant 2
-push local 1
-add
-pop pointer 1
-push that 0
-push constant 100
-sub
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 1
-push local 0
-add
-push constant 1
-push local 2
-add
-pop pointer 1
-push that 0
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 500
-call Array.new 1
-pop local 3
-push constant 499
-push local 3
-add
-push constant 2
-push local 1
-add
-pop pointer 1
-push that 0
-push constant 1
-push local 2
-add
-pop pointer 1
-push that 0
-sub
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 2
-push local 0
-add
-push constant 499
-push local 3
-add
-pop pointer 1
-push that 0
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push local 1
-call Array.dispose 1
-pop temp 0
-push local 2
-call Array.dispose 1
-pop temp 0
-push constant 3
-call Array.new 1
-pop local 2
-push constant 0
-push local 2
-add
-push constant 499
-push local 3
-add
-pop pointer 1
-push that 0
-push constant 90
-sub
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push constant 3
-push local 0
-add
-push constant 0
-push local 2
-add
-pop pointer 1
-push that 0
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push local 3
-call Array.dispose 1
-pop temp 0
-push local 2
-call Array.dispose 1
-pop temp 0
-push constant 0
-return