1 #define PROGINSTR stw r0, PDATA(r13)
26 ;assuming that no more than 42 instr are used
36 .ifill ldis r8, 0;0xed400004
37 .ifill mov r0, r7;0xe1038000
38 .ifill andx r0, 1;0xe2800008
39 .ifill adddnz r8, r8, r6;0x00443001
40 .ifill subinz r7, r7, 1;0x01bb8008
41 .ifill addizs r7, r7, 0;0x113b8000
43 .ifill adddnz r8, r8, r6;0x00443001
44 .ifill adddnz r8, r8, r6;0x00443001
45 .ifill subi r7, r7, 2;0xe1bb8010
46 .fill 0x0b7ffe83;brnz+ loop
51 .fill 0xed300004;ldis r6, CONST
55 .ifill add r6, r7, r6;0xe03bb000
59 .ifill sub r7, r7, r6;0xe0bbb000
64 .ifill cmp r7, r6;0xec3b0000
72 .ifill cmpi r6,0;0xecb00000
75 .fill 1, 0x0b000003;brne+ CONST
79 .fill 1, 0xed300000;ldil r6, CONST
80 .fill 1, 0xed300002;ldih r6, CONST
91 .ifill not r6;0xe4b7fffa
114 ;set address of input
115 ldis r1, inputdata@lo
116 ldih r1, inputdata@hi
118 ;set address of program start
119 ldis r2, (prog_start/4)@lo
120 ldih r2, (prog_start/4)@hi
122 ;set address to instruction table
123 ldis r3, instrtable@lo
124 ldih r3, instrtable@hi
126 ;set address to defer table
127 ldis r9, defertable@lo
128 ldih r9, defertable@hi
133 ;set programmer address
139 ;set address to stack
143 ;make r15 a 0-register
145 ;make r14 a 8-bit -1-register
156 subi r0, r0, 0xc ; offset abziehen
173 ;first version only supports backward jumps
175 ;r1 ... address to input, every byte is a new input
176 ; includes pc implicitly
177 ;r2 ... address to program start
178 ;r3 ... address of instruction table
179 ;r4 ... gets loaded with instr. prog. addr.
181 ;r9 ... address to actual entry in defer table
182 ;r10... address to defer table
183 ;r13 .. programmer address
185 ;load address of program
186 ldil r14, prog_mul@lo
187 ldih r14, prog_mul@hi
189 ldil r15, prog_consts@lo
190 ldih r15, prog_consts@hi
192 ;backup defer table address
198 ;increment input address
201 ;store address of next instruction in table
203 ;increment instr. table
208 ;we need to multiply input by 4 to get correct address offset
210 ;calc position in jumptable
211 ldw r0, jumptable(r0)
216 ;load address of program
219 ;program instruction (2)
226 ;now it is time to clear up the defer table
230 ;load branch template
233 ;if actual and base are equal, no entry
239 ;load pointer to where to jump to
241 ;load where to jump to
243 ;load where to save from defer table
249 ;set the upper 16 bit 0
251 ;shift to the position of imm in br
266 ;program instruction (14)
300 ;load address of program
304 ;program instruction (5)
318 ;load address of program
322 ;program instruction (5)
335 ;case 0 1 2 3 4 5 6 7 8 9
338 ;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
364 ;load address of program
365 ldil r4, prog_lessthan@lo
366 ldih r4, prog_lessthan@hi
368 ;program instruction (6)
389 ;program instruction (3)
401 ;the following instructions calculate the immediate
423 ;now we will generate ldih/l which will store this
424 ;immediate into a register
426 ;load address of program
461 ;gespeicherte instrs sollten input indepentent sein
463 ;fuer forward jumps muss deferrer table gemacht werden *puke*
465 ;load address of program
474 ;program instruction (2)
479 ;we add the offset to this instruction
483 ;we know calculate the jump destination
484 ;set r6 to 0 (to clear upper bytes)
488 ;compare input with neg. max of 8 bit
494 ;generate negativ offset
496 ;r6 is now the 'real' negativ number
498 ;todo: testing showed (at least once) we are off by 2 instr.
500 ;multiply by to get the offset
502 ;generate address in table
504 ;r0 now has the target address
509 ;we shift 2 bits out, because rel. br takes instr.
510 ;count and not address amount ...
512 ;set the upper 16 bit 0
514 ;shift to the position of imm in br
528 ;we know save the address in the instrtable where the addr to jump to stands
529 ;the value doesn't exists at the moment, but it will at evaluation
531 ;save position to save the instr into defer table
534 ;we need one instruction to have the correct offset (?)
537 ;todo: check if -1 is needed
539 ;multiply with 2 to get offset right
543 ;save the address to defer table
545 ;increment defer table address
554 ;load address of program
558 ;program instruction (1)
570 ;load address of program
574 ;program instruction (4)
590 ;load address of program
594 ;program instruction (3)
608 .fill 41, vm_default/4
614 .fill 1, vm_default/4
618 .fill 2, vm_default/4
620 .fill 10, vm_consts/4
622 .fill 2, vm_default/4
624 .fill 1, vm_lessthan/4
626 .fill 7, vm_default/4
630 .fill 4, vm_default/4
636 .fill 5, vm_default/4
640 .fill 7, vm_default/4
644 .fill 37, vm_default/4
648 .fill 129, vm_default/4
650 ;we assume not more than 3 entries