Download Appendix 4 Alecsis assembler .PDF
2366945 Downloads
6.50 MB .pdf
Assembler instructions Most of instructions for virtual processor have more than one version. This makes a program more effective, especially in the case of mathematical functions, which are used often in modelling of analogue circuits. t op1, op2 op1 += op2 %d0 = op1 << op2 %d0 = op1 <<= op2 %d0 = op1 & op2 %d0 = op1 &= op2 %d0 = op1 ~& op2 %d0 = op1 ~| op2 %d0 = ~op %d0 = op1 | op2 %d0 = op1 |= op2 l b, b, b, b, b, b, b, b, b, l l l l l l l l l Appendix 4. Since Alecsis does not have a multipassage optimizer (besides the peephole optimizer, which does not deal with the code as a whole but only with 2-3 neighbouring instructions), there is always room for a shorter and more efficient code written in assembler. That is an internal table containing the base addresses off all regions the potential operands can come from. l indx, offset %d0=putchar (op) %d0 = fputc (op1, op2) %d0 = getchar() %d0 = fgetc (op) %d0 = strcpy(op1, op2) %d0 = strcmp(op1, op2) %d0 = strlen(op) %d0 = malloc (op) %d0 = calloc (op1, op2) free (op) l l l l l l l l l / l slen slen. l l, d d d d d d d d d d d d d d d d d d Appendix 4. When using temporary registers (%dn) you can cross over limit of 64 bytes. 64 bytes) %sn - local static memory %_id - identifier id (name with external linking) (%an) - content of memory pointed to by the address register (dereferencing) %bn - register pointing to resource vector %en - memory of the n-th element (if it has parameters) %nn - memory of the value of the signal at the position n (in processes) in the current time instant The last two operands can appear in processes only, since they refer to object that can be declared only in modules. l z, %d0 } } test (int i, int j) { int k; asm { add. Virtual processor supports the following resource mnemonics (mnemonic always goes after the character '%'). l %d12, %v4 // placing variable j into the next one jsr %d8, _test_ii //call of func. The type gives information about the number of bytes used by the instruction (sometime the meaning of the instruction, too). The previous example can be realized using combined AleC++/assembler syntax: int z; 204 Alecsis 2. Assembler instructions need to be inside asm command for compiler to accept them. l b, (%a0) which means that the instruction addr puts the address &a + sizeof(long)*(i+j) into the address register %a0. d jfn L0: unlk rts %b0, 28 %v0, 170 %v8, "\tfactor(%g)=%g\n" %v12, %v0 %v20, %v0 %v20, _factor_d %v20, %d0 %v8, 0 %b0 . Instructions of Alecsis virtual processor mnemonic syntax operation supported types add adda addr add. 3 - User’s manual int foo (int, int, double**, class Point, . This can be more than necessary sometimes, but compiler uses the safer method