aboutsummaryrefslogtreecommitdiff
path: root/projects/12
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-17 18:35:55 +0100
committerYuchen Pei <me@ypei.me>2018-01-17 18:35:55 +0100
commit01da7177bd2f4d83e8916540a69d8b2690b52bbb (patch)
treebe320d5a30c62cfb93eee1333244e53a75811121 /projects/12
parentc89bcc6a364ded67504e88db1bf71417250e2ea3 (diff)
finished project 12
- revised output - finished string
Diffstat (limited to 'projects/12')
-rw-r--r--projects/12/OutputTest/Output.jack28
-rw-r--r--projects/12/OutputTest/Output.vm85
-rw-r--r--projects/12/String.jack43
-rw-r--r--projects/12/StringTest/Main.vm469
-rw-r--r--projects/12/StringTest/String.jack176
-rw-r--r--projects/12/StringTest/String.vm917
6 files changed, 1614 insertions, 104 deletions
diff --git a/projects/12/OutputTest/Output.jack b/projects/12/OutputTest/Output.jack
index 05d59de..61b24de 100644
--- a/projects/12/OutputTest/Output.jack
+++ b/projects/12/OutputTest/Output.jack
@@ -254,30 +254,10 @@ class Output {
/** Displays the given integer starting at the cursor location,
* and advances the cursor appropriately. */
function void printInt(int i) {
- var int n, k, j;
- var Array s;
- if (i = 0) {
- do Output.printChar(48);
- return;
- }
- let n = i;
- if (i < 0) {
- do Output.printChar(45);
- let n = -n;
- }
- let s = Array.new(5);
- let j = 0;
- while (n > 0) {
- let k = n / 10;
- let s[j] = 48 + n - (k * 10);
- let n = k;
- let j = j + 1;
- }
- while (j > 0) {
- let j = j - 1;
- do Output.printChar(s[j]);
- }
- //do Output.printString(s);
+ var String s;
+ let s = String.new(6);
+ do s.setInt(i);
+ do Output.printString(s);
return;
}
diff --git a/projects/12/OutputTest/Output.vm b/projects/12/OutputTest/Output.vm
index e291708..dd83b63 100644
--- a/projects/12/OutputTest/Output.vm
+++ b/projects/12/OutputTest/Output.vm
@@ -1702,90 +1702,17 @@ goto WHILE_EXP0
label WHILE_END0
push constant 0
return
-function Output.printInt 4
-push argument 0
-push constant 0
-eq
-if-goto IF_TRUE0
-goto IF_FALSE0
-label IF_TRUE0
-push constant 48
-call Output.printChar 1
-pop temp 0
-push constant 0
-return
-label IF_FALSE0
-push argument 0
+function Output.printInt 1
+push constant 6
+call String.new 1
pop local 0
+push local 0
push argument 0
-push constant 0
-lt
-if-goto IF_TRUE1
-goto IF_FALSE1
-label IF_TRUE1
-push constant 45
-call Output.printChar 1
+call String.setInt 2
pop temp 0
push local 0
-neg
-pop local 0
-label IF_FALSE1
-push constant 5
-call Array.new 1
-pop local 3
-push constant 0
-pop local 2
-label WHILE_EXP0
-push local 0
-push constant 0
-gt
-not
-if-goto WHILE_END0
-push local 0
-push constant 10
-call Math.divide 2
-pop local 1
-push local 2
-push local 3
-add
-push constant 48
-push local 0
-add
-push local 1
-push constant 10
-call Math.multiply 2
-sub
-pop temp 0
-pop pointer 1
-push temp 0
-pop that 0
-push local 1
-pop local 0
-push local 2
-push constant 1
-add
-pop local 2
-goto WHILE_EXP0
-label WHILE_END0
-label WHILE_EXP1
-push local 2
-push constant 0
-gt
-not
-if-goto WHILE_END1
-push local 2
-push constant 1
-sub
-pop local 2
-push local 2
-push local 3
-add
-pop pointer 1
-push that 0
-call Output.printChar 1
+call Output.printString 1
pop temp 0
-goto WHILE_EXP1
-label WHILE_END1
push constant 0
return
function Output.println 0
diff --git a/projects/12/String.jack b/projects/12/String.jack
index 2d5c440..398fdfe 100644
--- a/projects/12/String.jack
+++ b/projects/12/String.jack
@@ -47,6 +47,10 @@ class String {
/** Sets the character at the j-th location of this string to c. */
method void setCharAt(int j, char c) {
+ if ((j < 0) | (j + 1 > len)){
+ Output.printString("String.setCharAt: index out of range!");
+ Sys.error(5);
+ }
let s[j] = c;
return;
}
@@ -110,7 +114,44 @@ class String {
}
/** Sets this string to hold a representation of the given value. */
- method void setInt(int val) {
+ method void setInt(int val) { //change Output.printInt after this
+ var int l;
+ var boolean neg;
+ if (val < 0) {
+ let neg = true;
+ len = 2;
+ } else {
+ let neg = false;
+ len = 1;
+ }
+ let x = Math.abs(val);
+ if (x > 9999) {
+ let len = len + 4;
+ } else { if (x > 999) {
+ let len = len + 3;
+ } else { if (x > 99) {
+ let len = len + 2;
+ } else { if (x > 9) {
+ let len = len + 1;
+ }}}}
+ if (len > maxLen) {
+ Output.printString("String.setInt: val is too big for the string!");
+ Sys.error(5);
+ }
+ if (x = 0) {
+ setCharAt(0, 48);
+ return;
+ }
+ if (neg) {
+ setCharAt(0, 45);
+ }
+ let i = len - 1;
+ while (x > 0) {
+ let y = x / 10;
+ setCharAt(i, x - (y * 10) + 48);
+ let x = y;
+ }
+ return;
}
/** Returns the new line character. */
diff --git a/projects/12/StringTest/Main.vm b/projects/12/StringTest/Main.vm
new file mode 100644
index 0000000..2c9fb9f
--- /dev/null
+++ b/projects/12/StringTest/Main.vm
@@ -0,0 +1,469 @@
+function Main.main 2
+push constant 0
+call String.new 1
+pop local 0
+push local 0
+call String.dispose 1
+pop temp 0
+push constant 6
+call String.new 1
+pop local 0
+push local 0
+push constant 97
+call String.appendChar 2
+pop local 0
+push local 0
+push constant 98
+call String.appendChar 2
+pop local 0
+push local 0
+push constant 99
+call String.appendChar 2
+pop local 0
+push local 0
+push constant 100
+call String.appendChar 2
+pop local 0
+push local 0
+push constant 101
+call String.appendChar 2
+pop local 0
+push constant 16
+call String.new 1
+push constant 110
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 119
+call String.appendChar 2
+push constant 44
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+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 Output.printString 1
+pop temp 0
+push local 0
+call Output.printString 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 6
+call String.new 1
+pop local 1
+push local 1
+push constant 12345
+call String.setInt 2
+pop temp 0
+push constant 8
+call String.new 1
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 73
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 1
+call Output.printString 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push local 1
+push constant 32767
+neg
+call String.setInt 2
+pop temp 0
+push constant 8
+call String.new 1
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 73
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 1
+call Output.printString 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 8
+call String.new 1
+push constant 108
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 0
+call String.length 1
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 11
+call String.new 1
+push constant 99
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 65
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 91
+call String.appendChar 2
+push constant 50
+call String.appendChar 2
+push constant 93
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 0
+push constant 2
+call String.charAt 2
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push local 0
+push constant 2
+push constant 45
+call String.setCharAt 3
+pop temp 0
+push constant 18
+call String.new 1
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 65
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 40
+call String.appendChar 2
+push constant 50
+call String.appendChar 2
+push constant 44
+call String.appendChar 2
+push constant 39
+call String.appendChar 2
+push constant 45
+call String.appendChar 2
+push constant 39
+call String.appendChar 2
+push constant 41
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 0
+call Output.printString 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push local 0
+call String.eraseLastChar 1
+pop temp 0
+push constant 15
+call String.new 1
+push constant 101
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 76
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 115
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+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 Output.printString 1
+pop temp 0
+push local 0
+call Output.printString 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 3
+call String.new 1
+push constant 52
+call String.appendChar 2
+push constant 53
+call String.appendChar 2
+push constant 54
+call String.appendChar 2
+pop local 0
+push constant 10
+call String.new 1
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 86
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 0
+call String.intValue 1
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 6
+call String.new 1
+push constant 45
+call String.appendChar 2
+push constant 51
+call String.appendChar 2
+push constant 50
+call String.appendChar 2
+push constant 49
+call String.appendChar 2
+push constant 50
+call String.appendChar 2
+push constant 51
+call String.appendChar 2
+pop local 0
+push constant 10
+call String.new 1
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 86
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push local 0
+call String.intValue 1
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 11
+call String.new 1
+push constant 98
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 99
+call String.appendChar 2
+push constant 107
+call String.appendChar 2
+push constant 83
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 99
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+call String.backSpace 0
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 13
+call String.new 1
+push constant 100
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 98
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 81
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+call String.doubleQuote 0
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push constant 9
+call String.new 1
+push constant 110
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 119
+call String.appendChar 2
+push constant 76
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+call String.newLine 0
+call Output.printInt 1
+pop temp 0
+call Output.println 0
+pop temp 0
+push local 1
+call String.dispose 1
+pop temp 0
+push local 0
+call String.dispose 1
+pop temp 0
+push constant 0
+return
diff --git a/projects/12/StringTest/String.jack b/projects/12/StringTest/String.jack
new file mode 100644
index 0000000..3ef40b2
--- /dev/null
+++ b/projects/12/StringTest/String.jack
@@ -0,0 +1,176 @@
+// 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/String.jack
+
+/**
+ * Represents character strings. In addition for constructing and disposing
+ * strings, the class features methods for getting and setting individual
+ * characters of the string, for erasing the string's last character,
+ * for appending a character to the string's end, and more typical
+ * string-oriented operations.
+ */
+class String {
+ field int maxLen;
+ field int len;
+ field Array s;
+
+ /** constructs a new empty string with a maximum length of maxLength
+ * and initial length of 0. */
+ constructor String new(int maxLength) {
+ if (maxLength > 0) {
+ let s = Array.new(maxLength);
+ }
+ let maxLen = maxLength;
+ let len = 0;
+ return this;
+ }
+
+ /** Disposes this string. */
+ method void dispose() {
+ if (maxLen > 0) {
+ do s.dispose();
+ }
+ do Memory.deAlloc(this);
+ return;
+ }
+
+ /** Returns the current length of this string. */
+ method int length() {
+ return len;
+ }
+
+ /** Returns the character at the j-th location of this string. */
+ method char charAt(int j) {
+ if ((j < 0) | (j + 1 > len)){
+ do Output.printString("String.charAt: index out of range!");
+ do Sys.error(5);
+ }
+ return s[j];
+ }
+
+ /** Sets the character at the j-th location of this string to c. */
+ method void setCharAt(int j, char c) {
+ if ((j < 0) | (j + 1 > len)){
+ do Output.printString("String.setCharAt: index out of range!");
+ do Sys.error(5);
+ }
+ let s[j] = c;
+ return;
+ }
+
+ /** Appends c to this string's end and returns this string. */
+ method String appendChar(char c) {
+ if (len = maxLen) {
+ do Output.printString("String.appendChar: reached max length!");
+ do Sys.error(5);
+ }
+ let s[len] = c;
+ let len = len + 1;
+ return this;
+ }
+
+ /** Erases the last character from this string. */
+ method void eraseLastChar() {
+ if (len = 0){
+ do Output.printString("String.eraseLastChar: string is already empty!");
+ do Sys.error(5);
+ }
+ let len = len - 1;
+ return;
+ }
+
+ /** Returns the integer value of this string,
+ * until a non-digit character is detected. */
+ method int intValue() {
+ var int n, i;
+ var char c;
+ var boolean neg, done;
+ let n = 0;
+ if (s[0] = 45) {
+ let i = 1;
+ let neg = true;
+ } else {
+ let i = 0;
+ let neg = false;
+ }
+ let c = s[i];
+ if ((c < 48) | (c > 57)) {
+ do Sys.error(3);
+ do Output.printString("String.intValue: the input data is not number!");
+ }
+ let done = false;
+ while ((~done) & (i < len)) {
+ let c = s[i];
+ if ((c > 47) & (c < 58)) {
+ let n = n * 10 + (c - 48);
+ } else {
+ let done = true;
+ }
+ let i = i + 1;
+ }
+ if (neg) {
+ return -n;
+ } else {
+ return n;
+ }
+
+ }
+
+ /** Sets this string to hold a representation of the given value. */
+ method void setInt(int val) { //change Output.printInt after this
+ var int x, i, y;
+ var boolean neg;
+ if (val < 0) {
+ let neg = true;
+ let len = 2;
+ } else {
+ let neg = false;
+ let len = 1;
+ }
+ let x = Math.abs(val);
+ if (x > 9999) {
+ let len = len + 4;
+ } else { if (x > 999) {
+ let len = len + 3;
+ } else { if (x > 99) {
+ let len = len + 2;
+ } else { if (x > 9) {
+ let len = len + 1;
+ }}}}
+ if (len > maxLen) {
+ do Output.printString("String.setInt: val is too big for the string!");
+ do Sys.error(5);
+ }
+ if (x = 0) {
+ do setCharAt(0, 48);
+ return;
+ }
+ if (neg) {
+ do setCharAt(0, 45);
+ }
+ let i = len - 1;
+ while (x > 0) {
+ let y = x / 10;
+ do setCharAt(i, x - (y * 10) + 48);
+ let x = y;
+ let i = i - 1;
+ }
+ return;
+ }
+
+ /** Returns the new line character. */
+ function char newLine() {
+ return 128;
+ }
+
+ /** Returns the backspace character. */
+ function char backSpace() {
+ return 129;
+ }
+
+ /** Returns the double quote (") character. */
+ function char doubleQuote() {
+ return 34;
+ }
+}
diff --git a/projects/12/StringTest/String.vm b/projects/12/StringTest/String.vm
new file mode 100644
index 0000000..36664c1
--- /dev/null
+++ b/projects/12/StringTest/String.vm
@@ -0,0 +1,917 @@
+function String.new 0
+push constant 3
+call Memory.alloc 1
+pop pointer 0
+push argument 0
+push constant 0
+gt
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push argument 0
+call Array.new 1
+pop this 2
+label IF_FALSE0
+push argument 0
+pop this 0
+push constant 0
+pop this 1
+push pointer 0
+return
+function String.dispose 0
+push argument 0
+pop pointer 0
+push this 0
+push constant 0
+gt
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push this 2
+call Array.dispose 1
+pop temp 0
+label IF_FALSE0
+push pointer 0
+call Memory.deAlloc 1
+pop temp 0
+push constant 0
+return
+function String.length 0
+push argument 0
+pop pointer 0
+push this 1
+return
+function String.charAt 0
+push argument 0
+pop pointer 0
+push argument 1
+push constant 0
+lt
+push argument 1
+push constant 1
+add
+push this 1
+gt
+or
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 34
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+call String.appendChar 2
+push constant 99
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 65
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 120
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 102
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push constant 5
+call Sys.error 1
+pop temp 0
+label IF_FALSE0
+push argument 1
+push this 2
+add
+pop pointer 1
+push that 0
+return
+function String.setCharAt 0
+push argument 0
+pop pointer 0
+push argument 1
+push constant 0
+lt
+push argument 1
+push constant 1
+add
+push this 1
+gt
+or
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 37
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+call String.appendChar 2
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 65
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 120
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 102
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push constant 5
+call Sys.error 1
+pop temp 0
+label IF_FALSE0
+push argument 1
+push this 2
+add
+push argument 2
+pop temp 0
+pop pointer 1
+push temp 0
+pop that 0
+push constant 0
+return
+function String.appendChar 0
+push argument 0
+pop pointer 0
+push this 1
+push this 0
+eq
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 38
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+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
+push constant 114
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 99
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 100
+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 120
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push constant 5
+call Sys.error 1
+pop temp 0
+label IF_FALSE0
+push this 1
+push this 2
+add
+push argument 1
+pop temp 0
+pop pointer 1
+push temp 0
+pop that 0
+push this 1
+push constant 1
+add
+pop this 1
+push pointer 0
+return
+function String.eraseLastChar 0
+push argument 0
+pop pointer 0
+push this 1
+push constant 0
+eq
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 46
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+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 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 76
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 115
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 67
+call String.appendChar 2
+push constant 104
+call String.appendChar 2
+push constant 97
+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
+push constant 115
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+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
+push constant 97
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 121
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 109
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 121
+call String.appendChar 2
+push constant 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push constant 5
+call Sys.error 1
+pop temp 0
+label IF_FALSE0
+push this 1
+push constant 1
+sub
+pop this 1
+push constant 0
+return
+function String.intValue 5
+push argument 0
+pop pointer 0
+push constant 0
+pop local 0
+push constant 0
+push this 2
+add
+pop pointer 1
+push that 0
+push constant 45
+eq
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 1
+pop local 1
+push constant 0
+not
+pop local 3
+goto IF_END0
+label IF_FALSE0
+push constant 0
+pop local 1
+push constant 0
+pop local 3
+label IF_END0
+push local 1
+push this 2
+add
+pop pointer 1
+push that 0
+pop local 2
+push local 2
+push constant 48
+lt
+push local 2
+push constant 57
+gt
+or
+if-goto IF_TRUE1
+goto IF_FALSE1
+label IF_TRUE1
+push constant 3
+call Sys.error 1
+pop temp 0
+push constant 46
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 86
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 108
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 116
+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 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 112
+call String.appendChar 2
+push constant 117
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 100
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 97
+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
+push constant 110
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 116
+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 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+label IF_FALSE1
+push constant 0
+pop local 4
+label WHILE_EXP0
+push local 4
+not
+push local 1
+push this 1
+lt
+and
+not
+if-goto WHILE_END0
+push local 1
+push this 2
+add
+pop pointer 1
+push that 0
+pop local 2
+push local 2
+push constant 47
+gt
+push local 2
+push constant 58
+lt
+and
+if-goto IF_TRUE2
+goto IF_FALSE2
+label IF_TRUE2
+push local 0
+push constant 10
+call Math.multiply 2
+push local 2
+push constant 48
+sub
+add
+pop local 0
+goto IF_END2
+label IF_FALSE2
+push constant 0
+not
+pop local 4
+label IF_END2
+push local 1
+push constant 1
+add
+pop local 1
+goto WHILE_EXP0
+label WHILE_END0
+push local 3
+if-goto IF_TRUE3
+goto IF_FALSE3
+label IF_TRUE3
+push local 0
+neg
+return
+goto IF_END3
+label IF_FALSE3
+push local 0
+return
+label IF_END3
+function String.setInt 4
+push argument 0
+pop pointer 0
+push argument 1
+push constant 0
+lt
+if-goto IF_TRUE0
+goto IF_FALSE0
+label IF_TRUE0
+push constant 0
+not
+pop local 3
+push constant 2
+pop this 1
+goto IF_END0
+label IF_FALSE0
+push constant 0
+pop local 3
+push constant 1
+pop this 1
+label IF_END0
+push argument 1
+call Math.abs 1
+pop local 0
+push local 0
+push constant 9999
+gt
+if-goto IF_TRUE1
+goto IF_FALSE1
+label IF_TRUE1
+push this 1
+push constant 4
+add
+pop this 1
+goto IF_END1
+label IF_FALSE1
+push local 0
+push constant 999
+gt
+if-goto IF_TRUE2
+goto IF_FALSE2
+label IF_TRUE2
+push this 1
+push constant 3
+add
+pop this 1
+goto IF_END2
+label IF_FALSE2
+push local 0
+push constant 99
+gt
+if-goto IF_TRUE3
+goto IF_FALSE3
+label IF_TRUE3
+push this 1
+push constant 2
+add
+pop this 1
+goto IF_END3
+label IF_FALSE3
+push local 0
+push constant 9
+gt
+if-goto IF_TRUE4
+goto IF_FALSE4
+label IF_TRUE4
+push this 1
+push constant 1
+add
+pop this 1
+label IF_FALSE4
+label IF_END3
+label IF_END2
+label IF_END1
+push this 1
+push this 0
+gt
+if-goto IF_TRUE5
+goto IF_FALSE5
+label IF_TRUE5
+push constant 45
+call String.new 1
+push constant 83
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 46
+call String.appendChar 2
+push constant 115
+call String.appendChar 2
+push constant 101
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 73
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 58
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 118
+call String.appendChar 2
+push constant 97
+call String.appendChar 2
+push constant 108
+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
+push constant 116
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 98
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 102
+call String.appendChar 2
+push constant 111
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 32
+call String.appendChar 2
+push constant 116
+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 115
+call String.appendChar 2
+push constant 116
+call String.appendChar 2
+push constant 114
+call String.appendChar 2
+push constant 105
+call String.appendChar 2
+push constant 110
+call String.appendChar 2
+push constant 103
+call String.appendChar 2
+push constant 33
+call String.appendChar 2
+call Output.printString 1
+pop temp 0
+push constant 5
+call Sys.error 1
+pop temp 0
+label IF_FALSE5
+push local 0
+push constant 0
+eq
+if-goto IF_TRUE6
+goto IF_FALSE6
+label IF_TRUE6
+push pointer 0
+push constant 0
+push constant 48
+call String.setCharAt 3
+pop temp 0
+push constant 0
+return
+label IF_FALSE6
+push local 3
+if-goto IF_TRUE7
+goto IF_FALSE7
+label IF_TRUE7
+push pointer 0
+push constant 0
+push constant 45
+call String.setCharAt 3
+pop temp 0
+label IF_FALSE7
+push this 1
+push constant 1
+sub
+pop local 1
+label WHILE_EXP0
+push local 0
+push constant 0
+gt
+not
+if-goto WHILE_END0
+push local 0
+push constant 10
+call Math.divide 2
+pop local 2
+push pointer 0
+push local 1
+push local 0
+push local 2
+push constant 10
+call Math.multiply 2
+sub
+push constant 48
+add
+call String.setCharAt 3
+pop temp 0
+push local 2
+pop local 0
+push local 1
+push constant 1
+sub
+pop local 1
+goto WHILE_EXP0
+label WHILE_END0
+push constant 0
+return
+function String.newLine 0
+push constant 128
+return
+function String.backSpace 0
+push constant 129
+return
+function String.doubleQuote 0
+push constant 34
+return