.
This commit is contained in:
Executable
+101
@@ -0,0 +1,101 @@
|
||||
// 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/Keyboard.jack
|
||||
|
||||
/**
|
||||
* A library for handling user input from the keyboard.
|
||||
*/
|
||||
|
||||
class Keyboard {
|
||||
static Array mem;
|
||||
/** Initializes the keyboard. */
|
||||
function void init() {
|
||||
let mem = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character of the currently pressed key on the keyboard;
|
||||
* if no key is currently pressed, returns 0.
|
||||
*
|
||||
* Recognizes all ASCII characters, as well as the following keys:
|
||||
* new line = 128 = String.newline()
|
||||
* backspace = 129 = String.backspace()
|
||||
* left arrow = 130
|
||||
* up arrow = 131
|
||||
* right arrow = 132
|
||||
* down arrow = 133
|
||||
* home = 134
|
||||
* End = 135
|
||||
* page up = 136
|
||||
* page down = 137
|
||||
* insert = 138
|
||||
* delete = 139
|
||||
* ESC = 140
|
||||
* F1 - F12 = 141 - 152
|
||||
*/
|
||||
function char keyPressed() {
|
||||
return mem[24576];
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until a key is pressed on the keyboard and released,
|
||||
* then echoes the key to the screen, and returns the character
|
||||
* of the pressed key.
|
||||
*/
|
||||
function char readChar() {
|
||||
var char a, b;
|
||||
do Output.printChar(0);
|
||||
while ((b = 0) | (a > 0)){
|
||||
let a = Keyboard.keyPressed();
|
||||
if (a > 0){
|
||||
let b = a;
|
||||
}
|
||||
}
|
||||
do Output.printChar(String.backSpace());
|
||||
do Output.printChar(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the message on the screen, reads from the keyboard the entered
|
||||
* text until a newline character is detected, echoes the text to the screen,
|
||||
* and returns its value. Also handles user backspaces.
|
||||
*/
|
||||
function String readLine(String message) {
|
||||
var String s, b;
|
||||
var char c;
|
||||
let s = String.new(100);
|
||||
do Output.printString(message);
|
||||
while (true){
|
||||
let c = Keyboard.readChar();
|
||||
if (c = 128){
|
||||
return s;
|
||||
}
|
||||
else{
|
||||
if (c = 129){
|
||||
do s.eraseLastChar();
|
||||
}
|
||||
else{
|
||||
do s.appendChar(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the message on the screen, reads from the keyboard the entered
|
||||
* text until a newline character is detected, echoes the text to the screen,
|
||||
* and returns its integer value (until the first non-digit character in the
|
||||
* entered text is detected). Also handles user backspaces.
|
||||
*/
|
||||
function int readInt(String message) {
|
||||
var starting a;
|
||||
var int b;
|
||||
let a = Main.readLine_stolen(message);
|
||||
let b = String.intValue(a);
|
||||
do String.dispose(a);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
Executable
+156
@@ -0,0 +1,156 @@
|
||||
function Keyboard.init 0
|
||||
push constant 0
|
||||
pop static 0
|
||||
push constant 0
|
||||
return
|
||||
function Keyboard.keyPressed 0
|
||||
push static 0
|
||||
push constant 24576
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
return
|
||||
function Keyboard.readChar 2
|
||||
push constant 0
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
label L0
|
||||
push local 1
|
||||
push constant 0
|
||||
eq
|
||||
push local 0
|
||||
push constant 0
|
||||
gt
|
||||
or
|
||||
not
|
||||
if-goto L1
|
||||
call Keyboard.keyPressed 0
|
||||
pop local 0
|
||||
push local 0
|
||||
push constant 0
|
||||
gt
|
||||
not
|
||||
if-goto L2
|
||||
push local 0
|
||||
pop local 1
|
||||
goto L3
|
||||
label L2
|
||||
label L3
|
||||
goto L0
|
||||
label L1
|
||||
call String.backSpace 0
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
push local 1
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
push local 1
|
||||
return
|
||||
function Keyboard.readLine 3
|
||||
push constant 100
|
||||
call String.new 1
|
||||
pop local 0
|
||||
push argument 0
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
label L4
|
||||
push constant 1
|
||||
neg
|
||||
not
|
||||
if-goto L5
|
||||
call Keyboard.readChar 0
|
||||
pop local 2
|
||||
push local 2
|
||||
push constant 128
|
||||
eq
|
||||
not
|
||||
if-goto L6
|
||||
push local 0
|
||||
return
|
||||
goto L7
|
||||
label L6
|
||||
push local 2
|
||||
push constant 129
|
||||
eq
|
||||
not
|
||||
if-goto L8
|
||||
push local 0
|
||||
call String.eraseLastChar 1
|
||||
pop temp 0
|
||||
goto L9
|
||||
label L8
|
||||
push local 0
|
||||
push local 2
|
||||
call String.appendChar 2
|
||||
pop temp 0
|
||||
label L9
|
||||
label L7
|
||||
goto L4
|
||||
label L5
|
||||
function Keyboard.readInt 2
|
||||
push constant 100
|
||||
call String.new 1
|
||||
pop local 0
|
||||
push argument 0
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
label L10
|
||||
push constant 1
|
||||
neg
|
||||
not
|
||||
if-goto L11
|
||||
push local 1
|
||||
call Keyboard.readChar 1
|
||||
pop local 1
|
||||
push local 1
|
||||
push constant 128
|
||||
eq
|
||||
not
|
||||
if-goto L12
|
||||
push local 0
|
||||
call String.intValue 1
|
||||
return
|
||||
goto L13
|
||||
label L12
|
||||
push local 1
|
||||
push constant 129
|
||||
eq
|
||||
not
|
||||
if-goto L14
|
||||
push local 0
|
||||
call String.eraseLastChar 1
|
||||
pop temp 0
|
||||
goto L15
|
||||
label L14
|
||||
push local 1
|
||||
push constant 47
|
||||
gt
|
||||
push local 1
|
||||
push constant 57
|
||||
lt
|
||||
and
|
||||
not
|
||||
if-goto L16
|
||||
push local 0
|
||||
push local 1
|
||||
call String.appendChar 2
|
||||
pop temp 0
|
||||
goto L17
|
||||
label L16
|
||||
label L17
|
||||
push local 1
|
||||
push constant 45
|
||||
eq
|
||||
not
|
||||
if-goto L18
|
||||
push local 0
|
||||
push local 1
|
||||
call String.appendChar 2
|
||||
pop temp 0
|
||||
goto L19
|
||||
label L18
|
||||
label L19
|
||||
label L15
|
||||
label L13
|
||||
goto L10
|
||||
label L11
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Executable
+93
@@ -0,0 +1,93 @@
|
||||
// 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/KeyboardTest/Main.jack
|
||||
|
||||
/** Test program for the OS Keyboard class. */
|
||||
class Main {
|
||||
|
||||
/** Gets input from the user and verifies its contents. */
|
||||
function void main() {
|
||||
var char c, key;
|
||||
var String s;
|
||||
var int i;
|
||||
var boolean ok;
|
||||
|
||||
let ok = false;
|
||||
do Output.printString("keyPressed test:");
|
||||
do Output.println();
|
||||
while (~ok) {
|
||||
do Output.printString("Please press the 'Page Down' key");
|
||||
while (key = 0) {
|
||||
let key = Keyboard.keyPressed();
|
||||
}
|
||||
let c = key;
|
||||
while (~(key = 0)) {
|
||||
let key = Keyboard.keyPressed();
|
||||
}
|
||||
|
||||
do Output.println();
|
||||
|
||||
if (c = 137) {
|
||||
do Output.printString("ok");
|
||||
do Output.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
let ok = false;
|
||||
do Output.printString("readChar test:");
|
||||
do Output.println();
|
||||
do Output.printString("(Verify that the pressed character is echoed to the screen)");
|
||||
do Output.println();
|
||||
while (~ok) {
|
||||
do Output.printString("Please press the number '3': ");
|
||||
let c = Keyboard.readChar();
|
||||
|
||||
do Output.println();
|
||||
|
||||
if (c = 51) {
|
||||
do Output.printString("ok");
|
||||
do Output.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
let ok = false;
|
||||
do Output.printString("readLine test:");
|
||||
do Output.println();
|
||||
do Output.printString("(Verify echo and usage of 'backspace')");
|
||||
do Output.println();
|
||||
while (~ok) {
|
||||
let s = Keyboard.readLine("Please type 'JACK' and press enter: ");
|
||||
|
||||
if (s.length() = 4) {
|
||||
if ((s.charAt(0) = 74) & (s.charAt(1) = 65) & (s.charAt(2) = 67) & (s.charAt(3) = 75)) {
|
||||
do Output.printString("ok");
|
||||
do Output.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ok = false;
|
||||
do Output.printString("readInt test:");
|
||||
do Output.println();
|
||||
do Output.printString("(Verify echo and usage of 'backspace')");
|
||||
do Output.println();
|
||||
while (~ok) {
|
||||
let i = Keyboard.readInt("Please type '-32123' and press enter: ");
|
||||
|
||||
if (i = (-32123)) {
|
||||
do Output.printString("ok");
|
||||
do Output.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
do Output.println();
|
||||
do Output.printString("Test completed successfully");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
Executable
+954
@@ -0,0 +1,954 @@
|
||||
function Main.main 5
|
||||
push constant 0
|
||||
pop local 4
|
||||
push constant 16
|
||||
call String.new 1
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
call String.appendChar 2
|
||||
push constant 80
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 116
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 58
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
label L0
|
||||
push local 4
|
||||
not
|
||||
not
|
||||
if-goto L1
|
||||
push constant 32
|
||||
call String.new 1
|
||||
push constant 80
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 32
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 104
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 80
|
||||
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 68
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 119
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
label L2
|
||||
push local 1
|
||||
push constant 0
|
||||
eq
|
||||
not
|
||||
if-goto L3
|
||||
call Keyboard.keyPressed 0
|
||||
pop local 1
|
||||
goto L2
|
||||
label L3
|
||||
push local 1
|
||||
pop local 0
|
||||
label L4
|
||||
push local 1
|
||||
push constant 0
|
||||
eq
|
||||
not
|
||||
not
|
||||
if-goto L5
|
||||
call Keyboard.keyPressed 0
|
||||
pop local 1
|
||||
goto L4
|
||||
label L5
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 137
|
||||
eq
|
||||
not
|
||||
if-goto L6
|
||||
push constant 2
|
||||
call String.new 1
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 1
|
||||
neg
|
||||
pop local 4
|
||||
goto L7
|
||||
label L6
|
||||
label L7
|
||||
goto L0
|
||||
label L1
|
||||
push constant 0
|
||||
pop local 4
|
||||
push constant 14
|
||||
call String.new 1
|
||||
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 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 32
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 58
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 59
|
||||
call String.new 1
|
||||
push constant 40
|
||||
call String.appendChar 2
|
||||
push constant 86
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 105
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
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 97
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
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 112
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 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 97
|
||||
call String.appendChar 2
|
||||
push constant 99
|
||||
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 105
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 99
|
||||
call String.appendChar 2
|
||||
push constant 104
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
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 116
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
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 99
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 41
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
label L8
|
||||
push local 4
|
||||
not
|
||||
not
|
||||
if-goto L9
|
||||
push constant 29
|
||||
call String.new 1
|
||||
push constant 80
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 32
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 104
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 51
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
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 Keyboard.readChar 0
|
||||
pop local 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 51
|
||||
eq
|
||||
not
|
||||
if-goto L10
|
||||
push constant 2
|
||||
call String.new 1
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 1
|
||||
neg
|
||||
pop local 4
|
||||
goto L11
|
||||
label L10
|
||||
label L11
|
||||
goto L8
|
||||
label L9
|
||||
push constant 0
|
||||
pop local 4
|
||||
push constant 14
|
||||
call String.new 1
|
||||
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 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 32
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 58
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 38
|
||||
call String.new 1
|
||||
push constant 40
|
||||
call String.appendChar 2
|
||||
push constant 86
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 105
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
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 99
|
||||
call String.appendChar 2
|
||||
push constant 104
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 97
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 100
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 117
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 111
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
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 115
|
||||
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 39
|
||||
call String.appendChar 2
|
||||
push constant 41
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
label L12
|
||||
push local 4
|
||||
not
|
||||
not
|
||||
if-goto L13
|
||||
push constant 36
|
||||
call String.new 1
|
||||
push constant 80
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 32
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 74
|
||||
call String.appendChar 2
|
||||
push constant 65
|
||||
call String.appendChar 2
|
||||
push constant 67
|
||||
call String.appendChar 2
|
||||
push constant 75
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 97
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 100
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 58
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
call Keyboard.readLine 1
|
||||
pop local 2
|
||||
push local 2
|
||||
call String.length 1
|
||||
push constant 4
|
||||
eq
|
||||
not
|
||||
if-goto L14
|
||||
push local 2
|
||||
push constant 0
|
||||
call String.charAt 2
|
||||
push constant 74
|
||||
eq
|
||||
push local 2
|
||||
push constant 1
|
||||
call String.charAt 2
|
||||
push constant 65
|
||||
eq
|
||||
and
|
||||
push local 2
|
||||
push constant 2
|
||||
call String.charAt 2
|
||||
push constant 67
|
||||
eq
|
||||
and
|
||||
push local 2
|
||||
push constant 3
|
||||
call String.charAt 2
|
||||
push constant 75
|
||||
eq
|
||||
and
|
||||
not
|
||||
if-goto L15
|
||||
push constant 2
|
||||
call String.new 1
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 1
|
||||
neg
|
||||
pop local 4
|
||||
goto L16
|
||||
label L15
|
||||
label L16
|
||||
goto L17
|
||||
label L14
|
||||
label L17
|
||||
goto L12
|
||||
label L13
|
||||
push constant 0
|
||||
pop local 4
|
||||
push constant 13
|
||||
call String.new 1
|
||||
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 73
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 58
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 38
|
||||
call String.new 1
|
||||
push constant 40
|
||||
call String.appendChar 2
|
||||
push constant 86
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 105
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
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 99
|
||||
call String.appendChar 2
|
||||
push constant 104
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 97
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 100
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 117
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
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 111
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
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 115
|
||||
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 39
|
||||
call String.appendChar 2
|
||||
push constant 41
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
label L18
|
||||
push local 4
|
||||
not
|
||||
not
|
||||
if-goto L19
|
||||
push constant 38
|
||||
call String.new 1
|
||||
push constant 80
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 32
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
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
|
||||
push constant 39
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 97
|
||||
call String.appendChar 2
|
||||
push constant 110
|
||||
call String.appendChar 2
|
||||
push constant 100
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 114
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
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 58
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
call Keyboard.readInt 1
|
||||
pop local 3
|
||||
push local 3
|
||||
push constant 32123
|
||||
neg
|
||||
eq
|
||||
not
|
||||
if-goto L20
|
||||
push constant 2
|
||||
call String.new 1
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 107
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 1
|
||||
neg
|
||||
pop local 4
|
||||
goto L21
|
||||
label L20
|
||||
label L21
|
||||
goto L18
|
||||
label L19
|
||||
call Output.println 0
|
||||
pop temp 0
|
||||
push constant 27
|
||||
call String.new 1
|
||||
push constant 84
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
call String.appendChar 2
|
||||
push constant 32
|
||||
call String.appendChar 2
|
||||
push constant 99
|
||||
call String.appendChar 2
|
||||
push constant 111
|
||||
call String.appendChar 2
|
||||
push constant 109
|
||||
call String.appendChar 2
|
||||
push constant 112
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 116
|
||||
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 115
|
||||
call String.appendChar 2
|
||||
push constant 117
|
||||
call String.appendChar 2
|
||||
push constant 99
|
||||
call String.appendChar 2
|
||||
push constant 99
|
||||
call String.appendChar 2
|
||||
push constant 101
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 115
|
||||
call String.appendChar 2
|
||||
push constant 102
|
||||
call String.appendChar 2
|
||||
push constant 117
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 108
|
||||
call String.appendChar 2
|
||||
push constant 121
|
||||
call String.appendChar 2
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
Reference in New Issue
Block a user