aboutsummaryrefslogtreecommitdiff
path: root/projects/11/Average
diff options
context:
space:
mode:
Diffstat (limited to 'projects/11/Average')
-rw-r--r--projects/11/Average/Main.jack29
-rw-r--r--projects/11/Average/Main.vm147
2 files changed, 0 insertions, 176 deletions
diff --git a/projects/11/Average/Main.jack b/projects/11/Average/Main.jack
deleted file mode 100644
index d560bf1..0000000
--- a/projects/11/Average/Main.jack
+++ /dev/null
@@ -1,29 +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/11/Average/Main.jack
-
-// (Same as projects/09/Average/Main.jack)
-
-// Inputs some numbers and computes their average
-class Main {
- function void main() {
- var Array a;
- var int length;
- var int i, sum;
-
- let length = Keyboard.readInt("How many numbers? ");
- let a = Array.new(length); // constructs the array
-
- let i = 0;
- while (i < length) {
- let a[i] = Keyboard.readInt("Enter a number: ");
- let sum = sum + a[i];
- let i = i + 1;
- }
-
- do Output.printString("The average is ");
- do Output.printInt(sum / length);
- return;
- }
-}
diff --git a/projects/11/Average/Main.vm b/projects/11/Average/Main.vm
deleted file mode 100644
index 91772b9..0000000
--- a/projects/11/Average/Main.vm
+++ /dev/null
@@ -1,147 +0,0 @@
-function Main.main 4
-push constant 18
-call String.new 1
-push constant 72
-call String.appendChar 2
-push constant 111
-call String.appendChar 2
-push constant 119
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 109
-call String.appendChar 2
-push constant 97
-call String.appendChar 2
-push constant 110
-call String.appendChar 2
-push constant 121
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 110
-call String.appendChar 2
-push constant 117
-call String.appendChar 2
-push constant 109
-call String.appendChar 2
-push constant 98
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 114
-call String.appendChar 2
-push constant 115
-call String.appendChar 2
-push constant 63
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-call Keyboard.readInt 1
-pop local 1
-push local 1
-call Array.new 1
-pop local 0
-push constant 0
-pop local 2
-label main.While0
-push local 2
-push local 1
-lt
-not
-if-goto main.EndWhile0
-push constant 16
-call String.new 1
-push constant 69
-call String.appendChar 2
-push constant 110
-call String.appendChar 2
-push constant 116
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 114
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 97
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 110
-call String.appendChar 2
-push constant 117
-call String.appendChar 2
-push constant 109
-call String.appendChar 2
-push constant 98
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 114
-call String.appendChar 2
-push constant 58
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-call Keyboard.readInt 1
-push local 0
-push local 2
-add
-pop pointer 1
-pop that 0
-push local 3
-push local 0
-push local 2
-add
-pop pointer 1
-push that 0
-add
-pop local 3
-push local 2
-push constant 1
-add
-pop local 2
-goto main.While0
-label main.EndWhile0
-push constant 15
-call String.new 1
-push constant 84
-call String.appendChar 2
-push constant 104
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 97
-call String.appendChar 2
-push constant 118
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 114
-call String.appendChar 2
-push constant 97
-call String.appendChar 2
-push constant 103
-call String.appendChar 2
-push constant 101
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-push constant 105
-call String.appendChar 2
-push constant 115
-call String.appendChar 2
-push constant 32
-call String.appendChar 2
-call Output.printString 1
-pop temp 0
-push local 3
-push local 1
-call Math.divide 2
-call Output.printInt 1
-pop temp 0
-push constant 0
-return