1 #define PROGINSTR stw r0, PDATA(r13)
29 ;assuming that no more than 42 instr are used
40 .ifill ldis r8, 0;0xed400004
41 .ifill mov r0, r7;0xe1038000
42 .ifill andx r0, 1;0xe2800008
43 .ifill adddnz r8, r8, r6;0x00443001
44 .ifill subinz r7, r7, 1;0x01bb8008
45 .ifill addizs r7, r7, 0;0x113b8000
47 .ifill adddnz r8, r8, r6;0x00443001
48 .ifill adddnz r8, r8, r6;0x00443001
49 .ifill subi r7, r7, 2;0xe1bb8010
50 .fill 0x0b7ffe83;brnz+ loop
54 .fill 0xed300004;ldis r6, CONST
60 .ifill add r7, r7, r6;0xe03bb000
66 .ifill sub r7, r7, r6;0xe0bbb000
72 .ifill cmp r7, r6;0xec3b0000
82 .ifill cmpi r6,0;0xecb00000
84 .fill 1, 0x1b000103;breq- vm_next
85 .fill 1, 0xeb000003;br+ CONST
88 .fill 1, 0xed400000;ldil r6, CONST
89 .fill 1, 0xed400002;ldih r6, CONST
103 .ifill not r6;0xe4b7fffa
122 ;set address of input
123 ldis r1, inputdata@lo
124 ldih r1, inputdata@hi
126 ;set address of program start
127 ldis r2, (prog_start/4)@lo
128 ldih r2, (prog_start/4)@hi
130 ;set address to instruction table
131 ldis r3, instrtable@lo
132 ldih r3, instrtable@hi
134 ;set address to defer table
135 ldis r9, defertable@lo
136 ldih r9, defertable@hi
141 ;set programmer address
147 ;set address to stack
151 ;make r15 a 0-register
153 ;make r14 a 8-bit -1-register
166 ;first version only supports backward jumps
168 ;r1 ... address to input, every byte is a new input
169 ; includes pc implicitly
170 ;r2 ... address to program start
171 ;r3 ... address of instruction table
172 ;r4 ... gets loaded with instr. prog. addr.
174 ;r9 ... address to actual entry in defer table
175 ;r10... address to defer table
176 ;r13 .. programmer address
178 ;load address of program
179 ldil r14, prog_mul@lo
180 ldih r14, prog_mul@hi
182 ldil r15, prog_consts@lo
183 ldih r15, prog_consts@hi
185 ;backup defer table address
187 ;decrement address to input by 1
192 ;increment input address
195 ;store address of next instruction in table
197 ;increment instr. table
202 ;we need to multiply input by 4 to get correct address offset
204 ;calc position in jumptable
205 ldw r0, jumptable(r0)
210 ;load address of program
213 ;program instruction (2)
220 ;now it is time to clear up the defer table
224 ;load branch template
227 ;if actual and base are equal, no entry
233 ;load pointer to where to jump to
235 ;load where to jump to
237 ;load where to save from defer table
243 ;set the upper 16 bit 0
245 ;shift to the position of imm in br
260 ;program instruction (14)
296 ;load address of program
300 ;program instruction (5)
318 ;load address of program
322 ;program instruction (5)
337 ;case 0 1 2 3 4 5 6 7 8 9
340 ;program instruction (3)
342 ;the first instr. loads r6 with the number
343 ;thus we shall emulate this
347 ;shift 3 bits left, as the immediate in ldi has
350 ;now 'add' this to the ldi
353 ;store this 'dynamic' instruction
366 ;load address of program
367 ldil r4, prog_lessthan@lo
368 ldih r4, prog_lessthan@hi
370 ;program instruction (6)
393 ;program instruction (3)
407 ;the following instructions calculate the immediate
429 ;now we will generate ldih/l which will store this
430 ;immediate into a register
432 ;load address of program
453 ;now we program the instructions that will save the
454 ;immediate onto the stack and increment the later
470 ;gespeicherte instrs sollten input indepentent sein
472 ;fuer forward jumps muss deferrer table gemacht werden *puke*
474 ;load address of program
478 ;program instruction (2)
493 ;we add the offset to this instruction
497 ;we know calculate the jump destination
498 ;set r6 to 0 (to clear upper bytes)
502 ;compare input with neg. max of 8 bit
508 ;generate negativ offset
510 ;r6 is now the 'real' negativ number
512 ;todo: testing showed (at least once) we are off by 2 instr.
514 ;multiply by to get the offset
516 ;generate address in table
518 ;r0 now has the target address
523 ;we shift 2 bits out, because rel. br takes instr.
524 ;count and not address amount ...
526 ;set the upper 16 bit 0
528 ;shift to the position of imm in br
542 ;we know save the address in the instrtable where the addr to jump to stands
543 ;the value doesn't exists at the moment, but it will at evaluation
545 ;save position to save the instr into defer table
548 ;we need one instruction to have the correct offset (?)
551 ;todo: check if -1 is needed
553 ;multiply with 2 to get offset right
557 ;save the address to defer table
559 ;increment defer table address
568 ;load address of program
572 ;program instruction (1)
584 ;load address of program
588 ;program instruction (4)
606 ;load address of program
610 ;program instruction (3)
629 .fill 41, vm_default/4
635 .fill 1, vm_default/4
639 .fill 2, vm_default/4
641 .fill 10, vm_consts/4
643 .fill 2, vm_default/4
645 .fill 1, vm_lessthan/4
647 .fill 7, vm_default/4
651 .fill 4, vm_default/4
657 .fill 5, vm_default/4
661 .fill 7, vm_default/4
665 .fill 37, vm_default/4
669 .fill 129, vm_default/4
671 ;we assume not more than 3 entries