1 #define PROGINSTR stw r0, PDATA(r13)
29 ;assuming that no more than 42 instr are used
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
54 .fill 0xed300004;ldis r6, CONST
58 .ifill add r6, r7, r6;0xe03bb000
62 .ifill sub r7, r7, r6;0xe0bbb000
67 .ifill cmp r7, r6;0xec3b0000
75 .ifill cmpi r6,0;0xecb00000
78 .fill 1, 0x0b000003;brne+ CONST
82 .fill 1, 0xed300000;ldil r6, CONST
83 .fill 1, 0xed300002;ldih r6, CONST
94 .ifill not r6;0xe4b7fffa
117 ;set address of input
118 ldis r1, inputdata@lo
119 ldih r1, inputdata@hi
121 ;set address of program start
122 ldis r2, (prog_start/4)@lo
123 ldih r2, (prog_start/4)@hi
125 ;set address to instruction table
126 ldis r3, instrtable@lo
127 ldih r3, instrtable@hi
129 ;set address to defer table
130 ldis r9, defertable@lo
131 ldih r9, defertable@hi
136 ;set programmer address
142 ;set address to stack
146 ;make r15 a 0-register
148 ;make r14 a 8-bit -1-register
159 subi r0, r0, 0xc ; offset abziehen
176 ;first version only supports backward jumps
178 ;r1 ... address to input, every byte is a new input
179 ; includes pc implicitly
180 ;r2 ... address to program start
181 ;r3 ... address of instruction table
182 ;r4 ... gets loaded with instr. prog. addr.
184 ;r9 ... address to actual entry in defer table
185 ;r10... address to defer table
186 ;r13 .. programmer address
188 ;load address of program
189 ldil r14, prog_mul@lo
190 ldih r14, prog_mul@hi
192 ldil r15, prog_consts@lo
193 ldih r15, prog_consts@hi
195 ;backup defer table address
201 ;increment input address
204 ;store address of next instruction in table
206 ;increment instr. table
211 ;we need to multiply input by 4 to get correct address offset
213 ;calc position in jumptable
214 ldw r0, jumptable(r0)
219 ;load address of program
222 ;program instruction (2)
229 ;now it is time to clear up the defer table
233 ;load branch template
236 ;if actual and base are equal, no entry
242 ;load pointer to where to jump to
244 ;load where to jump to
246 ;load where to save from defer table
252 ;set the upper 16 bit 0
254 ;shift to the position of imm in br
269 ;program instruction (14)
303 ;load address of program
307 ;program instruction (5)
321 ;load address of program
325 ;program instruction (5)
338 ;case 0 1 2 3 4 5 6 7 8 9
341 ;program instruction (3)
345 ;the first instr. loads r6 with the number
346 ;thus we shall emulate this
350 ;shift 3 bits left, as the immediate in ldi has
353 ;now 'add' this to the ldi
356 ;store this 'dynamic' instruction
367 ;load address of program
368 ldil r4, prog_lessthan@lo
369 ldih r4, prog_lessthan@hi
371 ;program instruction (6)
392 ;program instruction (3)
404 ;the following instructions calculate the immediate
426 ;now we will generate ldih/l which will store this
427 ;immediate into a register
429 ;load address of program
464 ;gespeicherte instrs sollten input indepentent sein
466 ;fuer forward jumps muss deferrer table gemacht werden *puke*
468 ;load address of program
477 ;program instruction (2)
482 ;we add the offset to this instruction
486 ;we know calculate the jump destination
487 ;set r6 to 0 (to clear upper bytes)
491 ;compare input with neg. max of 8 bit
497 ;generate negativ offset
499 ;r6 is now the 'real' negativ number
501 ;todo: testing showed (at least once) we are off by 2 instr.
503 ;multiply by to get the offset
505 ;generate address in table
507 ;r0 now has the target address
512 ;we shift 2 bits out, because rel. br takes instr.
513 ;count and not address amount ...
515 ;set the upper 16 bit 0
517 ;shift to the position of imm in br
531 ;we know save the address in the instrtable where the addr to jump to stands
532 ;the value doesn't exists at the moment, but it will at evaluation
534 ;save position to save the instr into defer table
537 ;we need one instruction to have the correct offset (?)
540 ;todo: check if -1 is needed
542 ;multiply with 2 to get offset right
546 ;save the address to defer table
548 ;increment defer table address
557 ;load address of program
561 ;program instruction (1)
573 ;load address of program
577 ;program instruction (4)
593 ;load address of program
597 ;program instruction (3)
611 .fill 41, vm_default/4
617 .fill 1, vm_default/4
621 .fill 2, vm_default/4
623 .fill 10, vm_consts/4
625 .fill 2, vm_default/4
627 .fill 1, vm_lessthan/4
629 .fill 7, vm_default/4
633 .fill 4, vm_default/4
639 .fill 5, vm_default/4
643 .fill 7, vm_default/4
647 .fill 37, vm_default/4
651 .fill 129, vm_default/4
653 ;we assume not more than 3 entries