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
127 ;set address of input
128 ldis r1, inputdata@lo
129 ldih r1, inputdata@hi
131 ;set address of program start
132 ldis r2, (prog_start/4)@lo
133 ldih r2, (prog_start/4)@hi
135 ;set address to instruction table
136 ldis r3, instrtable@lo
137 ldih r3, instrtable@hi
139 ;set address to defer table
140 ldis r9, defertable@lo
141 ldih r9, defertable@hi
146 ;set programmer address
152 ;set address to stack
156 ;make r15 a 0-register
158 ;make r14 a 8-bit -1-register
169 subi r0, r0, 0xd ; offset abziehen
186 ;first version only supports backward jumps
188 ;r1 ... address to input, every byte is a new input
189 ; includes pc implicitly
190 ;r2 ... address to program start
191 ;r3 ... address of instruction table
192 ;r4 ... gets loaded with instr. prog. addr.
194 ;r9 ... address to actual entry in defer table
195 ;r10... address to defer table
196 ;r13 .. programmer address
198 ;load address of program
199 ldil r14, prog_mul@lo
200 ldih r14, prog_mul@hi
202 ldil r15, prog_consts@lo
203 ldih r15, prog_consts@hi
205 ;backup defer table address
207 ;decrement address to input by 1
212 ;increment input address
215 ;store address of next instruction in table
217 ;increment instr. table
222 ;we need to multiply input by 4 to get correct address offset
224 ;calc position in jumptable
225 ldw r0, jumptable(r0)
230 ;load address of program
233 ;program instruction (2)
240 ;now it is time to clear up the defer table
244 ;load branch template
247 ;if actual and base are equal, no entry
253 ;load pointer to where to jump to
255 ;load where to jump to
257 ;load where to save from defer table
263 ;set the upper 16 bit 0
265 ;shift to the position of imm in br
280 ;program instruction (14)
316 ;load address of program
320 ;program instruction (5)
338 ;load address of program
342 ;program instruction (5)
357 ;case 0 1 2 3 4 5 6 7 8 9
360 ;program instruction (3)
362 ;the first instr. loads r6 with the number
363 ;thus we shall emulate this
367 ;shift 3 bits left, as the immediate in ldi has
370 ;now 'add' this to the ldi
373 ;store this 'dynamic' instruction
386 ;load address of program
387 ldil r4, prog_lessthan@lo
388 ldih r4, prog_lessthan@hi
390 ;program instruction (6)
413 ;program instruction (3)
427 ;the following instructions calculate the immediate
449 ;now we will generate ldih/l which will store this
450 ;immediate into a register
452 ;load address of program
473 ;now we program the instructions that will save the
474 ;immediate onto the stack and increment the later
490 ;gespeicherte instrs sollten input indepentent sein
492 ;fuer forward jumps muss deferrer table gemacht werden *puke*
494 ;load address of program
498 ;program instruction (2)
513 ;we add the offset to this instruction
517 ;we know calculate the jump destination
518 ;set r6 to 0 (to clear upper bytes)
522 ;compare input with neg. max of 8 bit
528 ;generate negativ offset
530 ;r6 is now the 'real' negativ number
532 ;todo: testing showed (at least once) we are off by 2 instr.
534 ;multiply by to get the offset
536 ;generate address in table
538 ;r0 now has the target address
543 ;we shift 2 bits out, because rel. br takes instr.
544 ;count and not address amount ...
546 ;set the upper 16 bit 0
548 ;shift to the position of imm in br
562 ;we know save the address in the instrtable where the addr to jump to stands
563 ;the value doesn't exists at the moment, but it will at evaluation
565 ;save position to save the instr into defer table
568 ;we need one instruction to have the correct offset (?)
571 ;todo: check if -1 is needed
573 ;multiply with 2 to get offset right
577 ;save the address to defer table
579 ;increment defer table address
588 ;load address of program
592 ;program instruction (1)
604 ;load address of program
608 ;program instruction (4)
626 ;load address of program
630 ;program instruction (3)
648 .fill 41, vm_default/4
654 .fill 1, vm_default/4
658 .fill 2, vm_default/4
660 .fill 10, vm_consts/4
662 .fill 2, vm_default/4
664 .fill 1, vm_lessthan/4
666 .fill 7, vm_default/4
670 .fill 4, vm_default/4
676 .fill 5, vm_default/4
680 .fill 7, vm_default/4
684 .fill 37, vm_default/4
688 .fill 129, vm_default/4
690 ;we assume not more than 3 entries