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, 0x0b000003;brne+ CONST
83 .fill 1, 0xed300000;ldil r6, CONST
84 .fill 1, 0xed300002;ldih r6, CONST
95 .ifill not r6;0xe4b7fffa
118 ;set address of input
119 ldis r1, inputdata@lo
120 ldih r1, inputdata@hi
122 ;set address of program start
123 ldis r2, (prog_start/4)@lo
124 ldih r2, (prog_start/4)@hi
126 ;set address to instruction table
127 ldis r3, instrtable@lo
128 ldih r3, instrtable@hi
130 ;set address to defer table
131 ldis r9, defertable@lo
132 ldih r9, defertable@hi
137 ;set programmer address
143 ;set address to stack
147 ;make r15 a 0-register
149 ;make r14 a 8-bit -1-register
160 subi r0, r0, 0xc ; offset abziehen
177 ;first version only supports backward jumps
179 ;r1 ... address to input, every byte is a new input
180 ; includes pc implicitly
181 ;r2 ... address to program start
182 ;r3 ... address of instruction table
183 ;r4 ... gets loaded with instr. prog. addr.
185 ;r9 ... address to actual entry in defer table
186 ;r10... address to defer table
187 ;r13 .. programmer address
189 ;load address of program
190 ldil r14, prog_mul@lo
191 ldih r14, prog_mul@hi
193 ldil r15, prog_consts@lo
194 ldih r15, prog_consts@hi
196 ;backup defer table address
202 ;increment input address
205 ;store address of next instruction in table
207 ;increment instr. table
212 ;we need to multiply input by 4 to get correct address offset
214 ;calc position in jumptable
215 ldw r0, jumptable(r0)
220 ;load address of program
223 ;program instruction (2)
232 ;now it is time to clear up the defer table
236 ;load branch template
239 ;if actual and base are equal, no entry
245 ;load pointer to where to jump to
247 ;load where to jump to
249 ;load where to save from defer table
255 ;set the upper 16 bit 0
257 ;shift to the position of imm in br
272 ;program instruction (14)
306 ;load address of program
310 ;program instruction (5)
324 ;load address of program
328 ;program instruction (5)
341 ;case 0 1 2 3 4 5 6 7 8 9
344 ;program instruction (3)
348 ;the first instr. loads r6 with the number
349 ;thus we shall emulate this
353 ;shift 3 bits left, as the immediate in ldi has
356 ;now 'add' this to the ldi
359 ;store this 'dynamic' instruction
370 ;load address of program
371 ldil r4, prog_lessthan@lo
372 ldih r4, prog_lessthan@hi
374 ;program instruction (6)
395 ;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
467 ;gespeicherte instrs sollten input indepentent sein
469 ;fuer forward jumps muss deferrer table gemacht werden *puke*
471 ;load address of program
480 ;program instruction (2)
485 ;we add the offset to this instruction
489 ;we know calculate the jump destination
490 ;set r6 to 0 (to clear upper bytes)
494 ;compare input with neg. max of 8 bit
500 ;generate negativ offset
502 ;r6 is now the 'real' negativ number
504 ;todo: testing showed (at least once) we are off by 2 instr.
506 ;multiply by to get the offset
508 ;generate address in table
510 ;r0 now has the target address
515 ;we shift 2 bits out, because rel. br takes instr.
516 ;count and not address amount ...
518 ;set the upper 16 bit 0
520 ;shift to the position of imm in br
534 ;we know save the address in the instrtable where the addr to jump to stands
535 ;the value doesn't exists at the moment, but it will at evaluation
537 ;save position to save the instr into defer table
540 ;we need one instruction to have the correct offset (?)
543 ;todo: check if -1 is needed
545 ;multiply with 2 to get offset right
549 ;save the address to defer table
551 ;increment defer table address
560 ;load address of program
564 ;program instruction (1)
576 ;load address of program
580 ;program instruction (4)
596 ;load address of program
600 ;program instruction (3)
614 .fill 41, vm_default/4
620 .fill 1, vm_default/4
624 .fill 2, vm_default/4
626 .fill 10, vm_consts/4
628 .fill 2, vm_default/4
630 .fill 1, vm_lessthan/4
632 .fill 7, vm_default/4
636 .fill 4, vm_default/4
642 .fill 5, vm_default/4
646 .fill 7, vm_default/4
650 .fill 37, vm_default/4
654 .fill 129, vm_default/4
656 ;we assume not more than 3 entries