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
54 .fill 0xed300004;ldis r6, CONST
60 .ifill add r7, r7, r6;0xe03bb000
66 .ifill sub r7, r7, r6;0xe0bbb000
72 .ifill cmp r7, r6;0xec3b0000
82 .ifill cmpi r6,0;0xecb00000
84 .fill 1, 0x1b000103;breq- vm_next
85 .fill 1, 0xeb000003;br+ CONST
88 .fill 1, 0xed400000;ldil r6, CONST
89 .fill 1, 0xed400002;ldih r6, CONST
103 .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
163 ;first version only supports backward jumps
165 ;r1 ... address to input, every byte is a new input
166 ; includes pc implicitly
167 ;r2 ... address to program start
168 ;r3 ... address of instruction table
169 ;r4 ... gets loaded with instr. prog. addr.
171 ;r9 ... address to actual entry in defer table
172 ;r10... address to defer table
173 ;r13 .. programmer address
175 ;load address of program
176 ldil r14, prog_mul@lo
177 ldih r14, prog_mul@hi
179 ldil r15, prog_consts@lo
180 ldih r15, prog_consts@hi
182 ;backup defer table address
184 ;decrement address to input by 1
189 ;increment input address
192 ;store address of next instruction in table
194 ;increment instr. table
199 ;we need to multiply input by 4 to get correct address offset
201 ;calc position in jumptable
202 ldw r0, jumptable(r0)
207 ;load address of program
210 ;program instruction (2)
217 ;now it is time to clear up the defer table
221 ;load branch template
224 ;if actual and base are equal, no entry
230 ;load pointer to where to jump to
232 ;load where to jump to
234 ;load where to save from defer table
240 ;set the upper 16 bit 0
242 ;shift to the position of imm in br
257 ;program instruction (14)
293 ;load address of program
297 ;program instruction (5)
315 ;load address of program
319 ;program instruction (5)
334 ;case 0 1 2 3 4 5 6 7 8 9
337 ;program instruction (3)
339 ;the first instr. loads r6 with the number
340 ;thus we shall emulate this
344 ;shift 3 bits left, as the immediate in ldi has
347 ;now 'add' this to the ldi
350 ;store this 'dynamic' instruction
363 ;load address of program
364 ldil r4, prog_lessthan@lo
365 ldih r4, prog_lessthan@hi
367 ;program instruction (6)
390 ;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
450 ;now we program the instructions that will save the
451 ;immediate onto the stack and increment the later
467 ;gespeicherte instrs sollten input indepentent sein
469 ;fuer forward jumps muss deferrer table gemacht werden *puke*
471 ;load address of program
475 ;program instruction (2)
490 ;we add the offset to this instruction
494 ;we know calculate the jump destination
495 ;set r6 to 0 (to clear upper bytes)
499 ;compare input with neg. max of 8 bit
505 ;generate negativ offset
507 ;r6 is now the 'real' negativ number
509 ;todo: testing showed (at least once) we are off by 2 instr.
511 ;multiply by to get the offset
513 ;generate address in table
515 ;r0 now has the target address
520 ;we shift 2 bits out, because rel. br takes instr.
521 ;count and not address amount ...
523 ;set the upper 16 bit 0
525 ;shift to the position of imm in br
539 ;we know save the address in the instrtable where the addr to jump to stands
540 ;the value doesn't exists at the moment, but it will at evaluation
542 ;save position to save the instr into defer table
545 ;we need one instruction to have the correct offset (?)
548 ;todo: check if -1 is needed
550 ;multiply with 2 to get offset right
554 ;save the address to defer table
556 ;increment defer table address
565 ;load address of program
569 ;program instruction (1)
581 ;load address of program
585 ;program instruction (4)
603 ;load address of program
607 ;program instruction (3)
625 .fill 41, vm_default/4
631 .fill 1, vm_default/4
635 .fill 2, vm_default/4
637 .fill 10, vm_consts/4
639 .fill 2, vm_default/4
641 .fill 1, vm_lessthan/4
643 .fill 7, vm_default/4
647 .fill 4, vm_default/4
653 .fill 5, vm_default/4
657 .fill 7, vm_default/4
661 .fill 37, vm_default/4
665 .fill 129, vm_default/4
667 ;we assume not more than 3 entries