diff options
author | Yuchen Pei <me@ypei.me> | 2018-01-17 16:06:50 +0100 |
---|---|---|
committer | Yuchen Pei <me@ypei.me> | 2018-01-17 16:06:50 +0100 |
commit | c3598a26ab4ba0562ede74b37dc2a7aa6907640a (patch) | |
tree | 858047df30d06258eef8ec799b25012fd5f674b6 /projects/12/OutputTest | |
parent | ee04ea4cf4e679b53180bcbbef8705078457af33 (diff) |
finished Keyboard
Diffstat (limited to 'projects/12/OutputTest')
-rw-r--r-- | projects/12/OutputTest/Output.jack | 11 | ||||
-rw-r--r-- | projects/12/OutputTest/Output.vm | 15 |
2 files changed, 19 insertions, 7 deletions
diff --git a/projects/12/OutputTest/Output.jack b/projects/12/OutputTest/Output.jack index 369c0d3..05d59de 100644 --- a/projects/12/OutputTest/Output.jack +++ b/projects/12/OutputTest/Output.jack @@ -199,20 +199,21 @@ class Output { function void printChar(char c) {
var int k, x, y, addr;
var Array cm;
- if (c = 8) {
+ if (c = 129) {
do Output.backSpace();
return;
}
if (cursorI = 22) {
- if (c = 10) {
+ if (c = 128) {
return;
}
if (cursorJ = 63) {
return;
}
}
- if (c = 10) {
+ if (c = 128) {
do Output.println();
+ return;
}
let k = 0;
let x = cursorJ / 2;
@@ -282,7 +283,9 @@ class Output { /** Advances the cursor to the beginning of the next line. */
function void println() {
- do Output.moveCursor(cursorI + 1, 0);
+ if (cursorI < 22) {
+ do Output.moveCursor(cursorI + 1, 0);
+ }
return;
}
diff --git a/projects/12/OutputTest/Output.vm b/projects/12/OutputTest/Output.vm index 8d6e74c..e291708 100644 --- a/projects/12/OutputTest/Output.vm +++ b/projects/12/OutputTest/Output.vm @@ -1531,7 +1531,7 @@ push constant 0 return function Output.printChar 5 push argument 0 -push constant 8 +push constant 129 eq if-goto IF_TRUE0 goto IF_FALSE0 @@ -1548,7 +1548,7 @@ if-goto IF_TRUE1 goto IF_FALSE1 label IF_TRUE1 push argument 0 -push constant 10 +push constant 128 eq if-goto IF_TRUE2 goto IF_FALSE2 @@ -1567,13 +1567,15 @@ return label IF_FALSE3 label IF_FALSE1 push argument 0 -push constant 10 +push constant 128 eq if-goto IF_TRUE4 goto IF_FALSE4 label IF_TRUE4 call Output.println 0 pop temp 0 +push constant 0 +return label IF_FALSE4 push constant 0 pop local 0 @@ -1788,11 +1790,18 @@ push constant 0 return function Output.println 0 push static 1 +push constant 22 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push static 1 push constant 1 add push constant 0 call Output.moveCursor 2 pop temp 0 +label IF_FALSE0 push constant 0 return function Output.backSpace 0 |