Autor Tema: OPTIMISER_LEVEL = 6 ???  (Leído 2731 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado beto0350

  • PIC12
  • **
  • Mensajes: 58
OPTIMISER_LEVEL = 6 ???
« en: 17 de Abril de 2008, 07:14:01 »
Hola:
     alguien podria decirme de donde obtener informacion sobre OPTIMISER_LEVEL = 6 en PROTON BASIC u otro nivel, ya se que es para que optimese el programa segun las paginas, pero compilando el mismo programa en un momento funciona bien y si le agrego o quito sentencias del programa (no Dim o Symbol) me dice que tiene problemas entre el banco 0 y 1 , pero no agrege ninguna sentencia dim o symbol, por lo cual quiero saber si hay otro valor de la funcion OPTIMISER_LEVEL para colocar y que sea efectivo.

 Gracias

Desconectado electronando

  • Colaborador
  • PIC18
  • *****
  • Mensajes: 427
Re: OPTIMISER_LEVEL = 6 ???
« Respuesta #1 en: 19 de Abril de 2008, 00:15:42 »
es solo para ahorrarte codigo de programa pero al usar el optimizer en un programa extenso tuve problemas , asi que no lo uso esta funcion creo te da problemas cuando tu programa es extenso y estas trabajando con dos o mas bancos , te recomiendo q no lo uses a menos q encuentres un abuena documentacion , la cual hasta ahora no e encontrado ni en el manual :mrgreen:

Desconectado raraavis

  • PIC10
  • *
  • Mensajes: 47
Re: OPTIMISER_LEVEL = 6 ???
« Respuesta #2 en: 10 de Junio de 2008, 22:28:22 »
Esto es lo que dice la Ayuda de Proton:

Citar
The underlying assembler code produced by the compiler is the single most important element to a good language, because compact assembler not only means more can be squeezed into the tight confines of the PICmicro, but also the code runs faster which allows more complex operations to be performed. And even though the compiler already produces good underlying assembler mnemonics, there is always room for improvement and that improvement is achieved by a separate optimising pass.
The optimiser is enabled by issuing the DECLARE: -

OPTIMISER_LEVEL = n

Where n is the level of optimisation required.

The DECLARE should be placed at the top of the BASIC program, but anywhere in the code is actually acceptable because once the optimiser is enabled it cannot be disabled later in the same program.

As of version 3.1 of the compiler, the optimiser has 6 levels, 7 if you include OFF as a level.

Level 0 disables the optimiser.
Level 1 Chooses the appropriate branching mnemonics when using a 16-bit core (18F) device, and actively chooses the appropriate page switching mnemonics when using a 14-bit core (16F) device.

This is the single most important optimising pass for larger PICmicrotm devices, especially 14-bit core (16F) types because page switching is a very code hungry operation. For 16-bit core (18F) types it will replace CALL with RCALL and GOTO with BRA whenever appropriate, saving 1 byte of code space every time.

Level 2 Re-arranges some branching operations on both 14 and 16-bit core devices. Again, this is an important optimising pass because a single program can implement many decision making mnemonics.
Level 3 Removes consecutive CALL, RETURN mnemonics and replaces them with a single GOTO mnemonic.
Level 4 Looks for a MOVF VAR,W mnemonic followed by a MOVWF VAR mnemonic, each using the same variable or register. If found, the MOVWF VAR mnemonic is removed because both the WREG and the variable are already loaded and the following mnemonic is not required.

This sequence of mnemonics is not common in programs, but does happen from time to time. Therefore level 4 optimisation may not show any decrease in code size.

Level 5 Looks for a MOVWF VAR,W mnemonic followed by a MOVF VAR,W mnemonic, each using the same variable or register. If found, the MOVF VAR,W mnemonic is removed because both the WREG and the variable are already loaded and the following mnemonic is not required.

As with level 4, this sequence of mnemonics is not common in programs, but does happen from time to time. Therefore level 5 optimisation may not show any decrease in code size.

Level 6 Looks for an ANDLW CONSTANT mnemonic followed by another ANDLW CONSTANT mnemonic. If found, the first ANDLW CONSTANT mnemonic is removed because the second mnemonic will override the first anyway.

As with level 4 and 5, this sequence of mnemonics is not common in programs, very rare in fact, but does happen from time to time. Therefore level 6 optimisation may not show any decrease in code size.

Each optimiser level uses the previous one, so level 3 implements level 1 and level 2 as well as level 3.

You must be aware that optimising code, especially paged code found in the larger 14-bit core (16F) devices can, in some circumstances, have a detrimental effect on a program if it misses a page boundary, this is true of all optimisation on all compilers and is something that you should take into account.

Always try to write and test your program without the optimiser pass. Then once it’s working as expected, enable the optimiser a level at a time. However, this is not always possible with larger programs that will not fit within the PICmicrotm without optimisation. In this circumstance, choose level 1 optimisation whenever the code is reaching the limits of the PICmicro, testing the code as you go along.

Caveats
Of course there’s no such thing as a free lunch, and there are some features that cannot be used when implementing the optimiser.

The main one is that the optimiser is not supported with 12-bit core devices.

Also, the ORG directive is not allowed with 14-bit core (16F) devices when using the optimiser, but can be used with 16-bit core (18F) devices.

When using 16-bit core devices, do not use the MOVFW macro as this will cause problems withing the ASM listing, use the correct mnemonic of MOVF VAR , W.

On all devices, do not use the assembler LIST and NOLIST directives, as the optimiser uses these to sculpt the final ASM used.

Consejo:  :mrgreen:
Si podes..No optimices
Si necesitas hacerlo por problemas de espacio, anda optimizando de a uno y probando que funcione Bien el programa.

Suerte!      :lol: