157 lines
2.1 KiB
Plaintext
Executable File
157 lines
2.1 KiB
Plaintext
Executable File
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
|