Mikroelektronika MIKROE-724 データシート
162
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
0x0102 0x320001 BRA Z L__SSA_Test2
L__SSA_Test6:
;Example.mbas,31 :: nop
0x0104 0x000000 NOP
Without SSA enabled, sub procedure
SSA_Test
this example is consisted of 5 asm instructions :
;Example.mbas,29 :: if (y+k) then
0x0102 0x97B8CE MOV [W14-8], W1
0x0104 0x57006A SUB W14, #10, W0
0x0106 0x408010 ADD W1, [W0], W0
0x0108 0x320001 BRA Z L__SSA_Test2
L__SSA_Test6:
;Example.mbas,31 :: nop
0x010A 0x000000 NOP
Proper Coding Recommendations
To get the maximum out of the SSA, user should regard the following rules during the coding process:
- Routines should not contain too many parameters (not more than 4 words).
- Don’t change the value of the parameter in the function body (it is better to use a new local variable).
- If the
function1
parameters are passed as
function2
parameters, then parameter order should remain
the same:
sub procedure f2(dim a as integer, dim b as integer)
end sub
sub procedure f1(dim x as integer, dim y as integer)
‘ routine call
f2(x,y) ‘ x->a and y->b (1 to 1 and 2 to 2) is far more efficient than:
f2(y,x) ‘ y->a and x->b (1 to 2 and 2 to 1)
end sub
- Large amount of nested loops and complex structures as its members should be avoided.
- When writing a code in assembly, keep in mind that there are registers reserved exclusively for routine
parameters.
- Using
goto
and
label
statements in nested loops should be avoided.
- Obtaining address of the local variable with the global pointer and using it to alter the variable’s address
should be avoided.
Note:
-
mcl
files compiled with or without SSA enabled are fully compatible and can be used and mixed without
any restrictions, except pointers to functions.
- Functions, functions declarations and pointers that may point to these functions must be compiled with the
same option, either SSA enabled or disabled. If this is not the case, compiler will report an error.