27 ;assuming that no more than 42 instr are used
32 .ifill ldw r0, 0-4(r3);0xE701FFFC
36 .ifill subi r3, r3, 4;0xE1998020
37 .ifill ldw r6, 0(r3);0xe7318000
38 .ifill ldw r7, 0-4(r3);0xe739fffc
39 .ifill ldis r8, 0;0xed400004
40 .ifill mov r0, r7;0xe1038000
41 .ifill andx r0, 1;0xe2800008
42 .ifill adddnz r8, r8, r6;0x00443001
43 .ifill subinz r7, r7, 1;0x01bb8008
44 .ifill addizs r7, r7, 0;0x113b8000
46 .ifill adddnz r8, r8, r6;0x00443001
47 .ifill adddnz r8, r8, r6;0x00443001
48 .ifill subi r7, r7, 2;0xe1bb8010
49 .fill 0x0b7ffe83;brnz+ loop
50 .ifill stw r8, 0-4(r3);0xe7c1fffc
53 .fill 0xed300004;ldis r6, CONST
54 .ifill stw r6, 0(r3);0xe7b18000
55 .ifill addi r3, r3, 4;0xe1198020
58 .ifill subi r3, r3, 4;0xe1998020
59 .ifill ldw r6, 0(r3);0xe7318000
60 .ifill ldw r7, 0-4(r3);0xe739fffc
61 .ifill add r7, r7, r6;0xe03bb000
62 .ifill stw r7, 0-4(r3);0xe7b9fffc
65 .ifill subi r3, r3, 4;0xe1998020
66 .ifill ldw r6, 0(r3);0xe7318000
67 .ifill ldw r7, 0-4(r3);0xe739fffc
68 .ifill sub r7, r7, r6;0xe0bbb000
69 .ifill stw r7, 0-4(r3);0xe7b9fffc
72 .ifill subi r3, r3, 4;0xe1998020
73 .ifill ldw r6, 0(r3);0xe7318000
74 .ifill ldw r7, 0-4(r3);0xe739fffc
75 .ifill ldis r8, 0;0xed400004
76 .ifill cmp r7, r6;0xec3b0000
77 .ifill ldislt r8, 0xFF;0xbd4007fc
78 .ifill stw r8, 0-4(r3);0xe7c1fffc
81 .ifill ldw r6, 0-4(r3);0xe731fffc
82 .ifill stw r6, 0(r3);0xe7b18000
83 .ifill addi r3, r3, 4;0xe1198020
86 .ifill subi r3, r3, 4;0xe1998020
87 .ifill ldw r6, 0(r3);0xe7318000
88 .ifill cmpi r6,0;0xecb00000
90 .fill 1, 0x1b000103;breq- vm_next
91 .fill 1, 0xeb000003;br+ CONST
94 .fill 1, 0xed400000;ldil r6, CONST
95 .fill 1, 0xed400002;ldih r6, CONST
96 .ifill stw r6, 0(r3);0xe7b18000
97 .ifill addi r3, r3, 4;0xe1198020
100 .ifill subi r3, r3, 4;0xe1998020
103 .ifill ldw r6, 0-4(r3);0xe731fffc
104 .ifill ldw r7, 0-8(r3);0xe739fff8
105 .ifill stw r6, 0-8(r3);0xe7b1fff8
106 .ifill stw r7, 0-4(r3);0xe7b9fffc
109 .ifill ldw r6, 0-4(r3);0xe731fffc
110 .ifill not r6;0xe4b7fffa
111 .ifill stw r6, 0-4(r3);0xe7b1fffc
115 ;set address of input
116 ldil r1, inputdata@lo
117 ldih r1, inputdata@hi
119 ;set address of program start
120 ldil r2, prog_start@lo
121 ldih r2, prog_start@hi
123 ;set address to instruction table
124 ldil r3, instrtable@lo
125 ldih r3, instrtable@hi
127 ;set address to defer table
128 ldil r9, defertable@lo
129 ldih r9, defertable@hi
135 ;set address to stack
144 ;first version only supports backward jumps
146 ;r1 ... address to input, every byte is a new input
147 ; includes pc implicitly
148 ;r2 ... address to program start
149 ;r3 ... address of instruction table
150 ;r4 ... gets loaded with instr. prog. addr.
152 ;r9 ... address to actual entry in defer table
153 ;r10... address to defer table
155 ;backup defer table address
157 ;decrement address to input by 1
162 ;increment input address
165 ;store address of next instruction in table
167 ;increment instr. table
172 ;we need to multiply input by 4 to get correct address offset
174 ;calc position in jumptable
175 ldw r0, jumptable(r0)
180 ;load address of program
183 ;program instruction (2)
190 ;now it is time to clear up the defer table
194 ;load branch template
197 ;if actual and base are equal, no entry
203 ;load pointer to where to jump to
205 ;load where to jump to
207 ;load where to save from defer table
213 ;set the upper 16 bit 0
215 ;shift to the position of imm in br
228 ;load address of program
232 ;program instruction (14)
270 ;load address of program
274 ;program instruction (5)
294 ;load address of program
298 ;program instruction (5)
315 ;case 0 1 2 3 4 5 6 7 8 9
318 ;load address of program
319 ldil r4, prog_consts@lo
320 ldih r4, prog_consts@hi
322 ;program instruction (3)
324 ;the first instr. loads r6 with the number
325 ;thus we shall emulate this
329 ;shift 3 bits left, as the immediate in ldi has
332 ;now 'add' this to the ldi
335 ;store this 'dynamic' instruction
350 ;load address of program
351 ldil r4, prog_lessthan@lo
352 ldih r4, prog_lessthan@hi
354 ;program instruction (7)
378 ;load address of program
382 ;program instruction (3)
398 ;the following instructions calculate the immediate
420 ;now we will generate ldih/l which will store this
421 ;immediate into a register
423 ;load address of program
444 ;now we program the instructions that will save the
445 ;immediate onto the stack and increment the later
463 ;gespeicherte instrs sollten input indepentent sein
465 ;fuer forward jumps muss deferrer table gemacht werden *puke*
467 ;load address of program
471 ;program instruction (3)
490 ;r8 has now the current base
492 ;we add the offset to this instruction
496 ;we know calculate the jump destination
497 ;set r6 to 0 (to clear upper bytes)
501 ;compare input with neg. max of 8 bit
507 ;generate negativ offset
509 ;r6 is now the 'real' negativ number
511 ;todo: testing showed (at least once) we are off by 2 instr.
513 ;multiply by to get the offset
515 ;generate address in table
517 ;r0 now has the target address
522 ;we shift 2 bits out, because rel. br takes instr.
523 ;count and not address amount ...
525 ;set the upper 16 bit 0
527 ;shift to the position of imm in br
541 ;we know save the address in the instrtable where the addr to jump to stands
542 ;the value doesn't exists at the moment, but it will at evaluation
544 ;save position to save the instr into defer table
547 ;todo: check if -1 is needed
549 ;multiply with 2 to get offset right
553 ;save the address to defer table
555 ;increment defer table address
564 ;load address of program
568 ;program instruction (1)
580 ;load address of program
584 ;program instruction (4)
602 ;load address of program
606 ;program instruction (3)
665 .fill 129, vm_default
667 ;we assume not more than 3 entries