4.9.2 Asmopt Directive
The ASMOPT action
directive selectively controls
the assembler optimizer when processing assembly code. The allowable actions are shown in
Table 4-7.
Action | Purpose |
---|---|
off |
Disables the assembler optimizer for subsequent code. |
on |
Enables the assembler optimizer for subsequent code. |
pop |
Retrieves the state of the assembler optimization setting. |
push |
Saves the state of the assembler optimization setting. |
No code is modified after an ASMOPT off
directive. Following an
ASMOPT on
directive, the assembler will perform allowable
optimizations.
The ASMOPT push
and ASMOPT pop
directives allow the state of the assembler optimizer to be saved onto a stack of states
and then restored at a later time. They are useful when you need to ensure the optimizers
are disabled for a small section of code, but you do not know if the optimizers have
previously been disabled.
ASMOPT PUSH ;store the state of the assembler optimizers
ASMOPT OFF ;optimizations must be off for this sequence
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
ASMOPT POP ;restore state of the optimizers
Note that no optimizations are performed by the MPLAB XC8 PIC Assembler and these controls will be ignored.