Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
163
 
Asm code and SSA optimization
 
If converting code from an earlier version of the compiler, which consists of mixed asm code with the Basic  
 
code, keep in mind that the generated code can substantially differ when SSA optimization option is enabled  
 
or disabled. 
 
This is due to the fact that SSA optimization uses certain working registers to store routine parameters  
 
(W10-W13), rather than storing them onto the function frame.
 
Because of this, user must be very careful when writing asm code as existing values in the working registers  
 
used by SSA optimization can be overwritten. 
 
To avoid this, it is recommended that user includes desired asm code in a separate routine.
Debugging Notes
SSA also influences the code debugging in such a way that the local variables will be available in the Watch Window 
only in those parts of the procedure where they have useful value (eg. on entering the procedure, variable isn’t available 
until its definition). 
Variables can be allocated in one part of the procedure in register W4, and in another part of the procedure in register 
W2, if the optimizer estimates that it is better that way. That means that the local variable has no static address.
Warning Messages Enhancement
Besides the smaller code, SSA also deals with the intensive code analysis, which in turn has the consequence in 
enhancing the warning messages. 
For example, compiler will warn the user that the uninitialized variable is used:
sub procedure SSA_Test()
dim y as char
  if (y) then    ‘ Variable y might not have been initialized
    asm 
      nop
    end asm
  end if
   
end sub
main:
  SSA_Test()
end.
Related topics: Code Optimization, dsPIC Specifics, mikroBasic PRO for dsPIC30/33 and PIC24 specifics, Memory 
type specifiers