aboutsummaryrefslogtreecommitdiff
path: root/projects/08/FunctionCalls/FibonacciElement
diff options
context:
space:
mode:
Diffstat (limited to 'projects/08/FunctionCalls/FibonacciElement')
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm421
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp2
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out2
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst18
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst17
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/Main.vm30
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/Sys.vm15
7 files changed, 0 insertions, 505 deletions
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm
deleted file mode 100644
index a2ca368..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm
+++ /dev/null
@@ -1,421 +0,0 @@
-@256
-D=A
-@SP
-M=D
-@RET0
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@LCL
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@ARG
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THIS
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THAT
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-D=M
-@LCL
-M=D
-@5
-D=D-A
-@0
-D=D-A
-@ARG
-M=D
-@Sys.init
-0;JMP
-(RET0)
-(Main.fibonacci)
-@ARG
-D=M
-@0
-D=A+D
-A=D
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@2
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M-D
-@IFMain3
-D;JLT
-@SP
-A=M
-M=0
-@SP
-M=M+1
-@ENDIF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M-D
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@RET17
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@LCL
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@ARG
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THIS
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THAT
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-D=M
-@LCL
-M=D
-@5
-D=D-A
-@1
-D=D-A
-@ARG
-M=D
-@Main.fibonacci
-0;JMP
-(RET17)
-@SP
-AM=M-1
-D=M
-@SP
-AM=M-1
-D=M+D
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@LCL
-D=M
-@R13
-M=D
-@5
-A=D-A
-D=M
-@R14
-M=D
-@SP
-AM=M-1
-D=M
-@ARG
-A=M
-M=D
-@ARG
-D=M+1
-@SP
-M=D
-@R13
-AM=M-1
-D=M
-@THAT
-M=D
-@R13
-AM=M-1
-D=M
-@THIS
-M=D
-@R13
-AM=M-1
-D=M
-@ARG
-M=D
-@R13
-AM=M-1
-D=M
-@LCL
-M=D
-@R14
-A=M
-0;JMP
-(Sys.init)
-@4
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@RET2
-D=A
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@LCL
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@ARG
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THIS
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@THAT
-D=M
-@SP
-A=M
-M=D
-@SP
-M=M+1
-@SP
-D=M
-@LCL
-M=D
-@5
-D=D-A
-@1
-D=D-A
-@ARG
-M=D
-@Main.fibonacci
-0;JMP
-(RET2)
-(Sys.init$WHILE)
-@Sys.init$WHILE
-0;JMP
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp
deleted file mode 100644
index d667834..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp
+++ /dev/null
@@ -1,2 +0,0 @@
-| RAM[0] |RAM[261]|
-| 262 | 3 |
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out
deleted file mode 100644
index fdf5e2d..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out
+++ /dev/null
@@ -1,2 +0,0 @@
-| RAM[0] |RAM[261]|
-| 262 | 3 |
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst
deleted file mode 100644
index 1f907b1..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst
+++ /dev/null
@@ -1,18 +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/08/FunctionCalls/FibonacciElement/FibonacciElement.tst
-
-// FibonacciElement.asm results from translating both Main.vm and Sys.vm into
-// a single assembly program, stored in the file FibonacciElement.asm.
-
-load FibonacciElement.asm,
-output-file FibonacciElement.out,
-compare-to FibonacciElement.cmp,
-output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;
-
-repeat 6000 {
- ticktock;
-}
-
-output;
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst b/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst
deleted file mode 100644
index 87c0920..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.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/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst
-
-load, // Load all the VM files from the current directory
-output-file FibonacciElement.out,
-compare-to FibonacciElement.cmp,
-output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;
-
-set sp 261,
-
-repeat 110 {
- vmstep;
-}
-
-output;
diff --git a/projects/08/FunctionCalls/FibonacciElement/Main.vm b/projects/08/FunctionCalls/FibonacciElement/Main.vm
deleted file mode 100644
index 55e5ad2..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/Main.vm
+++ /dev/null
@@ -1,30 +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/08/FunctionCalls/FibonacciElement/Main.vm
-
-// Computes the n'th element of the Fibonacci series, recursively.
-// n is given in argument[0]. Called by the Sys.init function
-// (part of the Sys.vm file), which also pushes the argument[0]
-// parameter before this code starts running.
-
-function Main.fibonacci 0
-push argument 0
-push constant 2
-lt // checks if n<2
-if-goto IF_TRUE
-goto IF_FALSE
-label IF_TRUE // if n<2, return n
-push argument 0
-return
-label IF_FALSE // if n>=2, returns fib(n-2)+fib(n-1)
-push argument 0
-push constant 2
-sub
-call Main.fibonacci 1 // computes fib(n-2)
-push argument 0
-push constant 1
-sub
-call Main.fibonacci 1 // computes fib(n-1)
-add // returns fib(n-1) + fib(n-2)
-return
diff --git a/projects/08/FunctionCalls/FibonacciElement/Sys.vm b/projects/08/FunctionCalls/FibonacciElement/Sys.vm
deleted file mode 100644
index f3965c9..0000000
--- a/projects/08/FunctionCalls/FibonacciElement/Sys.vm
+++ /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/08/FunctionCalls/FibonacciElement/Sys.vm
-
-// Pushes a constant, say n, onto the stack, and calls the Main.fibonacii
-// function, which computes the n'th element of the Fibonacci series.
-// Note that by convention, the Sys.init function is called "automatically"
-// by the bootstrap code.
-
-function Sys.init 0
-push constant 4
-call Main.fibonacci 1 // computes the 4'th fibonacci element
-label WHILE
-goto WHILE // loops infinitely