27 ;assuming that no more than 42 instr are used
38 .ifill ldis r8, 0;0xed400004
39 .ifill mov r0, r7;0xe1038000
40 .ifill andx r0, 1;0xe2800008
41 .ifill adddnz r8, r8, r6;0x00443001
42 .ifill subinz r7, r7, 1;0x01bb8008
43 .ifill addizs r7, r7, 0;0x113b8000
45 .ifill adddnz r8, r8, r6;0x00443001
46 .ifill adddnz r8, r8, r6;0x00443001
47 .ifill subi r7, r7, 2;0xe1bb8010
48 .fill 0x0b7ffe83;brnz+ loop
52 .fill 0xed300004;ldis r6, CONST
58 .ifill add r7, r7, r6;0xe03bb000
64 .ifill sub r7, r7, r6;0xe0bbb000
70 .ifill cmp r7, r6;0xec3b0000
80 .ifill cmpi r6,0;0xecb00000
82 .fill 1, 0x1b000103;breq- vm_next
83 .fill 1, 0xeb000003;br+ CONST
86 .fill 1, 0xed400000;ldil r6, CONST
87 .fill 1, 0xed400002;ldih r6, CONST
101 .ifill not r6;0xe4b7fffa
106 ;set address of input
107 ldil r1, inputdata@lo
108 ldih r1, inputdata@hi
110 ;set address of program start
111 ldil r2, prog_start@lo
112 ldih r2, prog_start@hi
114 ;set address to instruction table
115 ldil r3, instrtable@lo
116 ldih r3, instrtable@hi
118 ;set address to defer table
119 ldil r9, defertable@lo
120 ldih r9, defertable@hi
126 ;set address to stack
130 ;make r15 a 0-register
132 ;make r14 a 8-bit -1-register
140 ;first version only supports backward jumps
142 ;r1 ... address to input, every byte is a new input
143 ; includes pc implicitly
144 ;r2 ... address to program start
145 ;r3 ... address of instruction table
146 ;r4 ... gets loaded with instr. prog. addr.
148 ;r9 ... address to actual entry in defer table
149 ;r10... address to defer table
151 ;load address of program
152 ldil r13, prog_dup@lo
153 ldih r13, prog_dup@hi
155 ;load address of program
156 ldil r14, prog_mul@lo
157 ldih r14, prog_mul@hi
159 ldil r15, prog_consts@lo
160 ldih r15, prog_consts@hi
162 ;backup defer table address
164 ;decrement address to input by 1
169 ;increment input address
172 ;store address of next instruction in table
174 ;increment instr. table
179 ;we need to multiply input by 4 to get correct address offset
181 ;calc position in jumptable
182 ldw r0, jumptable(r0)
187 ;load address of program
190 ;program instruction (2)
197 ;now it is time to clear up the defer table
201 ;load branch template
204 ;if actual and base are equal, no entry
210 ;load pointer to where to jump to
212 ;load where to jump to
214 ;load where to save from defer table
220 ;set the upper 16 bit 0
222 ;shift to the position of imm in br
235 ;program instruction (14)
271 ;load address of program
275 ;program instruction (5)
293 ;load address of program
297 ;program instruction (5)
312 ;case 0 1 2 3 4 5 6 7 8 9
315 ;program instruction (3)
317 ;the first instr. loads r6 with the number
318 ;thus we shall emulate this
322 ;shift 3 bits left, as the immediate in ldi has
325 ;now 'add' this to the ldi
328 ;store this 'dynamic' instruction
341 ;load address of program
342 ldil r4, prog_lessthan@lo
343 ldih r4, prog_lessthan@hi
345 ;program instruction (6)
366 ;program instruction (3)
380 ;the following instructions calculate the immediate
402 ;now we will generate ldih/l which will store this
403 ;immediate into a register
405 ;load address of program
426 ;now we program the instructions that will save the
427 ;immediate onto the stack and increment the later
443 ;gespeicherte instrs sollten input indepentent sein
445 ;fuer forward jumps muss deferrer table gemacht werden *puke*
447 ;load address of program
451 ;program instruction (2)
465 ;we add the offset to this instruction
469 ;we know calculate the jump destination
470 ;set r6 to 0 (to clear upper bytes)
474 ;compare input with neg. max of 8 bit
480 ;generate negativ offset
482 ;r6 is now the 'real' negativ number
484 ;todo: testing showed (at least once) we are off by 2 instr.
486 ;multiply by to get the offset
488 ;generate address in table
490 ;r0 now has the target address
495 ;we shift 2 bits out, because rel. br takes instr.
496 ;count and not address amount ...
498 ;set the upper 16 bit 0
500 ;shift to the position of imm in br
514 ;we know save the address in the instrtable where the addr to jump to stands
515 ;the value doesn't exists at the moment, but it will at evaluation
517 ;save position to save the instr into defer table
520 ;todo: check if -1 is needed
522 ;multiply with 2 to get offset right
526 ;save the address to defer table
528 ;increment defer table address
537 ;load address of program
541 ;program instruction (1)
553 ;load address of program
557 ;program instruction (4)
575 ;load address of program
579 ;program instruction (3)
638 .fill 129, vm_default
640 ;we assume not more than 3 entries