Add missing test files
This commit is contained in:
BIN
files/advanced/Diamond.ijvm
Normal file
BIN
files/advanced/Diamond.ijvm
Normal file
Binary file not shown.
121
files/advanced/Diamond.jas
Normal file
121
files/advanced/Diamond.jas
Normal file
@@ -0,0 +1,121 @@
|
||||
// Recursive diamond by George Karlos
|
||||
//
|
||||
// print a pyramid of characters starting from input char and
|
||||
// going down to ascii 0x31 (1) using nested recursions
|
||||
//
|
||||
|
||||
.constant
|
||||
NEWLINE 0xA
|
||||
OBJREF 0xDEAD
|
||||
ZERO 0x30
|
||||
ONE 0x31
|
||||
SPACE 0x20
|
||||
.end-constant
|
||||
|
||||
.main
|
||||
LDC_W OBJREF
|
||||
prompt:
|
||||
IN
|
||||
|
||||
DUP
|
||||
LDC_W ZERO
|
||||
ISUB
|
||||
IFLT prompt
|
||||
|
||||
LDC_W ONE
|
||||
INVOKEVIRTUAL diamond
|
||||
|
||||
done:
|
||||
HALT
|
||||
.end-main
|
||||
|
||||
.method diamond(n,i)
|
||||
.var
|
||||
backupn
|
||||
backupi
|
||||
.end-var
|
||||
|
||||
ILOAD n
|
||||
LDC_W ZERO
|
||||
SWAP
|
||||
ISUB
|
||||
IFEQ return
|
||||
|
||||
//print empty spaces
|
||||
LDC_W OBJREF
|
||||
LDC_W SPACE
|
||||
ILOAD n
|
||||
INVOKEVIRTUAL printntimes
|
||||
|
||||
//print char
|
||||
LDC_W OBJREF
|
||||
ILOAD n
|
||||
ILOAD i
|
||||
INVOKEVIRTUAL printntimes
|
||||
|
||||
LDC_W NEWLINE
|
||||
OUT
|
||||
|
||||
ILOAD n
|
||||
ISTORE backupn
|
||||
IINC n -1
|
||||
ILOAD i
|
||||
ISTORE backupi
|
||||
IINC i 2
|
||||
|
||||
LDC_W OBJREF
|
||||
ILOAD n
|
||||
ILOAD i
|
||||
INVOKEVIRTUAL diamond
|
||||
|
||||
//dont print 1's again
|
||||
ILOAD backupn
|
||||
LDC_W ONE
|
||||
ISUB
|
||||
IFEQ return
|
||||
|
||||
//print empty spaces
|
||||
LDC_W OBJREF
|
||||
LDC_W SPACE
|
||||
ILOAD backupn
|
||||
INVOKEVIRTUAL printntimes
|
||||
|
||||
|
||||
//print char
|
||||
LDC_W OBJREF
|
||||
ILOAD backupn
|
||||
ILOAD backupi
|
||||
INVOKEVIRTUAL printntimes
|
||||
|
||||
LDC_W NEWLINE
|
||||
OUT
|
||||
|
||||
return:
|
||||
BIPUSH 0x1 //Just a return value
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
|
||||
.method printntimes(c,n)
|
||||
ILOAD n
|
||||
LDC_W ZERO
|
||||
SWAP
|
||||
ISUB
|
||||
IFEQ return
|
||||
|
||||
ILOAD c
|
||||
OUT
|
||||
|
||||
IINC n -1
|
||||
LDC_W OBJREF
|
||||
ILOAD c
|
||||
ILOAD n
|
||||
INVOKEVIRTUAL printntimes
|
||||
|
||||
return:
|
||||
BIPUSH 0x2 //Just a return value
|
||||
IRETURN
|
||||
|
||||
.end-method
|
||||
|
||||
|
||||
BIN
files/advanced/SimpleCalc.ijvm
Normal file
BIN
files/advanced/SimpleCalc.ijvm
Normal file
Binary file not shown.
303
files/advanced/SimpleCalc.jas
Normal file
303
files/advanced/SimpleCalc.jas
Normal file
@@ -0,0 +1,303 @@
|
||||
//SimpleCalc.jas by Ronald Bethlehem
|
||||
//Includes the recursive function for factorial and printing a number
|
||||
//Utilises reverse polish notation
|
||||
//Also tests the SWAP and IF_ICMPEQ operators
|
||||
//Can read larger numbers, all undefined characters delimit
|
||||
//Valid example:
|
||||
//99 5 + 4 / 22 1*- ! ? 99 5+4/22v1*-!?. (prints 24\n24\n)
|
||||
|
||||
.constant
|
||||
OBJREF 0xDEAD
|
||||
ZERO 0x30
|
||||
NINE 0x39
|
||||
FACTORIAL 0x21
|
||||
DUPLICATE 0x26
|
||||
MULTIPLY 0x2A
|
||||
PLUS 0x2B
|
||||
MINUS 0x2D
|
||||
DIVIDE 0x2F
|
||||
PRINT 0x3F
|
||||
END 0x2E
|
||||
.end-constant
|
||||
|
||||
.main
|
||||
.var
|
||||
mode //0 for end, 1 for numberreading, 2 for other
|
||||
tmp
|
||||
.end-var
|
||||
// Add some things to the stack
|
||||
BIPUSH 0x0
|
||||
BIPUSH 0x0
|
||||
BIPUSH 0x0
|
||||
BIPUSH 2
|
||||
ISTORE mode
|
||||
|
||||
readchar:
|
||||
ILOAD mode
|
||||
IFEQ end
|
||||
|
||||
IN
|
||||
//Is is a number?
|
||||
DUP
|
||||
LDC_W ZERO
|
||||
ISUB
|
||||
IFLT continue
|
||||
DUP
|
||||
LDC_W NINE
|
||||
BIPUSH 1
|
||||
IADD
|
||||
ISUB
|
||||
IFLT read_number
|
||||
|
||||
//Set mode to not number (aka delimited)
|
||||
continue:
|
||||
BIPUSH 2
|
||||
ISTORE mode
|
||||
|
||||
//Check for operators
|
||||
DUP
|
||||
LDC_W END
|
||||
IF_ICMPEQ read_end
|
||||
|
||||
DUP
|
||||
LDC_W FACTORIAL
|
||||
IF_ICMPEQ read_factorial
|
||||
|
||||
DUP
|
||||
LDC_W DUPLICATE
|
||||
IF_ICMPEQ read_duplicate
|
||||
|
||||
DUP
|
||||
LDC_W MULTIPLY
|
||||
IF_ICMPEQ read_multiply
|
||||
|
||||
DUP
|
||||
LDC_W PLUS
|
||||
IF_ICMPEQ read_plus
|
||||
|
||||
DUP
|
||||
LDC_W MINUS
|
||||
IF_ICMPEQ read_minus
|
||||
|
||||
DUP
|
||||
LDC_W DIVIDE
|
||||
IF_ICMPEQ read_divide
|
||||
|
||||
DUP
|
||||
LDC_W PRINT
|
||||
IF_ICMPEQ read_print
|
||||
|
||||
//Ignore character
|
||||
POP
|
||||
GOTO readchar
|
||||
|
||||
read_end:
|
||||
POP
|
||||
BIPUSH 0
|
||||
ISTORE mode
|
||||
GOTO readchar
|
||||
|
||||
read_factorial:
|
||||
POP
|
||||
ISTORE tmp
|
||||
LDC_W OBJREF
|
||||
SWAP
|
||||
ILOAD tmp
|
||||
INVOKEVIRTUAL factorial
|
||||
GOTO readchar
|
||||
|
||||
read_duplicate:
|
||||
POP
|
||||
DUP
|
||||
GOTO readchar
|
||||
|
||||
read_multiply:
|
||||
POP
|
||||
ISTORE tmp
|
||||
LDC_W OBJREF
|
||||
SWAP
|
||||
ILOAD tmp
|
||||
INVOKEVIRTUAL mul
|
||||
GOTO readchar
|
||||
|
||||
read_plus:
|
||||
POP
|
||||
IADD
|
||||
GOTO readchar
|
||||
|
||||
read_minus:
|
||||
POP
|
||||
ISUB
|
||||
GOTO readchar
|
||||
|
||||
read_divide:
|
||||
POP
|
||||
ISTORE tmp
|
||||
LDC_W OBJREF
|
||||
SWAP
|
||||
ILOAD tmp
|
||||
INVOKEVIRTUAL divide
|
||||
GOTO readchar
|
||||
|
||||
read_print:
|
||||
POP
|
||||
LDC_W OBJREF
|
||||
SWAP
|
||||
INVOKEVIRTUAL printNumber
|
||||
POP
|
||||
BIPUSH 0xA //newline
|
||||
OUT
|
||||
GOTO readchar
|
||||
|
||||
read_number:
|
||||
LDC_W ZERO
|
||||
ISUB
|
||||
ILOAD mode
|
||||
BIPUSH 1
|
||||
IF_ICMPEQ read_number_continue
|
||||
BIPUSH 1
|
||||
ISTORE mode
|
||||
GOTO readchar
|
||||
|
||||
read_number_continue:
|
||||
SWAP
|
||||
LDC_W OBJREF
|
||||
SWAP
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL mul
|
||||
IADD
|
||||
GOTO readchar
|
||||
|
||||
end:
|
||||
HALT
|
||||
|
||||
.end-main
|
||||
|
||||
.method printNumber(a)
|
||||
ILOAD a
|
||||
BIPUSH 10
|
||||
ISUB
|
||||
IFLT small
|
||||
recurse:
|
||||
LDC_W OBJREF
|
||||
LDC_W OBJREF
|
||||
ILOAD a
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL mod
|
||||
LDC_W OBJREF
|
||||
LDC_W OBJREF
|
||||
ILOAD a
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL divide
|
||||
INVOKEVIRTUAL printNumber
|
||||
POP
|
||||
INVOKEVIRTUAL printNum
|
||||
//POP
|
||||
IRETURN
|
||||
small:
|
||||
LDC_W OBJREF
|
||||
ILOAD a
|
||||
INVOKEVIRTUAL printNum
|
||||
//POP
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
.method printNum(a)
|
||||
ILOAD a
|
||||
LDC_W ZERO
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 0x0
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
.method mul(a,b)
|
||||
ILOAD b
|
||||
ILOAD a
|
||||
ISUB
|
||||
IFLT noswap
|
||||
ILOAD a
|
||||
ILOAD b
|
||||
SWAP
|
||||
ISTORE b
|
||||
ISTORE a
|
||||
noswap:
|
||||
BIPUSH 0
|
||||
loop:
|
||||
ILOAD b
|
||||
IFEQ bzero
|
||||
bpos:
|
||||
ILOAD b
|
||||
BIPUSH 1
|
||||
ISUB
|
||||
ISTORE b
|
||||
add:
|
||||
ILOAD a
|
||||
IADD
|
||||
GOTO loop
|
||||
bzero:
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
.method divide(a,b)
|
||||
.var
|
||||
count
|
||||
.end-var
|
||||
ILOAD b
|
||||
IFEQ err
|
||||
BIPUSH 0
|
||||
ISTORE count
|
||||
ILOAD a
|
||||
loop:
|
||||
ILOAD a
|
||||
ILOAD b
|
||||
ISUB
|
||||
DUP
|
||||
IFLT done
|
||||
ISTORE a
|
||||
inc:
|
||||
ILOAD count
|
||||
BIPUSH 1
|
||||
IADD
|
||||
ISTORE count
|
||||
GOTO loop
|
||||
done:
|
||||
ILOAD count
|
||||
IRETURN
|
||||
err:
|
||||
ERR
|
||||
.end-method
|
||||
|
||||
.method mod(a,b)
|
||||
LDC_W OBJREF
|
||||
LDC_W OBJREF
|
||||
ILOAD a
|
||||
ILOAD b
|
||||
INVOKEVIRTUAL divide
|
||||
ILOAD b
|
||||
INVOKEVIRTUAL mul
|
||||
ILOAD a
|
||||
SWAP // yeah I know, I could also have pushed a at the start, but its a test, who gives a carp about performance
|
||||
ISUB
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
.method factorial(i)
|
||||
.var
|
||||
tmp
|
||||
.end-var
|
||||
LDC_W OBJREF
|
||||
ILOAD i
|
||||
ILOAD i
|
||||
BIPUSH 1
|
||||
ISUB
|
||||
ISTORE tmp
|
||||
ILOAD tmp
|
||||
IFEQ one
|
||||
LDC_W OBJREF
|
||||
ILOAD tmp
|
||||
INVOKEVIRTUAL factorial
|
||||
INVOKEVIRTUAL mul
|
||||
one:
|
||||
IRETURN
|
||||
.end-method
|
||||
BIN
files/advanced/Tanenbaum.ijvm
Normal file
BIN
files/advanced/Tanenbaum.ijvm
Normal file
Binary file not shown.
489
files/advanced/Tanenbaum.jas
Normal file
489
files/advanced/Tanenbaum.jas
Normal file
@@ -0,0 +1,489 @@
|
||||
//
|
||||
// Name
|
||||
//
|
||||
// ijvmtest.jas
|
||||
//
|
||||
// Description
|
||||
//
|
||||
// This program tests the IJVM instruction set.
|
||||
//
|
||||
// Author
|
||||
//
|
||||
// Andrew S. Tanenbaum February 16, 1999
|
||||
//
|
||||
// Modification History
|
||||
//
|
||||
// Ray Ontko April 11, 1999
|
||||
// Added tests for LDC_W, ILOAD, ISTORE, INVOKEVIRTUAL and IRETURN
|
||||
// Also added OUT instructions to help identify which ERROR occurred.
|
||||
//
|
||||
// Notes
|
||||
//
|
||||
// The INP instruction is not tested by this program.
|
||||
// The ERR instruction is not tested by this program.
|
||||
//
|
||||
|
||||
.constant
|
||||
objref 0xCAFE // may be any value. Needed by invokevirtual.
|
||||
my_max 100
|
||||
.end-constant
|
||||
|
||||
.main
|
||||
.var
|
||||
my_var
|
||||
.end-var
|
||||
|
||||
BIPUSH 19 // mark the bottom of the stack
|
||||
BIPUSH 20 // # iterations
|
||||
|
||||
L1: BIPUSH 3
|
||||
BIPUSH 3
|
||||
IF_ICMPEQ L2
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L2: BIPUSH -1
|
||||
BIPUSH -1
|
||||
IF_ICMPEQ L3
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L3: BIPUSH 4 // start testing IADD
|
||||
BIPUSH 7
|
||||
IADD
|
||||
BIPUSH 11
|
||||
IF_ICMPEQ L4
|
||||
BIPUSH 48
|
||||
BIPUSH 3
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L4: BIPUSH -5
|
||||
BIPUSH -9
|
||||
IADD
|
||||
BIPUSH -14
|
||||
IF_ICMPEQ L5
|
||||
BIPUSH 48
|
||||
BIPUSH 4
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L5: BIPUSH 10 // start testing ISUB
|
||||
BIPUSH 7
|
||||
ISUB
|
||||
BIPUSH 3
|
||||
IF_ICMPEQ L6
|
||||
BIPUSH 48
|
||||
BIPUSH 5
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L6: BIPUSH -3
|
||||
BIPUSH -7
|
||||
ISUB
|
||||
BIPUSH 4
|
||||
IF_ICMPEQ L7
|
||||
BIPUSH 48
|
||||
BIPUSH 6
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L7: BIPUSH 0xF2 // start testing IAND
|
||||
BIPUSH 0x31
|
||||
IAND
|
||||
BIPUSH 0x30
|
||||
IF_ICMPEQ L8
|
||||
BIPUSH 48
|
||||
BIPUSH 7
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L8: BIPUSH 0xF2 // start testing IOR
|
||||
BIPUSH 0x31
|
||||
IOR
|
||||
BIPUSH 0xF3
|
||||
IF_ICMPEQ L9
|
||||
BIPUSH 48
|
||||
BIPUSH 8
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L9: BIPUSH 20 // start testing DUP
|
||||
DUP
|
||||
IADD
|
||||
BIPUSH 40
|
||||
IF_ICMPEQ L10
|
||||
BIPUSH 48
|
||||
BIPUSH 9
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L10: BIPUSH 32 // start testing POP
|
||||
BIPUSH 17
|
||||
POP
|
||||
BIPUSH 32
|
||||
IF_ICMPEQ L11
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 0
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L11: BIPUSH 9 // start test of IFLT
|
||||
IFLT ERR
|
||||
BIPUSH 0
|
||||
IFLT ERR
|
||||
BIPUSH -1
|
||||
IFLT L12
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L12: BIPUSH 1 // start testing IFEQ
|
||||
IFEQ ERR
|
||||
BIPUSH 0
|
||||
IFEQ L13
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L13: BIPUSH 16 // start testing SWAP
|
||||
BIPUSH -5
|
||||
SWAP
|
||||
BIPUSH 16
|
||||
IF_ICMPEQ L14
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 3
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L14: BIPUSH -5
|
||||
IF_ICMPEQ L15
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 4
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L15: LDC_W my_max // start testing LDC_W
|
||||
BIPUSH 100
|
||||
IF_ICMPEQ L16
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 5
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L16: BIPUSH 83 // start testing ISTORE, IINC and ILOAD
|
||||
ISTORE my_var
|
||||
IINC my_var 4
|
||||
BIPUSH 99
|
||||
POP
|
||||
ILOAD my_var
|
||||
BIPUSH 87
|
||||
IF_ICMPEQ L17
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 6
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L17: LDC_W objref // start testing INVOKEVIRTUAL and IRETURN
|
||||
BIPUSH -1
|
||||
BIPUSH -10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 1
|
||||
IF_ICMPEQ L18
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 7
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L18: LDC_W objref
|
||||
BIPUSH -10
|
||||
BIPUSH -1
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH -1
|
||||
IF_ICMPEQ L19
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 8
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L19: LDC_W objref
|
||||
BIPUSH -10
|
||||
BIPUSH -10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 0
|
||||
IF_ICMPEQ L20
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 9
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L20: LDC_W objref
|
||||
BIPUSH -10
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH -1
|
||||
IF_ICMPEQ L21
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 0
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L21: LDC_W objref
|
||||
BIPUSH 10
|
||||
BIPUSH -10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 1
|
||||
IF_ICMPEQ L22
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L22: LDC_W objref
|
||||
BIPUSH 0
|
||||
BIPUSH 0
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 0
|
||||
IF_ICMPEQ L23
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L23: LDC_W objref
|
||||
BIPUSH 1
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH -1
|
||||
IF_ICMPEQ L24
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 3
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L24: LDC_W objref
|
||||
BIPUSH 10
|
||||
BIPUSH 1
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 1
|
||||
IF_ICMPEQ L25
|
||||
BIPUSH 48
|
||||
BIPUSH 2
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 4
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L25: LDC_W objref
|
||||
BIPUSH 10
|
||||
BIPUSH 10
|
||||
INVOKEVIRTUAL cmp
|
||||
BIPUSH 0
|
||||
IF_ICMPEQ L26
|
||||
BIPUSH 48
|
||||
BIPUSH 1
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 48
|
||||
BIPUSH 8
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
L26: NOP // test NOP
|
||||
|
||||
// iterate
|
||||
BIPUSH 1
|
||||
ISUB
|
||||
DUP
|
||||
IFEQ FINAL
|
||||
GOTO L1
|
||||
|
||||
FINAL: POP // see if the marker is still there
|
||||
BIPUSH 19
|
||||
IF_ICMPEQ OK
|
||||
BIPUSH 48
|
||||
BIPUSH 0
|
||||
IADD
|
||||
OUT
|
||||
BIPUSH 32
|
||||
OUT
|
||||
GOTO ERR
|
||||
|
||||
OK: BIPUSH 79
|
||||
OUT
|
||||
BIPUSH 75
|
||||
OUT
|
||||
HALT
|
||||
ERR:
|
||||
BIPUSH 69
|
||||
OUT
|
||||
BIPUSH 82
|
||||
OUT
|
||||
BIPUSH 82
|
||||
OUT
|
||||
BIPUSH 79
|
||||
OUT
|
||||
BIPUSH 82
|
||||
OUT
|
||||
HALT
|
||||
.end-main
|
||||
|
||||
// cmp returns -1 if p1 < p2, 0 if p1 = p2, and 1 if p1 > p2
|
||||
.method cmp(p1,p2)
|
||||
.var
|
||||
temp
|
||||
.end-var
|
||||
ILOAD p1
|
||||
ILOAD p2
|
||||
ISUB
|
||||
ISTORE temp
|
||||
ILOAD temp
|
||||
IFLT lt
|
||||
ILOAD temp
|
||||
IFEQ eq
|
||||
gt: BIPUSH 1
|
||||
GOTO done
|
||||
lt: BIPUSH -1
|
||||
GOTO done
|
||||
eq: BIPUSH 0
|
||||
done: IRETURN
|
||||
.end-method
|
||||
BIN
files/advanced/test-nestedinvoke-simple.ijvm
Normal file
BIN
files/advanced/test-nestedinvoke-simple.ijvm
Normal file
Binary file not shown.
20
files/advanced/test-nestedinvoke-simple.jas
Normal file
20
files/advanced/test-nestedinvoke-simple.jas
Normal file
@@ -0,0 +1,20 @@
|
||||
.constant
|
||||
objref 0xCAFE // may be any value. Needed by invokevirtual.
|
||||
.end-constant
|
||||
|
||||
.main
|
||||
LDC_W objref
|
||||
INVOKEVIRTUAL magic
|
||||
.end-main
|
||||
|
||||
.method addone()
|
||||
BIPUSH 0x0
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
|
||||
.method magic()
|
||||
LDC_W objref
|
||||
INVOKEVIRTUAL addone
|
||||
IRETURN
|
||||
.end-method
|
||||
BIN
files/advanced/test-nestedinvoke.ijvm
Normal file
BIN
files/advanced/test-nestedinvoke.ijvm
Normal file
Binary file not shown.
36
files/advanced/test-nestedinvoke.jas
Normal file
36
files/advanced/test-nestedinvoke.jas
Normal file
@@ -0,0 +1,36 @@
|
||||
.constant
|
||||
objref 0xCAFE // may be any value. Needed by invokevirtual.
|
||||
a 5
|
||||
b 15
|
||||
.end-constant
|
||||
|
||||
.main
|
||||
LDC_W objref
|
||||
BIPUSH 0x1
|
||||
LDC_W a
|
||||
INVOKEVIRTUAL magic
|
||||
NOP
|
||||
.end-main
|
||||
|
||||
.method addone(var)
|
||||
ILOAD var
|
||||
BIPUSH 0x1
|
||||
IADD
|
||||
DUP
|
||||
IRETURN
|
||||
.end-method
|
||||
|
||||
|
||||
.method magic(x, y)
|
||||
LDC_W b
|
||||
ILOAD x
|
||||
ILOAD y
|
||||
IADD
|
||||
ISUB
|
||||
DUP
|
||||
LDC_W objref
|
||||
SWAP
|
||||
INVOKEVIRTUAL addone
|
||||
DUP
|
||||
IRETURN
|
||||
.end-method
|
||||
BIN
files/advanced/test-wide1.ijvm
Normal file
BIN
files/advanced/test-wide1.ijvm
Normal file
Binary file not shown.
523
files/advanced/test-wide1.jas
Normal file
523
files/advanced/test-wide1.jas
Normal file
@@ -0,0 +1,523 @@
|
||||
.main
|
||||
BIPUSH 0x0
|
||||
BIPUSH 0x0
|
||||
BIPUSH 0x0
|
||||
INVOKEVIRTUAL test
|
||||
.end-main
|
||||
|
||||
.method test()
|
||||
.var
|
||||
temp0
|
||||
temp1
|
||||
temp2
|
||||
temp3
|
||||
temp4
|
||||
temp5
|
||||
temp6
|
||||
temp7
|
||||
temp8
|
||||
temp9
|
||||
temp10
|
||||
temp11
|
||||
temp12
|
||||
temp13
|
||||
temp14
|
||||
temp15
|
||||
temp16
|
||||
temp17
|
||||
temp18
|
||||
temp19
|
||||
temp20
|
||||
temp21
|
||||
temp22
|
||||
temp23
|
||||
temp24
|
||||
temp25
|
||||
temp26
|
||||
temp27
|
||||
temp28
|
||||
temp29
|
||||
temp30
|
||||
temp31
|
||||
temp32
|
||||
temp33
|
||||
temp34
|
||||
temp35
|
||||
temp36
|
||||
temp37
|
||||
temp38
|
||||
temp39
|
||||
temp40
|
||||
temp41
|
||||
temp42
|
||||
temp43
|
||||
temp44
|
||||
temp45
|
||||
temp46
|
||||
temp47
|
||||
temp48
|
||||
temp49
|
||||
temp50
|
||||
temp51
|
||||
temp52
|
||||
temp53
|
||||
temp54
|
||||
temp55
|
||||
temp56
|
||||
temp57
|
||||
temp58
|
||||
temp59
|
||||
temp60
|
||||
temp61
|
||||
temp62
|
||||
temp63
|
||||
temp64
|
||||
temp65
|
||||
temp66
|
||||
temp67
|
||||
temp68
|
||||
temp69
|
||||
temp70
|
||||
temp71
|
||||
temp72
|
||||
temp73
|
||||
temp74
|
||||
temp75
|
||||
temp76
|
||||
temp77
|
||||
temp78
|
||||
temp79
|
||||
temp80
|
||||
temp81
|
||||
temp82
|
||||
temp83
|
||||
temp84
|
||||
temp85
|
||||
temp86
|
||||
temp87
|
||||
temp88
|
||||
temp89
|
||||
temp90
|
||||
temp91
|
||||
temp92
|
||||
temp93
|
||||
temp94
|
||||
temp95
|
||||
temp96
|
||||
temp97
|
||||
temp98
|
||||
temp99
|
||||
temp100
|
||||
temp101
|
||||
temp102
|
||||
temp103
|
||||
temp104
|
||||
temp105
|
||||
temp106
|
||||
temp107
|
||||
temp108
|
||||
temp109
|
||||
temp110
|
||||
temp111
|
||||
temp112
|
||||
temp113
|
||||
temp114
|
||||
temp115
|
||||
temp116
|
||||
temp117
|
||||
temp118
|
||||
temp119
|
||||
temp120
|
||||
temp121
|
||||
temp122
|
||||
temp123
|
||||
temp124
|
||||
temp125
|
||||
temp126
|
||||
temp127
|
||||
temp128
|
||||
temp129
|
||||
temp130
|
||||
temp131
|
||||
temp132
|
||||
temp133
|
||||
temp134
|
||||
temp135
|
||||
temp136
|
||||
temp137
|
||||
temp138
|
||||
temp139
|
||||
temp140
|
||||
temp141
|
||||
temp142
|
||||
temp143
|
||||
temp144
|
||||
temp145
|
||||
temp146
|
||||
temp147
|
||||
temp148
|
||||
temp149
|
||||
temp150
|
||||
temp151
|
||||
temp152
|
||||
temp153
|
||||
temp154
|
||||
temp155
|
||||
temp156
|
||||
temp157
|
||||
temp158
|
||||
temp159
|
||||
temp160
|
||||
temp161
|
||||
temp162
|
||||
temp163
|
||||
temp164
|
||||
temp165
|
||||
temp166
|
||||
temp167
|
||||
temp168
|
||||
temp169
|
||||
temp170
|
||||
temp171
|
||||
temp172
|
||||
temp173
|
||||
temp174
|
||||
temp175
|
||||
temp176
|
||||
temp177
|
||||
temp178
|
||||
temp179
|
||||
temp180
|
||||
temp181
|
||||
temp182
|
||||
temp183
|
||||
temp184
|
||||
temp185
|
||||
temp186
|
||||
temp187
|
||||
temp188
|
||||
temp189
|
||||
temp190
|
||||
temp191
|
||||
temp192
|
||||
temp193
|
||||
temp194
|
||||
temp195
|
||||
temp196
|
||||
temp197
|
||||
temp198
|
||||
temp199
|
||||
temp200
|
||||
temp201
|
||||
temp202
|
||||
temp203
|
||||
temp204
|
||||
temp205
|
||||
temp206
|
||||
temp207
|
||||
temp208
|
||||
temp209
|
||||
temp210
|
||||
temp211
|
||||
temp212
|
||||
temp213
|
||||
temp214
|
||||
temp215
|
||||
temp216
|
||||
temp217
|
||||
temp218
|
||||
temp219
|
||||
temp220
|
||||
temp221
|
||||
temp222
|
||||
temp223
|
||||
temp224
|
||||
temp225
|
||||
temp226
|
||||
temp227
|
||||
temp228
|
||||
temp229
|
||||
temp230
|
||||
temp231
|
||||
temp232
|
||||
temp233
|
||||
temp234
|
||||
temp235
|
||||
temp236
|
||||
temp237
|
||||
temp238
|
||||
temp239
|
||||
temp240
|
||||
temp241
|
||||
temp242
|
||||
temp243
|
||||
temp244
|
||||
temp245
|
||||
temp246
|
||||
temp247
|
||||
temp248
|
||||
temp249
|
||||
temp250
|
||||
temp251
|
||||
temp252
|
||||
temp253
|
||||
temp254
|
||||
temp255
|
||||
temp256
|
||||
temp257
|
||||
temp258
|
||||
temp259
|
||||
temp260
|
||||
temp261
|
||||
temp262
|
||||
temp263
|
||||
temp264
|
||||
temp265
|
||||
temp266
|
||||
temp267
|
||||
temp268
|
||||
temp269
|
||||
temp270
|
||||
temp271
|
||||
temp272
|
||||
temp273
|
||||
temp274
|
||||
temp275
|
||||
temp276
|
||||
temp277
|
||||
temp278
|
||||
temp279
|
||||
temp280
|
||||
temp281
|
||||
temp282
|
||||
temp283
|
||||
temp284
|
||||
temp285
|
||||
temp286
|
||||
temp287
|
||||
temp288
|
||||
temp289
|
||||
temp290
|
||||
temp291
|
||||
temp292
|
||||
temp293
|
||||
temp294
|
||||
temp295
|
||||
temp296
|
||||
temp297
|
||||
temp298
|
||||
temp299
|
||||
temp300
|
||||
temp301
|
||||
temp302
|
||||
temp303
|
||||
temp304
|
||||
temp305
|
||||
temp306
|
||||
temp307
|
||||
temp308
|
||||
temp309
|
||||
temp310
|
||||
temp311
|
||||
temp312
|
||||
temp313
|
||||
temp314
|
||||
temp315
|
||||
temp316
|
||||
temp317
|
||||
temp318
|
||||
temp319
|
||||
temp320
|
||||
temp321
|
||||
temp322
|
||||
temp323
|
||||
temp324
|
||||
temp325
|
||||
temp326
|
||||
temp327
|
||||
temp328
|
||||
temp329
|
||||
temp330
|
||||
temp331
|
||||
temp332
|
||||
temp333
|
||||
temp334
|
||||
temp335
|
||||
temp336
|
||||
temp337
|
||||
temp338
|
||||
temp339
|
||||
temp340
|
||||
temp341
|
||||
temp342
|
||||
temp343
|
||||
temp344
|
||||
temp345
|
||||
temp346
|
||||
temp347
|
||||
temp348
|
||||
temp349
|
||||
temp350
|
||||
temp351
|
||||
temp352
|
||||
temp353
|
||||
temp354
|
||||
temp355
|
||||
temp356
|
||||
temp357
|
||||
temp358
|
||||
temp359
|
||||
temp360
|
||||
temp361
|
||||
temp362
|
||||
temp363
|
||||
temp364
|
||||
temp365
|
||||
temp366
|
||||
temp367
|
||||
temp368
|
||||
temp369
|
||||
temp370
|
||||
temp371
|
||||
temp372
|
||||
temp373
|
||||
temp374
|
||||
temp375
|
||||
temp376
|
||||
temp377
|
||||
temp378
|
||||
temp379
|
||||
temp380
|
||||
temp381
|
||||
temp382
|
||||
temp383
|
||||
temp384
|
||||
temp385
|
||||
temp386
|
||||
temp387
|
||||
temp388
|
||||
temp389
|
||||
temp390
|
||||
temp391
|
||||
temp392
|
||||
temp393
|
||||
temp394
|
||||
temp395
|
||||
temp396
|
||||
temp397
|
||||
temp398
|
||||
temp399
|
||||
temp400
|
||||
temp401
|
||||
temp402
|
||||
temp403
|
||||
temp404
|
||||
temp405
|
||||
temp406
|
||||
temp407
|
||||
temp408
|
||||
temp409
|
||||
temp410
|
||||
temp411
|
||||
temp412
|
||||
temp413
|
||||
temp414
|
||||
temp415
|
||||
temp416
|
||||
temp417
|
||||
temp418
|
||||
temp419
|
||||
temp420
|
||||
temp421
|
||||
temp422
|
||||
temp423
|
||||
temp424
|
||||
temp425
|
||||
temp426
|
||||
temp427
|
||||
temp428
|
||||
temp429
|
||||
temp430
|
||||
temp431
|
||||
temp432
|
||||
temp433
|
||||
temp434
|
||||
temp435
|
||||
temp436
|
||||
temp437
|
||||
temp438
|
||||
temp439
|
||||
temp440
|
||||
temp441
|
||||
temp442
|
||||
temp443
|
||||
temp444
|
||||
temp445
|
||||
temp446
|
||||
temp447
|
||||
temp448
|
||||
temp449
|
||||
temp450
|
||||
temp451
|
||||
temp452
|
||||
temp453
|
||||
temp454
|
||||
temp455
|
||||
temp456
|
||||
temp457
|
||||
temp458
|
||||
temp459
|
||||
temp460
|
||||
temp461
|
||||
temp462
|
||||
temp463
|
||||
temp464
|
||||
temp465
|
||||
temp466
|
||||
temp467
|
||||
temp468
|
||||
temp469
|
||||
temp470
|
||||
temp471
|
||||
temp472
|
||||
temp473
|
||||
temp474
|
||||
temp475
|
||||
temp476
|
||||
temp477
|
||||
temp478
|
||||
temp479
|
||||
temp480
|
||||
temp481
|
||||
temp482
|
||||
temp483
|
||||
temp484
|
||||
temp485
|
||||
temp486
|
||||
temp487
|
||||
temp488
|
||||
temp489
|
||||
temp490
|
||||
temp491
|
||||
temp492
|
||||
temp493
|
||||
temp494
|
||||
temp495
|
||||
temp496
|
||||
temp497
|
||||
temp498
|
||||
temp499
|
||||
.end-var
|
||||
BIPUSH 0x1
|
||||
WIDE
|
||||
ISTORE temp0
|
||||
BIPUSH 0x2
|
||||
WIDE
|
||||
ISTORE temp256
|
||||
WIDE
|
||||
ILOAD temp0
|
||||
WIDE
|
||||
ILOAD temp256
|
||||
HALT
|
||||
.end-method
|
||||
|
||||
BIN
files/advanced/test-wide2.ijvm
Normal file
BIN
files/advanced/test-wide2.ijvm
Normal file
Binary file not shown.
32791
files/advanced/test-wide2.jas
Normal file
32791
files/advanced/test-wide2.jas
Normal file
File diff suppressed because it is too large
Load Diff
BIN
files/advanced/teststack.ijvm
Normal file
BIN
files/advanced/teststack.ijvm
Normal file
Binary file not shown.
11
files/advanced/teststack.jas
Normal file
11
files/advanced/teststack.jas
Normal file
@@ -0,0 +1,11 @@
|
||||
.main
|
||||
BIPUSH 0x1
|
||||
L1:
|
||||
BIPUSH 0x2
|
||||
GOTO L1
|
||||
BIPUSH 0x4
|
||||
OUT
|
||||
HALT
|
||||
.end-main
|
||||
|
||||
|
||||
BIN
files/advanced/teststack2.ijvm
Normal file
BIN
files/advanced/teststack2.ijvm
Normal file
Binary file not shown.
20
files/advanced/teststack2.jas
Normal file
20
files/advanced/teststack2.jas
Normal file
@@ -0,0 +1,20 @@
|
||||
.main
|
||||
BIPUSH 0x1
|
||||
BIPUSH 0x4
|
||||
BIPUSH 0x3
|
||||
BIPUSH 0x2
|
||||
BIPUSH 0x2
|
||||
BIPUSH 0x2
|
||||
BIPUSH 0x2
|
||||
BIPUSH 0x3
|
||||
INVOKEVIRTUAL test
|
||||
OUT
|
||||
.end-main
|
||||
|
||||
.method test()
|
||||
L1:
|
||||
BIPUSH 0x2
|
||||
GOTO L1
|
||||
.end-method
|
||||
|
||||
|
||||
Reference in New Issue
Block a user