.
This commit is contained in:
Executable
+103
@@ -0,0 +1,103 @@
|
||||
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
|
||||
push local 0
|
||||
return
|
||||
function Keyboard.readInt 2
|
||||
push argument 0
|
||||
call Keyboard.readLine 1
|
||||
pop local 0
|
||||
push local 0
|
||||
call String.intValue 1
|
||||
pop local 1
|
||||
push local 0
|
||||
call String.dispose 1
|
||||
pop temp 0
|
||||
push local 1
|
||||
return
|
||||
Reference in New Issue
Block a user