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
55 .fill 0xed300004;ldis r6, CONST
59 .ifill add r6, r7, r6;0xe03bb000
63 .ifill sub r7, r7, r6;0xe0bbb000
68 .ifill cmp r7, r6;0xec3b0000
76 .ifill cmpi r6,0;0xecb00000
79 .fill 1, 0x1b000103;breq- vm_next
80 .fill 1, 0xeb000003;br+ CONST
84 .fill 1, 0xed300000;ldil r6, CONST
85 .fill 1, 0xed300002;ldih r6, CONST
96 .ifill not r6;0xe4b7fffa
119 ;set address of input
120 ldis r1, inputdata@lo
121 ldih r1, inputdata@hi
123 ;set address of program start
124 ldis r2, (prog_start/4)@lo
125 ldih r2, (prog_start/4)@hi
127 ;set address to instruction table
128 ldis r3, instrtable@lo
129 ldih r3, instrtable@hi
131 ;set address to defer table
132 ldis r9, defertable@lo
133 ldih r9, defertable@hi
138 ;set programmer address
144 ;set address to stack
148 ;make r15 a 0-register
150 ;make r14 a 8-bit -1-register
161 subi r0, r0, 0xd ; offset abziehen
178 ;first version only supports backward jumps
180 ;r1 ... address to input, every byte is a new input
181 ; includes pc implicitly
182 ;r2 ... address to program start
183 ;r3 ... address of instruction table
184 ;r4 ... gets loaded with instr. prog. addr.
186 ;r9 ... address to actual entry in defer table
187 ;r10... address to defer table
188 ;r13 .. programmer address
190 ;load address of program
191 ldil r14, prog_mul@lo
192 ldih r14, prog_mul@hi
194 ldil r15, prog_consts@lo
195 ldih r15, prog_consts@hi
197 ;backup defer table address
203 ;increment input address
206 ;store address of next instruction in table
208 ;increment instr. table
213 ;we need to multiply input by 4 to get correct address offset
215 ;calc position in jumptable
216 ldw r0, jumptable(r0)
221 ;load address of program
224 ;program instruction (2)
233 ;now it is time to clear up the defer table
237 ;load branch template
240 ;if actual and base are equal, no entry
246 ;load pointer to where to jump to
248 ;load where to jump to
250 ;load where to save from defer table
256 ;set the upper 16 bit 0
258 ;shift to the position of imm in br
273 ;program instruction (14)
307 ;load address of program
311 ;program instruction (5)
325 ;load address of program
329 ;program instruction (5)
342 ;case 0 1 2 3 4 5 6 7 8 9
345 ;program instruction (3)
349 ;the first instr. loads r6 with the number
350 ;thus we shall emulate this
354 ;shift 3 bits left, as the immediate in ldi has
357 ;now 'add' this to the ldi
360 ;store this 'dynamic' instruction
371 ;load address of program
372 ldil r4, prog_lessthan@lo
373 ldih r4, prog_lessthan@hi
375 ;program instruction (6)
396 ;program instruction (3)
408 ;the following instructions calculate the immediate
430 ;now we will generate ldih/l which will store this
431 ;immediate into a register
433 ;load address of program
468 ;gespeicherte instrs sollten input indepentent sein
470 ;fuer forward jumps muss deferrer table gemacht werden *puke*
472 ;load address of program
481 ;program instruction (2)
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
521 ;we shift 2 bits out, because rel. br takes instr.
522 ;count and not address amount ...
524 ;set the upper 16 bit 0
526 ;shift to the position of imm in br
540 ;we know save the address in the instrtable where the addr to jump to stands
541 ;the value doesn't exists at the moment, but it will at evaluation
543 ;save position to save the instr into defer table
546 ;we need one instruction to have the correct offset (?)
549 ;todo: check if -1 is needed
551 ;multiply with 2 to get offset right
555 ;save the address to defer table
557 ;increment defer table address
566 ;load address of program
570 ;program instruction (1)
582 ;load address of program
586 ;program instruction (4)
602 ;load address of program
606 ;program instruction (3)
620 .fill 41, vm_default/4
626 .fill 1, vm_default/4
630 .fill 2, vm_default/4
632 .fill 10, vm_consts/4
634 .fill 2, vm_default/4
636 .fill 1, vm_lessthan/4
638 .fill 7, vm_default/4
642 .fill 4, vm_default/4
648 .fill 5, vm_default/4
652 .fill 7, vm_default/4
656 .fill 37, vm_default/4
660 .fill 129, vm_default/4
662 ;we assume not more than 3 entries