.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 cmp r7, r6;0xec3b0000
-.ifill ldislt r8, 0xFF;0xbd4007fc
-.ifill stw r8, 0-4(r3);0xe7c1fffc
+.ifill stwlt r14, 0-4(r3);
+.ifill stwge r15, 0-4(r3);
prog_dup:
.ifill ldw r6, 0-4(r3);0xe731fffc
.ifill ldw r6, 0(r3);0xe7318000
.ifill cmpi r6,0;0xecb00000
;static calced
-.fill 1, 0xbb000103;breq- vm_next
+.fill 1, 0x1b000103;breq- vm_next
.fill 1, 0xeb000003;br+ CONST
prog_imm:
ldih r3, instrtable@hi
;set address to defer table
- ldil r9, instrtable@lo
- ldih r9, instrtable@hi
+ ldil r9, defertable@lo
+ ldih r9, defertable@hi
;call jit compiler
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
;r9 ... address to actual entry in defer table
;r10... address to defer table
+ ldil r15, prog_consts@lo
+ ldih r15, prog_consts@hi
+
;backup defer table address
mov r10, r9
;decrement address to input by 1
;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
;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)
- ldw r0, 0(r4)
+ ldw r0, 0(r15)
;the first instr. loads r6 with the number
;thus we shall emulate this
;store this 'dynamic' instruction
stx r0, 0(r2)
- ldw r0, 4(r4)
+ ldw r0, 4(r15)
stx r0, 4(r2)
- ldw r0, 8(r4)
+ ldw r0, 8(r15)
stx r0, 8(r2)
;increment address
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)
stx r0, 16(r2)
ldw r0, 20(r4)
stx r0, 20(r2)
- ldw r0, 24(r4)
- stx r0, 24(r2)
;increment address
- addi r2, r2, 28
+ addi r2, r2, 24
br+ vm_loop
stx r0, 12(r2)
;r8 has now the current base
- ldw r8, 0(r3)
+ ;ldw r8, 0-4(r3)
;we add the offset to this instruction
- addi r8, r8, 12
+ addi r8, r2, 16
;we know calculate the jump destination
;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
+ ;todo: 0-4?
ldw r0, 0(r6)
;we calc the offset
- sub r8, r0, r2
+ sub r8, r0, r8
;we shift 2 bits out, because rel. br takes instr.
;count and not address amount ...
lrs r8, r8, 2
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