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, 0xbb000103;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, instrtable@lo
129 ldih r9, instrtable@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
212 ;set the upper 16 bit 0
214 ;shift to the position of imm in br
227 ;load address of program
231 ;program instruction (14)
269 ;load address of program
273 ;program instruction (5)
293 ;load address of program
297 ;program instruction (5)
314 ;case 0 1 2 3 4 5 6 7 8 9
317 ;load address of program
318 ldil r4, prog_consts@lo
319 ldih r4, prog_consts@hi
321 ;program instruction (3)
323 ;the first instr. loads r6 with the number
324 ;thus we shall emulate this
328 ;shift 3 bits left, as the immediate in ldi has
331 ;now 'add' this to the ldi
334 ;store this 'dynamic' instruction
349 ;load address of program
350 ldil r4, prog_lessthan@lo
351 ldih r4, prog_lessthan@hi
353 ;program instruction (7)
377 ;load address of program
381 ;program instruction (3)
397 ;the following instructions calculate the immediate
419 ;now we will generate ldih/l which will store this
420 ;immediate into a register
422 ;load address of program
443 ;now we program the instructions that will save the
444 ;immediate onto the stack and increment the later
462 ;gespeicherte instrs sollten input indepentent sein
464 ;fuer forward jumps muss deferrer table gemacht werden *puke*
466 ;load address of program
470 ;program instruction (3)
489 ;r8 has now the current base
491 ;we add the offset to this instruction
495 ;we know calculate the jump destination
496 ;set r6 to 0 (to clear upper bytes)
500 ;compare input with neg. max of 8 bit
506 ;generate negativ offset
508 ;r6 is now the 'real' negativ number
510 ;todo: testing showed (at least once) we are off by 2 instr.
512 ;multiply by to get the offset
514 ;generate address in table
516 ;r0 now has the target address
520 ;we shift 2 bits out, because rel. br takes instr.
521 ;count and not address amount ...
523 ;set the upper 16 bit 0
525 ;shift to the position of imm in br
539 ;we know save the address in the instrtable where the addr to jump to stands
540 ;the value doesn't exists at the moment, but it will at evaluation
542 ;save position to save the instr into defer table
545 ;todo: check if -1 is needed
547 ;multiply with 2 to get offset right
551 ;save the address to defer table
553 ;increment defer table address
562 ;load address of program
566 ;program instruction (1)
578 ;load address of program
582 ;program instruction (4)
600 ;load address of program
604 ;program instruction (3)
663 .fill 129, vm_default
665 ;we assume not more than 3 entries