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, 0x1b000103;breq- vm_next
79 .fill 1, 0xeb000003;br+ CONST
83 .fill 1, 0xed400000;ldil r6, CONST
84 .fill 1, 0xed400002;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, 0xd ; 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
198 ;decrement address to input by 1
203 ;increment input address
206 ;store address of next instruction in table
208 ;increment instr. table
213 ;we need to multiply input by 4 to get correct address offset
215 ;calc position in jumptable
216 ldw r0, jumptable(r0)
221 ;load address of program
224 ;program instruction (2)
231 ;now it is time to clear up the defer table
235 ;load branch template
238 ;if actual and base are equal, no entry
244 ;load pointer to where to jump to
246 ;load where to jump to
248 ;load where to save from defer table
254 ;set the upper 16 bit 0
256 ;shift to the position of imm in br
271 ;program instruction (14)
305 ;load address of program
309 ;program instruction (5)
323 ;load address of program
327 ;program instruction (5)
340 ;case 0 1 2 3 4 5 6 7 8 9
343 ;program instruction (3)
347 ;the first instr. loads r6 with the number
348 ;thus we shall emulate this
352 ;shift 3 bits left, as the immediate in ldi has
355 ;now 'add' this to the ldi
358 ;store this 'dynamic' instruction
369 ;load address of program
370 ldil r4, prog_lessthan@lo
371 ldih r4, prog_lessthan@hi
373 ;program instruction (6)
394 ;program instruction (3)
406 ;the following instructions calculate the immediate
428 ;now we will generate ldih/l which will store this
429 ;immediate into a register
431 ;load address of program
466 ;gespeicherte instrs sollten input indepentent sein
468 ;fuer forward jumps muss deferrer table gemacht werden *puke*
470 ;load address of program
479 ;program instruction (2)
489 ;we add the offset to this instruction
493 ;we know calculate the jump destination
494 ;set r6 to 0 (to clear upper bytes)
498 ;compare input with neg. max of 8 bit
504 ;generate negativ offset
506 ;r6 is now the 'real' negativ number
508 ;todo: testing showed (at least once) we are off by 2 instr.
510 ;multiply by to get the offset
512 ;generate address in table
514 ;r0 now has the target address
519 ;we shift 2 bits out, because rel. br takes instr.
520 ;count and not address amount ...
522 ;set the upper 16 bit 0
524 ;shift to the position of imm in br
538 ;we know save the address in the instrtable where the addr to jump to stands
539 ;the value doesn't exists at the moment, but it will at evaluation
541 ;save position to save the instr into defer table
544 ;we need one instruction to have the correct offset (?)
547 ;todo: check if -1 is needed
549 ;multiply with 2 to get offset right
553 ;save the address to defer table
555 ;increment defer table address
564 ;load address of program
568 ;program instruction (1)
580 ;load address of program
584 ;program instruction (4)
600 ;load address of program
604 ;program instruction (3)
618 .fill 41, vm_default/4
624 .fill 1, vm_default/4
628 .fill 2, vm_default/4
630 .fill 10, vm_consts/4
632 .fill 2, vm_default/4
634 .fill 1, vm_lessthan/4
636 .fill 7, vm_default/4
640 .fill 4, vm_default/4
646 .fill 5, vm_default/4
650 .fill 7, vm_default/4
654 .fill 37, vm_default/4
658 .fill 129, vm_default/4
660 ;we assume not more than 3 entries