Anpassungen Path-Struktur
This commit is contained in:
23
original/tools/OS/Array.vm
Normal file
23
original/tools/OS/Array.vm
Normal file
@@ -0,0 +1,23 @@
|
||||
function Array.new 0
|
||||
push argument 0
|
||||
push constant 0
|
||||
gt
|
||||
not
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 2
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
call Memory.alloc 1
|
||||
return
|
||||
function Array.dispose 0
|
||||
push argument 0
|
||||
pop pointer 0
|
||||
push pointer 0
|
||||
call Memory.deAlloc 1
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
102
original/tools/OS/Keyboard.vm
Normal file
102
original/tools/OS/Keyboard.vm
Normal file
@@ -0,0 +1,102 @@
|
||||
function Keyboard.init 0
|
||||
push constant 0
|
||||
return
|
||||
function Keyboard.keyPressed 0
|
||||
push constant 24576
|
||||
call Memory.peek 1
|
||||
return
|
||||
function Keyboard.readChar 2
|
||||
push constant 0
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
label WHILE_EXP0
|
||||
push local 1
|
||||
push constant 0
|
||||
eq
|
||||
push local 0
|
||||
push constant 0
|
||||
gt
|
||||
or
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
call Keyboard.keyPressed 0
|
||||
pop local 0
|
||||
push local 0
|
||||
push constant 0
|
||||
gt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push local 0
|
||||
pop local 1
|
||||
label IF_FALSE0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
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 5
|
||||
push constant 80
|
||||
call String.new 1
|
||||
pop local 3
|
||||
push argument 0
|
||||
call Output.printString 1
|
||||
pop temp 0
|
||||
call String.newLine 0
|
||||
pop local 1
|
||||
call String.backSpace 0
|
||||
pop local 2
|
||||
label WHILE_EXP0
|
||||
push local 4
|
||||
not
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
call Keyboard.readChar 0
|
||||
pop local 0
|
||||
push local 0
|
||||
push local 1
|
||||
eq
|
||||
pop local 4
|
||||
push local 4
|
||||
not
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push local 0
|
||||
push local 2
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 3
|
||||
call String.eraseLastChar 1
|
||||
pop temp 0
|
||||
goto IF_END1
|
||||
label IF_FALSE1
|
||||
push local 3
|
||||
push local 0
|
||||
call String.appendChar 2
|
||||
pop local 3
|
||||
label IF_END1
|
||||
label IF_FALSE0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 3
|
||||
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
|
||||
408
original/tools/OS/Math.vm
Normal file
408
original/tools/OS/Math.vm
Normal file
@@ -0,0 +1,408 @@
|
||||
function Math.init 1
|
||||
push constant 16
|
||||
call Array.new 1
|
||||
pop static 1
|
||||
push constant 16
|
||||
call Array.new 1
|
||||
pop static 0
|
||||
push constant 0
|
||||
push static 0
|
||||
add
|
||||
push constant 1
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 15
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
push local 0
|
||||
push static 0
|
||||
add
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Math.abs 0
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 0
|
||||
neg
|
||||
pop argument 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
return
|
||||
function Math.multiply 5
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
push argument 1
|
||||
push constant 0
|
||||
gt
|
||||
and
|
||||
push argument 0
|
||||
push constant 0
|
||||
gt
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
and
|
||||
or
|
||||
pop local 4
|
||||
push argument 0
|
||||
call Math.abs 1
|
||||
pop argument 0
|
||||
push argument 1
|
||||
call Math.abs 1
|
||||
pop argument 1
|
||||
push argument 0
|
||||
push argument 1
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 0
|
||||
pop local 1
|
||||
push argument 1
|
||||
pop argument 0
|
||||
push local 1
|
||||
pop argument 1
|
||||
label IF_FALSE0
|
||||
label WHILE_EXP0
|
||||
push local 2
|
||||
push constant 1
|
||||
sub
|
||||
push argument 1
|
||||
push constant 1
|
||||
sub
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 3
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 1
|
||||
and
|
||||
push constant 0
|
||||
eq
|
||||
not
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 0
|
||||
push argument 0
|
||||
add
|
||||
pop local 0
|
||||
push local 2
|
||||
push local 3
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop local 2
|
||||
label IF_FALSE1
|
||||
push argument 0
|
||||
push argument 0
|
||||
add
|
||||
pop argument 0
|
||||
push local 3
|
||||
push constant 1
|
||||
add
|
||||
pop local 3
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 4
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 0
|
||||
neg
|
||||
pop local 0
|
||||
label IF_FALSE2
|
||||
push local 0
|
||||
return
|
||||
function Math.divide 4
|
||||
push argument 1
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 3
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
push argument 1
|
||||
push constant 0
|
||||
gt
|
||||
and
|
||||
push argument 0
|
||||
push constant 0
|
||||
gt
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
and
|
||||
or
|
||||
pop local 2
|
||||
push constant 0
|
||||
push static 1
|
||||
add
|
||||
push argument 1
|
||||
call Math.abs 1
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push argument 0
|
||||
call Math.abs 1
|
||||
pop argument 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 15
|
||||
lt
|
||||
push local 3
|
||||
not
|
||||
and
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push constant 32767
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
sub
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
lt
|
||||
pop local 3
|
||||
push local 3
|
||||
not
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
push static 1
|
||||
add
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
push argument 0
|
||||
push constant 1
|
||||
sub
|
||||
gt
|
||||
pop local 3
|
||||
push local 3
|
||||
not
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label IF_FALSE2
|
||||
label IF_FALSE1
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
label WHILE_EXP1
|
||||
push local 0
|
||||
push constant 1
|
||||
neg
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END1
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
push argument 0
|
||||
push constant 1
|
||||
sub
|
||||
gt
|
||||
not
|
||||
if-goto IF_TRUE3
|
||||
goto IF_FALSE3
|
||||
label IF_TRUE3
|
||||
push local 1
|
||||
push local 0
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop local 1
|
||||
push argument 0
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
sub
|
||||
pop argument 0
|
||||
label IF_FALSE3
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 0
|
||||
goto WHILE_EXP1
|
||||
label WHILE_END1
|
||||
push local 2
|
||||
if-goto IF_TRUE4
|
||||
goto IF_FALSE4
|
||||
label IF_TRUE4
|
||||
push local 1
|
||||
neg
|
||||
pop local 1
|
||||
label IF_FALSE4
|
||||
push local 1
|
||||
return
|
||||
function Math.sqrt 4
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 4
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push constant 7
|
||||
pop local 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 1
|
||||
neg
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 3
|
||||
push local 0
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop local 1
|
||||
push local 1
|
||||
push local 1
|
||||
call Math.multiply 2
|
||||
pop local 2
|
||||
push local 2
|
||||
push argument 0
|
||||
gt
|
||||
not
|
||||
push local 2
|
||||
push constant 0
|
||||
lt
|
||||
not
|
||||
and
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 1
|
||||
pop local 3
|
||||
label IF_FALSE1
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 3
|
||||
return
|
||||
function Math.max 0
|
||||
push argument 0
|
||||
push argument 1
|
||||
gt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 0
|
||||
pop argument 1
|
||||
label IF_FALSE0
|
||||
push argument 1
|
||||
return
|
||||
function Math.min 0
|
||||
push argument 0
|
||||
push argument 1
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 0
|
||||
pop argument 1
|
||||
label IF_FALSE0
|
||||
push argument 1
|
||||
return
|
||||
376
original/tools/OS/Memory.vm
Normal file
376
original/tools/OS/Memory.vm
Normal file
@@ -0,0 +1,376 @@
|
||||
function Memory.init 0
|
||||
push constant 0
|
||||
pop static 0
|
||||
push constant 2048
|
||||
push static 0
|
||||
add
|
||||
push constant 14334
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 2049
|
||||
push static 0
|
||||
add
|
||||
push constant 2050
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 0
|
||||
return
|
||||
function Memory.peek 0
|
||||
push argument 0
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
return
|
||||
function Memory.poke 0
|
||||
push argument 0
|
||||
push static 0
|
||||
add
|
||||
push argument 1
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 0
|
||||
return
|
||||
function Memory.alloc 2
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 5
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push constant 1
|
||||
pop argument 0
|
||||
label IF_FALSE1
|
||||
push constant 2048
|
||||
pop local 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 16383
|
||||
lt
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 0
|
||||
lt
|
||||
and
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop local 1
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 0
|
||||
eq
|
||||
push local 1
|
||||
push constant 16382
|
||||
gt
|
||||
or
|
||||
push constant 0
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 0
|
||||
eq
|
||||
or
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 1
|
||||
pop local 0
|
||||
goto IF_END2
|
||||
label IF_FALSE2
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
sub
|
||||
push constant 0
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 1
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 1
|
||||
push constant 2
|
||||
add
|
||||
eq
|
||||
if-goto IF_TRUE3
|
||||
goto IF_FALSE3
|
||||
label IF_TRUE3
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
push local 0
|
||||
push constant 2
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto IF_END3
|
||||
label IF_FALSE3
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label IF_END3
|
||||
label IF_END2
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 0
|
||||
push argument 0
|
||||
add
|
||||
push constant 16379
|
||||
gt
|
||||
if-goto IF_TRUE4
|
||||
goto IF_FALSE4
|
||||
label IF_TRUE4
|
||||
push constant 6
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE4
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 0
|
||||
push constant 2
|
||||
add
|
||||
gt
|
||||
if-goto IF_TRUE5
|
||||
goto IF_FALSE5
|
||||
label IF_TRUE5
|
||||
push argument 0
|
||||
push constant 2
|
||||
add
|
||||
push local 0
|
||||
add
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 0
|
||||
sub
|
||||
push constant 2
|
||||
sub
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
push constant 2
|
||||
add
|
||||
eq
|
||||
if-goto IF_TRUE6
|
||||
goto IF_FALSE6
|
||||
label IF_TRUE6
|
||||
push argument 0
|
||||
push constant 3
|
||||
add
|
||||
push local 0
|
||||
add
|
||||
push local 0
|
||||
push argument 0
|
||||
add
|
||||
push constant 4
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto IF_END6
|
||||
label IF_FALSE6
|
||||
push argument 0
|
||||
push constant 3
|
||||
add
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label IF_END6
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
push local 0
|
||||
push argument 0
|
||||
add
|
||||
push constant 2
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label IF_FALSE5
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
push constant 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push local 0
|
||||
push constant 2
|
||||
add
|
||||
return
|
||||
function Memory.deAlloc 2
|
||||
push argument 0
|
||||
push constant 2
|
||||
sub
|
||||
pop local 0
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop local 1
|
||||
push constant 0
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
sub
|
||||
push constant 2
|
||||
sub
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto IF_END0
|
||||
label IF_FALSE0
|
||||
push constant 0
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
sub
|
||||
push constant 0
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 1
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 1
|
||||
push constant 2
|
||||
add
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
push local 0
|
||||
push constant 2
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto IF_END1
|
||||
label IF_FALSE1
|
||||
push constant 1
|
||||
push local 0
|
||||
add
|
||||
push constant 1
|
||||
push local 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label IF_END1
|
||||
label IF_END0
|
||||
push constant 0
|
||||
return
|
||||
1852
original/tools/OS/Output.vm
Normal file
1852
original/tools/OS/Output.vm
Normal file
File diff suppressed because it is too large
Load Diff
806
original/tools/OS/Screen.vm
Normal file
806
original/tools/OS/Screen.vm
Normal file
@@ -0,0 +1,806 @@
|
||||
function Screen.init 1
|
||||
push constant 16384
|
||||
pop static 1
|
||||
push constant 0
|
||||
not
|
||||
pop static 2
|
||||
push constant 17
|
||||
call Array.new 1
|
||||
pop static 0
|
||||
push constant 0
|
||||
push static 0
|
||||
add
|
||||
push constant 1
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 16
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
push local 0
|
||||
push static 0
|
||||
add
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.clearScreen 1
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push constant 8192
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push static 1
|
||||
add
|
||||
push constant 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.updateLocation 0
|
||||
push static 2
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 0
|
||||
push static 1
|
||||
add
|
||||
push argument 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 1
|
||||
or
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
goto IF_END0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push static 1
|
||||
add
|
||||
push argument 0
|
||||
push static 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push argument 1
|
||||
not
|
||||
and
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
label IF_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.setColor 0
|
||||
push argument 0
|
||||
pop static 2
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawPixel 3
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
push argument 0
|
||||
push constant 511
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 1
|
||||
push constant 255
|
||||
gt
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 7
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push constant 16
|
||||
call Math.divide 2
|
||||
pop local 0
|
||||
push argument 0
|
||||
push local 0
|
||||
push constant 16
|
||||
call Math.multiply 2
|
||||
sub
|
||||
pop local 1
|
||||
push argument 1
|
||||
push constant 32
|
||||
call Math.multiply 2
|
||||
push local 0
|
||||
add
|
||||
pop local 2
|
||||
push local 2
|
||||
push local 1
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawConditional 0
|
||||
push argument 2
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push argument 1
|
||||
push argument 0
|
||||
call Screen.drawPixel 2
|
||||
pop temp 0
|
||||
goto IF_END0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push argument 1
|
||||
call Screen.drawPixel 2
|
||||
pop temp 0
|
||||
label IF_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawLine 11
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
push argument 2
|
||||
push constant 511
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 3
|
||||
push constant 255
|
||||
gt
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 8
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 2
|
||||
push argument 0
|
||||
sub
|
||||
call Math.abs 1
|
||||
pop local 3
|
||||
push argument 3
|
||||
push argument 1
|
||||
sub
|
||||
call Math.abs 1
|
||||
pop local 2
|
||||
push local 3
|
||||
push local 2
|
||||
lt
|
||||
pop local 6
|
||||
push local 6
|
||||
push argument 3
|
||||
push argument 1
|
||||
lt
|
||||
and
|
||||
push local 6
|
||||
not
|
||||
push argument 2
|
||||
push argument 0
|
||||
lt
|
||||
and
|
||||
or
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push argument 0
|
||||
pop local 4
|
||||
push argument 2
|
||||
pop argument 0
|
||||
push local 4
|
||||
pop argument 2
|
||||
push argument 1
|
||||
pop local 4
|
||||
push argument 3
|
||||
pop argument 1
|
||||
push local 4
|
||||
pop argument 3
|
||||
label IF_FALSE1
|
||||
push local 6
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 3
|
||||
pop local 4
|
||||
push local 2
|
||||
pop local 3
|
||||
push local 4
|
||||
pop local 2
|
||||
push argument 1
|
||||
pop local 1
|
||||
push argument 0
|
||||
pop local 0
|
||||
push argument 3
|
||||
pop local 8
|
||||
push argument 0
|
||||
push argument 2
|
||||
gt
|
||||
pop local 7
|
||||
goto IF_END2
|
||||
label IF_FALSE2
|
||||
push argument 0
|
||||
pop local 1
|
||||
push argument 1
|
||||
pop local 0
|
||||
push argument 2
|
||||
pop local 8
|
||||
push argument 1
|
||||
push argument 3
|
||||
gt
|
||||
pop local 7
|
||||
label IF_END2
|
||||
push constant 2
|
||||
push local 2
|
||||
call Math.multiply 2
|
||||
push local 3
|
||||
sub
|
||||
pop local 5
|
||||
push constant 2
|
||||
push local 2
|
||||
call Math.multiply 2
|
||||
pop local 9
|
||||
push constant 2
|
||||
push local 2
|
||||
push local 3
|
||||
sub
|
||||
call Math.multiply 2
|
||||
pop local 10
|
||||
push local 1
|
||||
push local 0
|
||||
push local 6
|
||||
call Screen.drawConditional 3
|
||||
pop temp 0
|
||||
label WHILE_EXP0
|
||||
push local 1
|
||||
push local 8
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 5
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE3
|
||||
goto IF_FALSE3
|
||||
label IF_TRUE3
|
||||
push local 5
|
||||
push local 9
|
||||
add
|
||||
pop local 5
|
||||
goto IF_END3
|
||||
label IF_FALSE3
|
||||
push local 5
|
||||
push local 10
|
||||
add
|
||||
pop local 5
|
||||
push local 7
|
||||
if-goto IF_TRUE4
|
||||
goto IF_FALSE4
|
||||
label IF_TRUE4
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 0
|
||||
goto IF_END4
|
||||
label IF_FALSE4
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label IF_END4
|
||||
label IF_END3
|
||||
push local 1
|
||||
push constant 1
|
||||
add
|
||||
pop local 1
|
||||
push local 1
|
||||
push local 0
|
||||
push local 6
|
||||
call Screen.drawConditional 3
|
||||
pop temp 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawRectangle 9
|
||||
push argument 0
|
||||
push argument 2
|
||||
gt
|
||||
push argument 1
|
||||
push argument 3
|
||||
gt
|
||||
or
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 2
|
||||
push constant 511
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 3
|
||||
push constant 255
|
||||
gt
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 9
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push constant 16
|
||||
call Math.divide 2
|
||||
pop local 3
|
||||
push argument 0
|
||||
push local 3
|
||||
push constant 16
|
||||
call Math.multiply 2
|
||||
sub
|
||||
pop local 7
|
||||
push argument 2
|
||||
push constant 16
|
||||
call Math.divide 2
|
||||
pop local 4
|
||||
push argument 2
|
||||
push local 4
|
||||
push constant 16
|
||||
call Math.multiply 2
|
||||
sub
|
||||
pop local 8
|
||||
push local 7
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
not
|
||||
pop local 6
|
||||
push local 8
|
||||
push constant 1
|
||||
add
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 5
|
||||
push argument 1
|
||||
push constant 32
|
||||
call Math.multiply 2
|
||||
push local 3
|
||||
add
|
||||
pop local 0
|
||||
push local 4
|
||||
push local 3
|
||||
sub
|
||||
pop local 2
|
||||
label WHILE_EXP0
|
||||
push argument 1
|
||||
push argument 3
|
||||
gt
|
||||
not
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push local 2
|
||||
add
|
||||
pop local 1
|
||||
push local 2
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 0
|
||||
push local 5
|
||||
push local 6
|
||||
and
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
goto IF_END1
|
||||
label IF_FALSE1
|
||||
push local 0
|
||||
push local 6
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label WHILE_EXP1
|
||||
push local 0
|
||||
push local 1
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END1
|
||||
push local 0
|
||||
push constant 1
|
||||
neg
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
goto WHILE_EXP1
|
||||
label WHILE_END1
|
||||
push local 1
|
||||
push local 5
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
label IF_END1
|
||||
push argument 1
|
||||
push constant 1
|
||||
add
|
||||
pop argument 1
|
||||
push local 1
|
||||
push constant 32
|
||||
add
|
||||
push local 2
|
||||
sub
|
||||
pop local 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawHorizontal 11
|
||||
push argument 1
|
||||
push argument 2
|
||||
call Math.min 2
|
||||
pop local 7
|
||||
push argument 1
|
||||
push argument 2
|
||||
call Math.max 2
|
||||
pop local 8
|
||||
push argument 0
|
||||
push constant 1
|
||||
neg
|
||||
gt
|
||||
push argument 0
|
||||
push constant 256
|
||||
lt
|
||||
and
|
||||
push local 7
|
||||
push constant 512
|
||||
lt
|
||||
and
|
||||
push local 8
|
||||
push constant 1
|
||||
neg
|
||||
gt
|
||||
and
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push local 7
|
||||
push constant 0
|
||||
call Math.max 2
|
||||
pop local 7
|
||||
push local 8
|
||||
push constant 511
|
||||
call Math.min 2
|
||||
pop local 8
|
||||
push local 7
|
||||
push constant 16
|
||||
call Math.divide 2
|
||||
pop local 1
|
||||
push local 7
|
||||
push local 1
|
||||
push constant 16
|
||||
call Math.multiply 2
|
||||
sub
|
||||
pop local 9
|
||||
push local 8
|
||||
push constant 16
|
||||
call Math.divide 2
|
||||
pop local 2
|
||||
push local 8
|
||||
push local 2
|
||||
push constant 16
|
||||
call Math.multiply 2
|
||||
sub
|
||||
pop local 10
|
||||
push local 9
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
not
|
||||
pop local 5
|
||||
push local 10
|
||||
push constant 1
|
||||
add
|
||||
push static 0
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 4
|
||||
push argument 0
|
||||
push constant 32
|
||||
call Math.multiply 2
|
||||
push local 1
|
||||
add
|
||||
pop local 0
|
||||
push local 2
|
||||
push local 1
|
||||
sub
|
||||
pop local 6
|
||||
push local 0
|
||||
push local 6
|
||||
add
|
||||
pop local 3
|
||||
push local 6
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push local 0
|
||||
push local 4
|
||||
push local 5
|
||||
and
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
goto IF_END1
|
||||
label IF_FALSE1
|
||||
push local 0
|
||||
push local 5
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push local 3
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push constant 1
|
||||
neg
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 3
|
||||
push local 4
|
||||
call Screen.updateLocation 2
|
||||
pop temp 0
|
||||
label IF_END1
|
||||
label IF_FALSE0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawSymetric 0
|
||||
push argument 1
|
||||
push argument 3
|
||||
sub
|
||||
push argument 0
|
||||
push argument 2
|
||||
add
|
||||
push argument 0
|
||||
push argument 2
|
||||
sub
|
||||
call Screen.drawHorizontal 3
|
||||
pop temp 0
|
||||
push argument 1
|
||||
push argument 3
|
||||
add
|
||||
push argument 0
|
||||
push argument 2
|
||||
add
|
||||
push argument 0
|
||||
push argument 2
|
||||
sub
|
||||
call Screen.drawHorizontal 3
|
||||
pop temp 0
|
||||
push argument 1
|
||||
push argument 2
|
||||
sub
|
||||
push argument 0
|
||||
push argument 3
|
||||
sub
|
||||
push argument 0
|
||||
push argument 3
|
||||
add
|
||||
call Screen.drawHorizontal 3
|
||||
pop temp 0
|
||||
push argument 1
|
||||
push argument 2
|
||||
add
|
||||
push argument 0
|
||||
push argument 3
|
||||
sub
|
||||
push argument 0
|
||||
push argument 3
|
||||
add
|
||||
call Screen.drawHorizontal 3
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
function Screen.drawCircle 3
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
push argument 0
|
||||
push constant 511
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 1
|
||||
push constant 255
|
||||
gt
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 12
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push argument 2
|
||||
sub
|
||||
push constant 0
|
||||
lt
|
||||
push argument 0
|
||||
push argument 2
|
||||
add
|
||||
push constant 511
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push argument 2
|
||||
sub
|
||||
push constant 0
|
||||
lt
|
||||
or
|
||||
push argument 1
|
||||
push argument 2
|
||||
add
|
||||
push constant 255
|
||||
gt
|
||||
or
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push constant 13
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE1
|
||||
push argument 2
|
||||
pop local 1
|
||||
push constant 1
|
||||
push argument 2
|
||||
sub
|
||||
pop local 2
|
||||
push argument 0
|
||||
push argument 1
|
||||
push local 0
|
||||
push local 1
|
||||
call Screen.drawSymetric 4
|
||||
pop temp 0
|
||||
label WHILE_EXP0
|
||||
push local 1
|
||||
push local 0
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 2
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 2
|
||||
push constant 2
|
||||
push local 0
|
||||
call Math.multiply 2
|
||||
add
|
||||
push constant 3
|
||||
add
|
||||
pop local 2
|
||||
goto IF_END2
|
||||
label IF_FALSE2
|
||||
push local 2
|
||||
push constant 2
|
||||
push local 0
|
||||
push local 1
|
||||
sub
|
||||
call Math.multiply 2
|
||||
add
|
||||
push constant 5
|
||||
add
|
||||
pop local 2
|
||||
push local 1
|
||||
push constant 1
|
||||
sub
|
||||
pop local 1
|
||||
label IF_END2
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
push argument 0
|
||||
push argument 1
|
||||
push local 0
|
||||
push local 1
|
||||
call Screen.drawSymetric 4
|
||||
pop temp 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
393
original/tools/OS/String.vm
Normal file
393
original/tools/OS/String.vm
Normal file
@@ -0,0 +1,393 @@
|
||||
function String.new 0
|
||||
push constant 3
|
||||
call Memory.alloc 1
|
||||
pop pointer 0
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 14
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 0
|
||||
push constant 0
|
||||
gt
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push argument 0
|
||||
call Array.new 1
|
||||
pop this 1
|
||||
label IF_FALSE1
|
||||
push argument 0
|
||||
pop this 0
|
||||
push constant 0
|
||||
pop this 2
|
||||
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 1
|
||||
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 2
|
||||
return
|
||||
function String.charAt 0
|
||||
push argument 0
|
||||
pop pointer 0
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
push argument 1
|
||||
push this 2
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push this 2
|
||||
eq
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 15
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 1
|
||||
push this 1
|
||||
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 this 2
|
||||
gt
|
||||
or
|
||||
push argument 1
|
||||
push this 2
|
||||
eq
|
||||
or
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 16
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push argument 1
|
||||
push this 1
|
||||
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 2
|
||||
push this 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 17
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push this 2
|
||||
push this 1
|
||||
add
|
||||
push argument 1
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push this 2
|
||||
push constant 1
|
||||
add
|
||||
pop this 2
|
||||
push pointer 0
|
||||
return
|
||||
function String.eraseLastChar 0
|
||||
push argument 0
|
||||
pop pointer 0
|
||||
push this 2
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 18
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push this 2
|
||||
push constant 1
|
||||
sub
|
||||
pop this 2
|
||||
push constant 0
|
||||
return
|
||||
function String.intValue 5
|
||||
push argument 0
|
||||
pop pointer 0
|
||||
push this 2
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 0
|
||||
return
|
||||
label IF_FALSE0
|
||||
push constant 0
|
||||
not
|
||||
pop local 3
|
||||
push constant 0
|
||||
push this 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 45
|
||||
eq
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push constant 0
|
||||
not
|
||||
pop local 4
|
||||
push constant 1
|
||||
pop local 0
|
||||
label IF_FALSE1
|
||||
label WHILE_EXP0
|
||||
push local 0
|
||||
push this 2
|
||||
lt
|
||||
push local 3
|
||||
and
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push local 0
|
||||
push this 1
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
push constant 48
|
||||
sub
|
||||
pop local 2
|
||||
push local 2
|
||||
push constant 0
|
||||
lt
|
||||
push local 2
|
||||
push constant 9
|
||||
gt
|
||||
or
|
||||
not
|
||||
pop local 3
|
||||
push local 3
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 1
|
||||
push constant 10
|
||||
call Math.multiply 2
|
||||
push local 2
|
||||
add
|
||||
pop local 1
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label IF_FALSE2
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 4
|
||||
if-goto IF_TRUE3
|
||||
goto IF_FALSE3
|
||||
label IF_TRUE3
|
||||
push local 1
|
||||
neg
|
||||
pop local 1
|
||||
label IF_FALSE3
|
||||
push local 1
|
||||
return
|
||||
function String.setInt 4
|
||||
push argument 0
|
||||
pop pointer 0
|
||||
push this 0
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 19
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
push constant 6
|
||||
call Array.new 1
|
||||
pop local 2
|
||||
push argument 1
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE1
|
||||
goto IF_FALSE1
|
||||
label IF_TRUE1
|
||||
push constant 0
|
||||
not
|
||||
pop local 3
|
||||
push argument 1
|
||||
neg
|
||||
pop argument 1
|
||||
label IF_FALSE1
|
||||
push argument 1
|
||||
pop local 1
|
||||
label WHILE_EXP0
|
||||
push local 1
|
||||
push constant 0
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push argument 1
|
||||
push constant 10
|
||||
call Math.divide 2
|
||||
pop local 1
|
||||
push local 0
|
||||
push local 2
|
||||
add
|
||||
push constant 48
|
||||
push argument 1
|
||||
push local 1
|
||||
push constant 10
|
||||
call Math.multiply 2
|
||||
sub
|
||||
add
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
push local 1
|
||||
pop argument 1
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push local 3
|
||||
if-goto IF_TRUE2
|
||||
goto IF_FALSE2
|
||||
label IF_TRUE2
|
||||
push local 0
|
||||
push local 2
|
||||
add
|
||||
push constant 45
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push local 0
|
||||
push constant 1
|
||||
add
|
||||
pop local 0
|
||||
label IF_FALSE2
|
||||
push this 0
|
||||
push local 0
|
||||
lt
|
||||
if-goto IF_TRUE3
|
||||
goto IF_FALSE3
|
||||
label IF_TRUE3
|
||||
push constant 19
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE3
|
||||
push local 0
|
||||
push constant 0
|
||||
eq
|
||||
if-goto IF_TRUE4
|
||||
goto IF_FALSE4
|
||||
label IF_TRUE4
|
||||
push constant 0
|
||||
push this 1
|
||||
add
|
||||
push constant 48
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push constant 1
|
||||
pop this 2
|
||||
goto IF_END4
|
||||
label IF_FALSE4
|
||||
push constant 0
|
||||
pop this 2
|
||||
label WHILE_EXP1
|
||||
push this 2
|
||||
push local 0
|
||||
lt
|
||||
not
|
||||
if-goto WHILE_END1
|
||||
push this 2
|
||||
push this 1
|
||||
add
|
||||
push local 0
|
||||
push this 2
|
||||
push constant 1
|
||||
add
|
||||
sub
|
||||
push local 2
|
||||
add
|
||||
pop pointer 1
|
||||
push that 0
|
||||
pop temp 0
|
||||
pop pointer 1
|
||||
push temp 0
|
||||
pop that 0
|
||||
push this 2
|
||||
push constant 1
|
||||
add
|
||||
pop this 2
|
||||
goto WHILE_EXP1
|
||||
label WHILE_END1
|
||||
label IF_END4
|
||||
push local 2
|
||||
call Array.dispose 1
|
||||
pop temp 0
|
||||
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
|
||||
83
original/tools/OS/Sys.vm
Normal file
83
original/tools/OS/Sys.vm
Normal file
@@ -0,0 +1,83 @@
|
||||
function Sys.init 0
|
||||
call Memory.init 0
|
||||
pop temp 0
|
||||
call Math.init 0
|
||||
pop temp 0
|
||||
call Screen.init 0
|
||||
pop temp 0
|
||||
call Output.init 0
|
||||
pop temp 0
|
||||
call Keyboard.init 0
|
||||
pop temp 0
|
||||
call Main.main 0
|
||||
pop temp 0
|
||||
call Sys.halt 0
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
function Sys.halt 0
|
||||
label WHILE_EXP0
|
||||
push constant 0
|
||||
not
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Sys.wait 1
|
||||
push argument 0
|
||||
push constant 0
|
||||
lt
|
||||
if-goto IF_TRUE0
|
||||
goto IF_FALSE0
|
||||
label IF_TRUE0
|
||||
push constant 1
|
||||
call Sys.error 1
|
||||
pop temp 0
|
||||
label IF_FALSE0
|
||||
label WHILE_EXP0
|
||||
push argument 0
|
||||
push constant 0
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END0
|
||||
push constant 50
|
||||
pop local 0
|
||||
label WHILE_EXP1
|
||||
push local 0
|
||||
push constant 0
|
||||
gt
|
||||
not
|
||||
if-goto WHILE_END1
|
||||
push local 0
|
||||
push constant 1
|
||||
sub
|
||||
pop local 0
|
||||
goto WHILE_EXP1
|
||||
label WHILE_END1
|
||||
push argument 0
|
||||
push constant 1
|
||||
sub
|
||||
pop argument 0
|
||||
goto WHILE_EXP0
|
||||
label WHILE_END0
|
||||
push constant 0
|
||||
return
|
||||
function Sys.error 0
|
||||
push constant 69
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
push constant 82
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
push constant 82
|
||||
call Output.printChar 1
|
||||
pop temp 0
|
||||
push argument 0
|
||||
call Output.printInt 1
|
||||
pop temp 0
|
||||
call Sys.halt 0
|
||||
pop temp 0
|
||||
push constant 0
|
||||
return
|
||||
Reference in New Issue
Block a user