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 r6, r7, r6;0xe0bbb000
66 .ifill cmp r7, r6;0xec3b0000
74 .ifill cmpi r6,0;0xecb00000
77 .fill 1, 0x1b000103;breq- vm_next
78 .fill 1, 0xeb000003;br+ CONST
82 .fill 1, 0xed400000;ldil r6, CONST
83 .fill 1, 0xed400002;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, 0xd ; 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
197 ;decrement address to input by 1
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)
230 ;now it is time to clear up the defer table
234 ;load branch template
237 ;if actual and base are equal, no entry
243 ;load pointer to where to jump to
245 ;load where to jump to
247 ;load where to save from defer table
253 ;set the upper 16 bit 0
255 ;shift to the position of imm in br
270 ;program instruction (14)
304 ;load address of program
308 ;program instruction (5)
322 ;load address of program
326 ;program instruction (5)
337 ;case 0 1 2 3 4 5 6 7 8 9
340 ;program instruction (3)
344 ;the first instr. loads r6 with the number
345 ;thus we shall emulate this
349 ;shift 3 bits left, as the immediate in ldi has
352 ;now 'add' this to the ldi
355 ;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)
391 ;program instruction (3)
403 ;the following instructions calculate the immediate
425 ;now we will generate ldih/l which will store this
426 ;immediate into a register
428 ;load address of program
463 ;gespeicherte instrs sollten input indepentent sein
465 ;fuer forward jumps muss deferrer table gemacht werden *puke*
467 ;load address of program
476 ;program instruction (2)
486 ;we add the offset to this instruction
490 ;we know calculate the jump destination
491 ;set r6 to 0 (to clear upper bytes)
495 ;compare input with neg. max of 8 bit
501 ;generate negativ offset
503 ;r6 is now the 'real' negativ number
505 ;todo: testing showed (at least once) we are off by 2 instr.
507 ;multiply by to get the offset
509 ;generate address in table
511 ;r0 now has the target address
516 ;we shift 2 bits out, because rel. br takes instr.
517 ;count and not address amount ...
519 ;set the upper 16 bit 0
521 ;shift to the position of imm in br
535 ;we know save the address in the instrtable where the addr to jump to stands
536 ;the value doesn't exists at the moment, but it will at evaluation
538 ;save position to save the instr into defer table
541 ;we need one instruction to have the correct offset (?)
544 ;todo: check if -1 is needed
546 ;multiply with 2 to get offset right
550 ;save the address to defer table
552 ;increment defer table address
561 ;load address of program
565 ;program instruction (1)
577 ;load address of program
581 ;program instruction (4)
597 ;load address of program
601 ;program instruction (3)
615 .fill 41, vm_default/4
621 .fill 1, vm_default/4
625 .fill 2, vm_default/4
627 .fill 10, vm_consts/4
629 .fill 2, vm_default/4
631 .fill 1, vm_lessthan/4
633 .fill 7, vm_default/4
637 .fill 4, vm_default/4
643 .fill 5, vm_default/4
647 .fill 7, vm_default/4
651 .fill 37, vm_default/4
655 .fill 129, vm_default/4
657 ;we assume not more than 3 entries