From d3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 20 Jan 2018 15:41:49 +0100 Subject: rearranged the dir for github - removed tools and pdfs - rearranged the projects dirs - added md files - other minor changes --- projects/07/MemoryAccess/BasicTest/BasicTest.asm | 250 ------------ projects/07/MemoryAccess/BasicTest/BasicTest.cmp | 2 - projects/07/MemoryAccess/BasicTest/BasicTest.out | 2 - projects/07/MemoryAccess/BasicTest/BasicTest.tst | 25 -- projects/07/MemoryAccess/BasicTest/BasicTest.vm | 31 -- .../07/MemoryAccess/BasicTest/BasicTestVME.tst | 25 -- projects/07/MemoryAccess/BasicTest/delme.asm | 26 -- projects/07/MemoryAccess/BasicTest/delme.vm | 8 - .../07/MemoryAccess/PointerTest/PointerTest.asm | 138 ------- .../07/MemoryAccess/PointerTest/PointerTest.cmp | 2 - .../07/MemoryAccess/PointerTest/PointerTest.out | 2 - .../07/MemoryAccess/PointerTest/PointerTest.tst | 20 - .../07/MemoryAccess/PointerTest/PointerTest.vm | 22 -- .../07/MemoryAccess/PointerTest/PointerTestVME.tst | 20 - projects/07/MemoryAccess/StaticTest/StaticTest.asm | 86 ----- projects/07/MemoryAccess/StaticTest/StaticTest.cmp | 2 - projects/07/MemoryAccess/StaticTest/StaticTest.out | 2 - projects/07/MemoryAccess/StaticTest/StaticTest.tst | 17 - projects/07/MemoryAccess/StaticTest/StaticTest.vm | 17 - .../07/MemoryAccess/StaticTest/StaticTestVME.tst | 17 - .../07/StackArithmetic/SimpleAdd/SimpleAdd.asm | 32 -- .../07/StackArithmetic/SimpleAdd/SimpleAdd.cmp | 2 - .../07/StackArithmetic/SimpleAdd/SimpleAdd.out | 2 - .../07/StackArithmetic/SimpleAdd/SimpleAdd.tst | 17 - projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm | 9 - .../07/StackArithmetic/SimpleAdd/SimpleAddVME.tst | 17 - .../07/StackArithmetic/StackTest/StackTest.asm | 426 --------------------- .../07/StackArithmetic/StackTest/StackTest.cmp | 4 - .../07/StackArithmetic/StackTest/StackTest.out | 4 - .../07/StackArithmetic/StackTest/StackTest.tst | 22 -- projects/07/StackArithmetic/StackTest/StackTest.vm | 45 --- .../07/StackArithmetic/StackTest/StackTestVME.tst | 22 -- projects/07/VMTranslator | Bin 65152 -> 0 bytes projects/07/VMTranslator.hi | Bin 1693 -> 0 bytes projects/07/VMTranslator.hs | 88 ----- projects/07/VMTranslator.o | Bin 77480 -> 0 bytes 36 files changed, 1404 deletions(-) delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTest.asm delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTest.cmp delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTest.out delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTest.tst delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTest.vm delete mode 100644 projects/07/MemoryAccess/BasicTest/BasicTestVME.tst delete mode 100644 projects/07/MemoryAccess/BasicTest/delme.asm delete mode 100644 projects/07/MemoryAccess/BasicTest/delme.vm delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTest.asm delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTest.cmp delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTest.out delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTest.tst delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTest.vm delete mode 100644 projects/07/MemoryAccess/PointerTest/PointerTestVME.tst delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTest.asm delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTest.cmp delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTest.out delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTest.tst delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTest.vm delete mode 100644 projects/07/MemoryAccess/StaticTest/StaticTestVME.tst delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm delete mode 100644 projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst delete mode 100644 projects/07/StackArithmetic/StackTest/StackTest.asm delete mode 100644 projects/07/StackArithmetic/StackTest/StackTest.cmp delete mode 100644 projects/07/StackArithmetic/StackTest/StackTest.out delete mode 100644 projects/07/StackArithmetic/StackTest/StackTest.tst delete mode 100644 projects/07/StackArithmetic/StackTest/StackTest.vm delete mode 100644 projects/07/StackArithmetic/StackTest/StackTestVME.tst delete mode 100755 projects/07/VMTranslator delete mode 100644 projects/07/VMTranslator.hi delete mode 100644 projects/07/VMTranslator.hs delete mode 100644 projects/07/VMTranslator.o (limited to 'projects/07') diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.asm b/projects/07/MemoryAccess/BasicTest/BasicTest.asm deleted file mode 100644 index d978f07..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTest.asm +++ /dev/null @@ -1,250 +0,0 @@ -@256 -D=A -@SP -M=D -@10 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@LCL -D=M -@0 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@21 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@22 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@ARG -D=M -@2 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@ARG -D=M -@1 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@36 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@THIS -D=M -@6 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@42 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@45 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@THAT -D=M -@5 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@THAT -D=M -@2 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@510 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@11 -M=D -@LCL -D=M -@0 -D=A+D -A=D -D=M -@SP -A=M -M=D -@SP -M=M+1 -@THAT -D=M -@5 -D=A+D -A=D -D=M -@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 -@ARG -D=M -@1 -D=A+D -A=D -D=M -@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 -@THIS -D=M -@6 -D=A+D -A=D -D=M -@SP -A=M -M=D -@SP -M=M+1 -@THIS -D=M -@6 -D=A+D -A=D -D=M -@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 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@SP -A=M -M=D -@SP -M=M+1 -@11 -D=M -@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/MemoryAccess/BasicTest/BasicTest.cmp b/projects/07/MemoryAccess/BasicTest/BasicTest.cmp deleted file mode 100644 index 538454b..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTest.cmp +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] | -| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 | diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.out b/projects/07/MemoryAccess/BasicTest/BasicTest.out deleted file mode 100644 index 85c19a7..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTest.out +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] | -| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 | diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.tst b/projects/07/MemoryAccess/BasicTest/BasicTest.tst deleted file mode 100644 index fa6d9a6..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTest.tst +++ /dev/null @@ -1,25 +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/MemoryAccess/BasicTest/BasicTest.tst - -load BasicTest.asm, -output-file BasicTest.out, -compare-to BasicTest.cmp, -output-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 - RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1 - RAM[3015]%D1.6.1 RAM[11]%D1.6.1; - -set RAM[0] 256, // stack pointer -set RAM[1] 300, // base address of the local segment -set RAM[2] 400, // base address of the argument segment -set RAM[3] 3000, // base address of the this segment -set RAM[4] 3010, // base address of the that segment - -repeat 600 { // enough cycles to complete the execution - ticktock; -} - -// Outputs the stack base and some values -// from the tested memory segments -output; diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.vm b/projects/07/MemoryAccess/BasicTest/BasicTest.vm deleted file mode 100644 index b2f9343..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTest.vm +++ /dev/null @@ -1,31 +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/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 diff --git a/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst b/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst deleted file mode 100644 index 24e9090..0000000 --- a/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst +++ /dev/null @@ -1,25 +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/MemoryAccess/BasicTest/BasicTestVME.tst - -load BasicTest.vm, -output-file BasicTest.out, -compare-to BasicTest.cmp, -output-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 - RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1 - RAM[3015]%D1.6.1 RAM[11]%D1.6.1; - -set sp 256, // stack pointer -set local 300, // base address of the local segment -set argument 400, // base address of the argument segment -set this 3000, // base address of the this segment -set that 3010, // base address of the that segment - -repeat 25 { // BasicTest.vm has 25 instructions - vmstep; -} - -// Outputs the stack base and some values -// from the tested memory segments -output; diff --git a/projects/07/MemoryAccess/BasicTest/delme.asm b/projects/07/MemoryAccess/BasicTest/delme.asm deleted file mode 100644 index 6392181..0000000 --- a/projects/07/MemoryAccess/BasicTest/delme.asm +++ /dev/null @@ -1,26 +0,0 @@ -@256 -D=A -@SP -M=D -@10 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@LCL -D=M -@0 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -(END) -@END -0;JMP \ No newline at end of file diff --git a/projects/07/MemoryAccess/BasicTest/delme.vm b/projects/07/MemoryAccess/BasicTest/delme.vm deleted file mode 100644 index d1ae195..0000000 --- a/projects/07/MemoryAccess/BasicTest/delme.vm +++ /dev/null @@ -1,8 +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/MemoryAccess/BasicTest/BasicTest.vm - -// Executes pop and push commands using the virtual memory segments. -push constant 10 -pop local 0 diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.asm b/projects/07/MemoryAccess/PointerTest/PointerTest.asm deleted file mode 100644 index 67125df..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTest.asm +++ /dev/null @@ -1,138 +0,0 @@ -@256 -D=A -@SP -M=D -@3030 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@3 -M=D -@3040 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@4 -M=D -@32 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@THIS -D=M -@2 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@46 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@THAT -D=M -@6 -D=A+D -@R13 -M=D -@SP -AM=M-1 -D=M -@R13 -A=M -M=D -@3 -D=M -@SP -A=M -M=D -@SP -M=M+1 -@4 -D=M -@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 -@THIS -D=M -@2 -D=A+D -A=D -D=M -@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 -@THAT -D=M -@6 -D=A+D -A=D -D=M -@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/MemoryAccess/PointerTest/PointerTest.cmp b/projects/07/MemoryAccess/PointerTest/PointerTest.cmp deleted file mode 100644 index b59fa97..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTest.cmp +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046| -| 6084 | 3030 | 3040 | 32 | 46 | diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.out b/projects/07/MemoryAccess/PointerTest/PointerTest.out deleted file mode 100644 index 5d62de8..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTest.out +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046| -| 6084 | 3030 | 3040 | 32 | 46 | diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.tst b/projects/07/MemoryAccess/PointerTest/PointerTest.tst deleted file mode 100644 index cd5515d..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTest.tst +++ /dev/null @@ -1,20 +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/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; diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.vm b/projects/07/MemoryAccess/PointerTest/PointerTest.vm deleted file mode 100644 index 5b0a109..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTest.vm +++ /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/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 diff --git a/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst b/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst deleted file mode 100644 index 1b395c2..0000000 --- a/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst +++ /dev/null @@ -1,20 +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/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; diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.asm b/projects/07/MemoryAccess/StaticTest/StaticTest.asm deleted file mode 100644 index 8cd989d..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTest.asm +++ /dev/null @@ -1,86 +0,0 @@ -@256 -D=A -@SP -M=D -@111 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@333 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@888 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@StaticTest.8 -M=D -@SP -AM=M-1 -D=M -@StaticTest.3 -M=D -@SP -AM=M-1 -D=M -@StaticTest.1 -M=D -@StaticTest.3 -D=M -@SP -A=M -M=D -@SP -M=M+1 -@StaticTest.1 -D=M -@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 -@StaticTest.8 -D=M -@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/MemoryAccess/StaticTest/StaticTest.cmp b/projects/07/MemoryAccess/StaticTest/StaticTest.cmp deleted file mode 100644 index 29f4bf0..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTest.cmp +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]| -| 1110 | diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.out b/projects/07/MemoryAccess/StaticTest/StaticTest.out deleted file mode 100644 index 2bc908b..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTest.out +++ /dev/null @@ -1,2 +0,0 @@ -|RAM[256]| -| 1110 | diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.tst b/projects/07/MemoryAccess/StaticTest/StaticTest.tst deleted file mode 100644 index 1f23d66..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTest.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/MemoryAccess/StaticTest/StaticTest.tst - -load StaticTest.asm, -output-file StaticTest.out, -compare-to StaticTest.cmp, -output-list RAM[256]%D1.6.1; - -set RAM[0] 256, // initializes the stack pointer - -repeat 200 { // enough cycles to complete the execution - ticktock; -} - -output; // the stack base diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.vm b/projects/07/MemoryAccess/StaticTest/StaticTest.vm deleted file mode 100644 index 65b4f6f..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTest.vm +++ /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/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 diff --git a/projects/07/MemoryAccess/StaticTest/StaticTestVME.tst b/projects/07/MemoryAccess/StaticTest/StaticTestVME.tst deleted file mode 100644 index 52882a4..0000000 --- a/projects/07/MemoryAccess/StaticTest/StaticTestVME.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/MemoryAccess/StaticTest/StaticTestVME.tst - -load StaticTest.vm, -output-file StaticTest.out, -compare-to StaticTest.cmp, -output-list RAM[256]%D1.6.1; - -set sp 256, // initializes the stack pointer - -repeat 11 { // StaticTest.vm has 11 instructions - vmstep; -} - -output; // the stack base 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 -@EQ5 -D;JEQ -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFEQ5 -0;JMP -(EQ5) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFEQ5) -@16 -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 -@EQ8 -D;JEQ -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFEQ8 -0;JMP -(EQ8) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFEQ8) -@892 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@891 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@LT11 -D;JLT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFLT11 -0;JMP -(LT11) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFLT11) -@891 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@892 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@LT14 -D;JLT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFLT14 -0;JMP -(LT14) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFLT14) -@891 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@891 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@LT17 -D;JLT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFLT17 -0;JMP -(LT17) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFLT17) -@32767 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@32766 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@GT20 -D;JGT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFGT20 -0;JMP -(GT20) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFGT20) -@32766 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@32767 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@GT23 -D;JGT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFGT23 -0;JMP -(GT23) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFGT23) -@32766 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@32766 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@SP -AM=M-1 -D=M -@SP -AM=M-1 -D=M-D -@GT26 -D;JGT -@SP -A=M -M=0 -@SP -M=M+1 -@ENDIFGT26 -0;JMP -(GT26) -@SP -A=M -M=-1 -@SP -M=M+1 -(ENDIFGT26) -@57 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@31 -D=A -@SP -A=M -M=D -@SP -M=M+1 -@53 -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 -@112 -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 -@SP -AM=M-1 -D=M -@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 -@82 -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 -@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; diff --git a/projects/07/VMTranslator b/projects/07/VMTranslator deleted file mode 100755 index 65a46dc..0000000 Binary files a/projects/07/VMTranslator and /dev/null differ diff --git a/projects/07/VMTranslator.hi b/projects/07/VMTranslator.hi deleted file mode 100644 index 078767f..0000000 Binary files a/projects/07/VMTranslator.hi and /dev/null differ diff --git a/projects/07/VMTranslator.hs b/projects/07/VMTranslator.hs deleted file mode 100644 index ce8447d..0000000 --- a/projects/07/VMTranslator.hs +++ /dev/null @@ -1,88 +0,0 @@ -import Data.Char (toUpper) -import Data.List.Split (splitOn) -import System.Environment (getArgs) -import Data.Maybe (fromJust) -import Data.List (elemIndex) - -preamble = "@256\nD=A\n@SP\nM=D\n" - -epilogue = "(END)\n@END\n0;JMP" - -parse' :: [Char] -> [[Char]] -> Int -> [Char] -> [Char] -parse' op [] n _ - | op `elem` ["add", "sub", "and", "or"] = pop "M" ++ pop ('M':(f op):"D") ++ push "D" - | op `elem` ["eq", "gt", "lt"] = pop "M" ++ pop "M-D" ++ ifThenElse op n - | otherwise = pop "M" ++ push (f op:"D") - where f "add" = '+'; f "sub" = '-'; f "and" = '&'; - f "or" = '|'; f "neg" = '-'; f "not" = '!' - -parse' "push" ["constant", x] _ _ = "@" ++ x ++ "\nD=A\n" ++ push "D" - -parse' cmd [seg, x] _ _ | seg `elem` ["local", "argument", "this", "that"] = - case cmd of - "push" -> getAddr seg x ++ "A=D\nD=M\n" ++ push "D" - "pop" -> getAddr seg x ++ "@R13\nM=D\n" ++ pop "M" ++ "@R13\nA=M\nM=D\n" - -parse' cmd [seg, x] _ _ | seg `elem` ["pointer", "temp"] = - case cmd of - "push" -> getAddr' seg x ++ "D=M\n" ++ push "D" - "pop" -> pop "M" ++ getAddr' seg x ++ "M=D\n" - -parse' cmd ["static", x] _ filename = - case cmd of - "push" -> getAddr'' x filename ++ "D=M\n" ++ push "D" - "pop" -> pop "M" ++ getAddr'' x filename ++ "M=D\n" - -getAddr seg x = "@" ++ seg2Lab seg ++ "\nD=M\n@" ++ x ++ "\nD=A+D\n" - -getAddr' seg x = "@" ++ show (read x + (if seg == "pointer" then 3 else 5)) ++ "\n" - -getAddr'' x filename = "@" ++ filename ++ "." ++ x ++ "\n" - -seg2Lab seg = case seg of - "local" -> "LCL" - "argument" -> "ARG" - "this" -> "THIS" - "that" -> "THAT" - -push :: [Char] -> [Char] -push xs = "@SP\nA=M\nM=" ++ xs ++ "\n@SP\nM=M+1\n" - -ifThenElse :: [Char] -> Int -> [Char] -ifThenElse cond n = "@" ++ cond' ++ show n ++ "\nD;J" ++ cond' ++ "\n" ++ push "0" - ++ "@ENDIF" ++ cond' ++ show n ++ "\n0;JMP\n(" ++ cond' ++ show n ++ ")\n" - ++ push "-1" ++ "(ENDIF" ++ cond' ++ show n ++ ")\n" - where cond' = toUpper <$> cond - -pop :: [Char] -> [Char] -pop xs = "@SP\nAM=M-1\nD=" ++ xs ++ "\n" - -parseline :: [[Char]] -> Int -> [Char] -> [Char] -> [Char] -parseline [] _ acc _ = acc -parseline (line:lines) n acc filename = parseline lines (n + 1) (acc ++ parse' cmd target n filename) filename - where cmd:target = words line - -stripJunk :: [Char] -> [[Char]] -stripJunk = filter (not . isEmptyLine) . fmap (head . splitOn "//") . lines . replCrWithNl - -isEmptyLine :: [Char] -> Bool -isEmptyLine = null . filter (not . flip elem " \t") - -parseCode :: [Char] -> [Char] -> [Char] -parseCode xs filename = preamble ++ (parseline (stripJunk xs) 0 "" filename) ++ epilogue - -replCrWithNl :: [Char] -> [Char] -replCrWithNl = fmap cr2nl - where cr2nl '\r' = '\n' - cr2nl c = c - -lastSplit c xs = (take (prefix - 1) xs, drop prefix xs) - where prefix = length xs - (fromJust . elemIndex c . reverse) xs - -main = do - args <- getArgs - let path = head args - let pathWithoutExt = fst $ lastSplit '.' path - let filename = snd $ lastSplit '/' pathWithoutExt - code <- readFile path - writeFile (pathWithoutExt ++ ".asm") (parseCode code filename) diff --git a/projects/07/VMTranslator.o b/projects/07/VMTranslator.o deleted file mode 100644 index f8e3523..0000000 Binary files a/projects/07/VMTranslator.o and /dev/null differ -- cgit v1.2.3