1 #define PROGINSTR stw r0, PDATA(r13)
28 ;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
53 .fill 0xed300004;ldis r6, CONST
59 .ifill add r7, r7, r6;0xe03bb000
65 .ifill sub r7, r7, r6;0xe0bbb000
71 .ifill cmp r7, r6;0xec3b0000
81 .ifill cmpi r6,0;0xecb00000
83 .fill 1, 0x1b000103;breq- vm_next
84 .fill 1, 0xeb000003;br+ CONST
87 .fill 1, 0xed400000;ldil r6, CONST
88 .fill 1, 0xed400002;ldih r6, CONST
102 .ifill not r6;0xe4b7fffa
106 .define UART_BASE, 0x2000
107 .define UART_STATUS, 0x0
108 .define UART_RECV, 0xc
109 .define UART_TRANS, 0x8
111 .define UART_TRANS_EMPTY, 0x1
112 .define UART_RECV_NEW, 0x2
114 .define PBASE, 0x2030
121 ldi r10, UART_BASE@lo
122 ldih r10, UART_BASE@hi
125 ldw r3, UART_STATUS(r10)
126 andx r3, UART_RECV_NEW
127 brzs+ u_recv_byte; branch if zero
129 ldw r0, UART_RECV(r10)
132 ;set address of input
133 ldil r1, inputdata@lo
134 ldih r1, inputdata@hi
136 ;set address of program start
137 ldil r2, prog_start@lo
138 ldih r2, prog_start@hi
140 ;set address to instruction table
141 ldil r3, instrtable@lo
142 ldih r3, instrtable@hi
144 ;set address to defer table
145 ldil r9, defertable@lo
146 ldih r9, defertable@hi
151 ;set programmer address
158 ;set address to stack
162 ;make r15 a 0-register
164 ;make r14 a 8-bit -1-register
172 ldi r10, UART_BASE@lo
173 ldih r10, UART_BASE@hi
174 ldw r9, UART_STATUS(r10)
175 andx r9, UART_TRANS_EMPTY
176 brnz+ u_send_byte ; branch if not zero
177 stb r0, UART_TRANS(r10)
182 ;first version only supports backward jumps
184 ;r1 ... address to input, every byte is a new input
185 ; includes pc implicitly
186 ;r2 ... address to program start
187 ;r3 ... address of instruction table
188 ;r4 ... gets loaded with instr. prog. addr.
190 ;r9 ... address to actual entry in defer table
191 ;r10... address to defer table
192 ;r13 .. programmer address
194 ;load address of program
195 ldil r14, prog_mul@lo
196 ldih r14, prog_mul@hi
198 ldil r15, prog_consts@lo
199 ldih r15, prog_consts@hi
201 ;backup defer table address
203 ;decrement address to input by 1
208 ;increment input address
211 ;store address of next instruction in table
213 ;increment instr. table
218 ;we need to multiply input by 4 to get correct address offset
220 ;calc position in jumptable
221 ldw r0, jumptable(r0)
226 ;load address of program
229 ;program instruction (2)
236 ;now it is time to clear up the defer table
240 ;load branch template
243 ;if actual and base are equal, no entry
249 ;load pointer to where to jump to
251 ;load where to jump to
253 ;load where to save from defer table
259 ;set the upper 16 bit 0
261 ;shift to the position of imm in br
276 ;program instruction (14)
312 ;load address of program
316 ;program instruction (5)
334 ;load address of program
338 ;program instruction (5)
353 ;case 0 1 2 3 4 5 6 7 8 9
356 ;program instruction (3)
358 ;the first instr. loads r6 with the number
359 ;thus we shall emulate this
363 ;shift 3 bits left, as the immediate in ldi has
366 ;now 'add' this to the ldi
369 ;store this 'dynamic' instruction
382 ;load address of program
383 ldil r4, prog_lessthan@lo
384 ldih r4, prog_lessthan@hi
386 ;program instruction (6)
409 ;program instruction (3)
423 ;the following instructions calculate the immediate
445 ;now we will generate ldih/l which will store this
446 ;immediate into a register
448 ;load address of program
469 ;now we program the instructions that will save the
470 ;immediate onto the stack and increment the later
486 ;gespeicherte instrs sollten input indepentent sein
488 ;fuer forward jumps muss deferrer table gemacht werden *puke*
490 ;load address of program
494 ;program instruction (2)
509 ;we add the offset to this instruction
513 ;we know calculate the jump destination
514 ;set r6 to 0 (to clear upper bytes)
518 ;compare input with neg. max of 8 bit
524 ;generate negativ offset
526 ;r6 is now the 'real' negativ number
528 ;todo: testing showed (at least once) we are off by 2 instr.
530 ;multiply by to get the offset
532 ;generate address in table
534 ;r0 now has the target address
539 ;we shift 2 bits out, because rel. br takes instr.
540 ;count and not address amount ...
542 ;set the upper 16 bit 0
544 ;shift to the position of imm in br
558 ;we know save the address in the instrtable where the addr to jump to stands
559 ;the value doesn't exists at the moment, but it will at evaluation
561 ;save position to save the instr into defer table
564 ;we need one instruction to have the correct offset (?)
567 ;todo: check if -1 is needed
569 ;multiply with 2 to get offset right
573 ;save the address to defer table
575 ;increment defer table address
584 ;load address of program
588 ;program instruction (1)
600 ;load address of program
604 ;program instruction (4)
622 ;load address of program
626 ;program instruction (3)
685 .fill 129, vm_default
687 ;we assume not more than 3 entries