projects
/
calu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vm: made deepjit downloadable?
[calu.git]
/
3_test
/
deepjit.s
diff --git
a/3_test/deepjit.s
b/3_test/deepjit.s
index ae87d687a9732efd0ceec2ce590cc09add53abad..bf6507bc94da2552d5e9af14e6c3ba5250a9ac22 100644
(file)
--- a/
3_test/deepjit.s
+++ b/
3_test/deepjit.s
@@
-29,13
+29,12
@@
instrtable:
.fill 42, 0
prog_eof:
.fill 42, 0
prog_eof:
-.ifill
ldw r0, 0-4(r3);0xE701FFFC
+.ifill
pop r0
.ifill ret+
prog_mul:
.ifill ret+
prog_mul:
-.ifill subi r3, r3, 4;0xE1998020
-.ifill ldw r6, 0(r3);0xe7318000
-.ifill ldw r7, 0-4(r3);0xe739fffc
+.ifill pop r6
+.ifill pop r7
.ifill ldis r8, 0;0xed400004
.ifill mov r0, r7;0xe1038000
.ifill andx r0, 1;0xe2800008
.ifill ldis r8, 0;0xed400004
.ifill mov r0, r7;0xe1038000
.ifill andx r0, 1;0xe2800008
@@
-47,68
+46,60
@@
prog_mul:
.ifill adddnz r8, r8, r6;0x00443001
.ifill subi r7, r7, 2;0xe1bb8010
.fill 0x0b7ffe83;brnz+ loop
.ifill adddnz r8, r8, r6;0x00443001
.ifill subi r7, r7, 2;0xe1bb8010
.fill 0x0b7ffe83;brnz+ loop
-.ifill
stw r8, 0-4(r3);0xe7c1fffc
+.ifill
push r8
prog_consts:
.fill 0xed300004;ldis r6, CONST
prog_consts:
.fill 0xed300004;ldis r6, CONST
-.ifill stw r6, 0(r3);0xe7b18000
-.ifill addi r3, r3, 4;0xe1198020
+.ifill push r6
prog_add:
prog_add:
-.ifill subi r3, r3, 4;0xe1998020
-.ifill ldw r6, 0(r3);0xe7318000
-.ifill ldw r7, 0-4(r3);0xe739fffc
+.ifill pop r6
+.ifill pop r7
.ifill add r7, r7, r6;0xe03bb000
.ifill add r7, r7, r6;0xe03bb000
-.ifill
stw r7, 0-4(r3);0xe7b9fffc
+.ifill
push r7
prog_sub:
prog_sub:
-.ifill subi r3, r3, 4;0xe1998020
-.ifill ldw r6, 0(r3);0xe7318000
-.ifill ldw r7, 0-4(r3);0xe739fffc
+.ifill pop r6
+.ifill pop r7
.ifill sub r7, r7, r6;0xe0bbb000
.ifill sub r7, r7, r6;0xe0bbb000
-.ifill
stw r7, 0-4(r3);0xe7b9fffc
+.ifill
push r7
prog_lessthan:
prog_lessthan:
-.ifill subi r3, r3, 4;0xe1998020
-.ifill ldw r6, 0(r3);0xe7318000
-.ifill ldw r7, 0-4(r3);0xe739fffc
-.ifill ldis r8, 0;0xed400004
+.ifill pop r6
+.ifill pop r7
.ifill cmp r7, r6;0xec3b0000
.ifill cmp r7, r6;0xec3b0000
-.ifill
ldislt r8, 0xFF;0xbd4007fc
-.ifill
stw r8, 0-4(r3);0xe7c1fffc
+.ifill
pushlt r14
+.ifill
pushge r15
prog_dup:
prog_dup:
-.ifill ldw r6, 0-4(r3);0xe731fffc
-.ifill stw r6, 0(r3);0xe7b18000
-.ifill addi r3, r3, 4;0xe1198020
+.ifill fetch r6
+.ifill push r6
prog_jmp:
prog_jmp:
-.ifill subi r3, r3, 4;0xe1998020
-.ifill ldw r6, 0(r3);0xe7318000
+.ifill pop r6
.ifill cmpi r6,0;0xecb00000
;static calced
.ifill cmpi r6,0;0xecb00000
;static calced
-.fill 1, 0x
b
b000103;breq- vm_next
+.fill 1, 0x
1
b000103;breq- vm_next
.fill 1, 0xeb000003;br+ CONST
prog_imm:
.fill 1, 0xed400000;ldil r6, CONST
.fill 1, 0xed400002;ldih r6, CONST
.fill 1, 0xeb000003;br+ CONST
prog_imm:
.fill 1, 0xed400000;ldil r6, CONST
.fill 1, 0xed400002;ldih r6, CONST
-.ifill stw r6, 0(r3);0xe7b18000
-.ifill addi r3, r3, 4;0xe1198020
+.ifill push r6
prog_pop:
prog_pop:
-.ifill
subi r3, r3, 4;0xe1998020
+.ifill
disc r6
prog_xch:
prog_xch:
-.ifill
ldw r6, 0-4(r3);0xe731fffc
-.ifill
ldw r7, 0-8(r3);0xe739fff8
-.ifill
stw r6, 0-8(r3);0xe7b1fff8
-.ifill
stw r7, 0-4(r3);0xe7b9fffc
+.ifill
pop r6
+.ifill
pop r7
+.ifill
push r6
+.ifill
push r7
prog_not:
prog_not:
-.ifill
ldw r6, 0-4(r3);0xe731fffc
+.ifill
pop r6
.ifill not r6;0xe4b7fffa
.ifill not r6;0xe4b7fffa
-.ifill
stw r6, 0-4(r3);0xe7b1fffc
+.ifill
push r6
.text
main:
.text
main:
@@
-125,16
+116,21
@@
main:
ldih r3, instrtable@hi
;set address to defer table
ldih r3, instrtable@hi
;set address to defer table
- ldil r9,
inst
rtable@lo
- ldih r9,
inst
rtable@hi
+ ldil r9,
defe
rtable@lo
+ ldih r9,
defe
rtable@hi
;call jit compiler
call+ jit
;set address to stack
;call jit compiler
call+ jit
;set address to stack
- ldil r3, stack@lo
- ldih r3, stack@hi
+ ;ldil r3, stack@lo
+ ;ldih r3, stack@hi
+
+ ;make r15 a 0-register
+ ldis r15, 0
+ ;make r14 a 8-bit -1-register
+ ldis r14, 0xFF
;call jit'ed prog
call+ prog_start
;call jit'ed prog
call+ prog_start
@@
-152,6
+148,17
@@
jit:
;r9 ... address to actual entry in defer table
;r10... address to defer table
;r9 ... address to actual entry in defer table
;r10... address to defer table
+ ;load address of program
+ ldil r13, prog_dup@lo
+ ldih r13, prog_dup@hi
+
+ ;load address of program
+ ldil r14, prog_mul@lo
+ ldih r14, prog_mul@hi
+
+ ldil r15, prog_consts@lo
+ ldih r15, prog_consts@hi
+
;backup defer table address
mov r10, r9
;decrement address to input by 1
;backup defer table address
mov r10, r9
;decrement address to input by 1
@@
-192,7
+199,7
@@
vm_eof:
ldil r7, prog_jmp@lo
ldih r7, prog_jmp@hi
;load branch template
ldil r7, prog_jmp@lo
ldih r7, prog_jmp@hi
;load branch template
- ldw r7, 1
6
(r7)
+ ldw r7, 1
2
(r7)
;if actual and base are equal, no entry
cmp r9, r10
;if actual and base are equal, no entry
cmp r9, r10
@@
-209,6
+216,7
@@
vm_defer:
;generate branch
sub r11, r6, r8
;generate branch
sub r11, r6, r8
+ lrs r11, r11, 2
;set the upper 16 bit 0
andx r11, 0xFFFF
;shift to the position of imm in br
;set the upper 16 bit 0
andx r11, 0xFFFF
;shift to the position of imm in br
@@
-224,42
+232,36
@@
vm_defer:
;case *
;42
vm_mul:
;case *
;42
vm_mul:
- ;load address of program
- ldil r4, prog_mul@lo
- ldih r4, prog_mul@hi
-
;program instruction (14)
;program instruction (14)
- ldw r0, 0(r4)
+ ldw r0, 0(r
1
4)
stx r0, 0(r2)
stx r0, 0(r2)
- ldw r0, 4(r4)
+ ldw r0, 4(r
1
4)
stx r0, 4(r2)
stx r0, 4(r2)
- ldw r0, 8(r4)
+ ldw r0, 8(r
1
4)
stx r0, 8(r2)
stx r0, 8(r2)
- ldw r0, 12(r4)
+ ldw r0, 12(r
1
4)
stx r0, 12(r2)
stx r0, 12(r2)
- ldw r0, 16(r4)
+ ldw r0, 16(r
1
4)
stx r0, 16(r2)
stx r0, 16(r2)
- ldw r0, 20(r4)
+ ldw r0, 20(r
1
4)
stx r0, 20(r2)
stx r0, 20(r2)
- ldw r0, 24(r4)
+ ldw r0, 24(r
1
4)
stx r0, 24(r2)
stx r0, 24(r2)
- ldw r0, 28(r4)
+ ldw r0, 28(r
1
4)
stx r0, 28(r2)
stx r0, 28(r2)
- ldw r0, 32(r4)
+ ldw r0, 32(r
1
4)
stx r0, 32(r2)
stx r0, 32(r2)
- ldw r0, 36(r4)
+ ldw r0, 36(r
1
4)
stx r0, 36(r2)
stx r0, 36(r2)
- ldw r0, 40(r4)
+ ldw r0, 40(r
1
4)
stx r0, 40(r2)
stx r0, 40(r2)
- ldw r0, 44(r4)
+ ldw r0, 44(r
1
4)
stx r0, 44(r2)
stx r0, 44(r2)
- ldw r0, 48(r4)
+ ldw r0, 48(r
1
4)
stx r0, 48(r2)
stx r0, 48(r2)
- ldw r0, 52(r4)
- stx r0, 52(r2)
;increment address
;increment address
- addi r2, r2, 5
6
+ addi r2, r2, 5
2
br+ vm_loop
br+ vm_loop
@@
-279,11
+281,9
@@
vm_add:
stx r0, 8(r2)
ldw r0, 12(r4)
stx r0, 12(r2)
stx r0, 8(r2)
ldw r0, 12(r4)
stx r0, 12(r2)
- ldw r0, 16(r4)
- stx r0, 16(r2)
;increment address
;increment address
- addi r2, r2,
20
+ addi r2, r2,
16
br+ vm_loop
br+ vm_loop
@@
-303,23
+303,17
@@
vm_sub:
stx r0, 8(r2)
ldw r0, 12(r4)
stx r0, 12(r2)
stx r0, 8(r2)
ldw r0, 12(r4)
stx r0, 12(r2)
- ldw r0, 16(r4)
- stx r0, 16(r2)
;increment address
;increment address
- addi r2, r2,
20
+ addi r2, r2,
16
br+ vm_loop
;case 0 1 2 3 4 5 6 7 8 9
;48-57
vm_consts:
br+ vm_loop
;case 0 1 2 3 4 5 6 7 8 9
;48-57
vm_consts:
- ;load address of program
- ldil r4, prog_consts@lo
- ldih r4, prog_consts@hi
-
;program instruction (3)
;program instruction (3)
- ldw r0, 0(r
4
)
+ ldw r0, 0(r
15
)
;the first instr. loads r6 with the number
;thus we shall emulate this
;the first instr. loads r6 with the number
;thus we shall emulate this
@@
-333,13
+327,11
@@
vm_consts:
;store this 'dynamic' instruction
stx r0, 0(r2)
;store this 'dynamic' instruction
stx r0, 0(r2)
- ldw r0, 4(r
4
)
+ ldw r0, 4(r
15
)
stx r0, 4(r2)
stx r0, 4(r2)
- ldw r0, 8(r4)
- stx r0, 8(r2)
;increment address
;increment address
- addi r2, r2,
12
+ addi r2, r2,
8
br+ vm_loop
br+ vm_loop
@@
-350,7
+342,7
@@
vm_lessthan:
ldil r4, prog_lessthan@lo
ldih r4, prog_lessthan@hi
ldil r4, prog_lessthan@lo
ldih r4, prog_lessthan@hi
- ;program instruction (
7
)
+ ;program instruction (
6
)
ldw r0, 0(r4)
stx r0, 0(r2)
ldw r0, 4(r4)
ldw r0, 0(r4)
stx r0, 0(r2)
ldw r0, 4(r4)
@@
-361,33
+353,24
@@
vm_lessthan:
stx r0, 12(r2)
ldw r0, 16(r4)
stx r0, 16(r2)
stx r0, 12(r2)
ldw r0, 16(r4)
stx r0, 16(r2)
- ldw r0, 20(r4)
- stx r0, 20(r2)
- ldw r0, 24(r4)
- stx r0, 24(r2)
;increment address
;increment address
- addi r2, r2, 2
8
+ addi r2, r2, 2
0
br+ vm_loop
;case D
;68
vm_dup:
br+ vm_loop
;case D
;68
vm_dup:
- ;load address of program
- ldil r4, prog_dup@lo
- ldih r4, prog_dup@hi
;program instruction (3)
;program instruction (3)
- ldw r0, 0(r
4
)
+ ldw r0, 0(r
13
)
stx r0, 0(r2)
stx r0, 0(r2)
- ldw r0, 4(r
4
)
+ ldw r0, 4(r
13
)
stx r0, 4(r2)
stx r0, 4(r2)
- ldw r0, 8(r4)
- stx r0, 8(r2)
;increment address
;increment address
- addi r2, r2,
12
+ addi r2, r2,
8
br+ vm_loop
br+ vm_loop
@@
-445,11
+428,9
@@
vm_imm:
ldw r0, 8(r4)
stx r0, 8(r2)
ldw r0, 8(r4)
stx r0, 8(r2)
- ldw r0, 12(r4)
- stx r0, 12(r2)
;increment address
;increment address
- addi r2, r2, 1
6
+ addi r2, r2, 1
2
;pc+4
addi r1, r1, 4
;pc+4
addi r1, r1, 4
@@
-467,29
+448,22
@@
vm_jmp:
ldil r4, prog_jmp@lo
ldih r4, prog_jmp@hi
ldil r4, prog_jmp@lo
ldih r4, prog_jmp@hi
- ;program instruction (3)
- ;decrement sp
- ;subi r3, r3, 4
+ ;program instruction (2)
+ ;pop r6
ldw r0, 0(r4)
stx r0, 0(r2)
ldw r0, 0(r4)
stx r0, 0(r2)
- ;load sp
- ;ldw r6, 0(r3)
- ldw r0, 4(r4)
- stx r0, 4(r2)
;compare to 0
;cmpi r6,0
;compare to 0
;cmpi r6,0
- ldw r0,
8
(r4)
- stx r0,
8
(r2)
+ ldw r0,
4
(r4)
+ stx r0,
4
(r2)
;breq+ vm_next
;is statically known
;breq+ vm_next
;is statically known
- ldw r0,
12
(r4)
- stx r0,
12
(r2)
+ ldw r0,
8
(r4)
+ stx r0,
8
(r2)
- ;r8 has now the current base
- ldw r8, 0(r3)
;we add the offset to this instruction
;we add the offset to this instruction
- addi r8, r
8
, 12
+ addi r8, r
2
, 12
;we know calculate the jump destination
;we know calculate the jump destination
@@
-508,15
+482,16
@@
vm_jmp:
;r6 is now the 'real' negativ number
or r6, r6, r7
;todo: testing showed (at least once) we are off by 2 instr.
;r6 is now the 'real' negativ number
or r6, r6, r7
;todo: testing showed (at least once) we are off by 2 instr.
- addi r6, r6, 2
+
;
addi r6, r6, 2
;multiply by to get the offset
lls r6, r6, 2
;generate address in table
add r6, r3, r6
;r0 now has the target address
;multiply by to get the offset
lls r6, r6, 2
;generate address in table
add r6, r3, r6
;r0 now has the target address
+ ;todo: 0-4?
ldw r0, 0(r6)
;we calc the offset
ldw r0, 0(r6)
;we calc the offset
- sub r8, r0, r
2
+ sub r8, r0, r
8
;we shift 2 bits out, because rel. br takes instr.
;count and not address amount ...
lrs r8, r8, 2
;we shift 2 bits out, because rel. br takes instr.
;count and not address amount ...
lrs r8, r8, 2
@@
-525,12
+500,12
@@
vm_jmp:
;shift to the position of imm in br
lls r8, r8, 7
;load template br
;shift to the position of imm in br
lls r8, r8, 7
;load template br
- ldw r0, 1
6
(r4)
+ ldw r0, 1
2
(r4)
or r0, r0, r8
or r0, r0, r8
- stx r0, 1
6
(r2)
+ stx r0, 1
2
(r2)
;increment address
;increment address
- addi r2, r2,
20
+ addi r2, r2,
16
br+ vm_loop
br+ vm_loop
@@
-543,7
+518,7
@@
vm_possign:
stw r8, 4(r9)
;todo: check if -1 is needed
stw r8, 4(r9)
;todo: check if -1 is needed
- subi r6, r6, 1
+
;
subi r6, r6, 1
;multiply with 2 to get offset right
lls r6, r6, 2
;add to current base
;multiply with 2 to get offset right
lls r6, r6, 2
;add to current base