Some optimisation stratergies involve the generation of partial results in the destination location. This can have serious side effects if the destination location is a hardware port or is being monitored or otherwise used by an interrupt service routine.
To prevent such side effects ports and RAM mailboxes should be declared as port locations. This is done by declaring the port within a .port section.
e.g. .sect my_section .port var1 .db 0 var2 .dw 0The following examples show how code is generated with and without destination optimisation
WITH DESTINATION OPTIMISATION
.sect bert_data_sect .data 0010 .org 16 0010 00 01 A .dw 1 0012 00 01 B .dw 1 0014 00 01 E .dw 1 ;---------------------- .sect bert_code_sect .code 0000 .org 0 ;;; E = A + B 0000 08 11 movf A+1,w 0001 00 95 movwf E+1 0002 08 10 movf A,w 0003 07 12 addwf B,w 0004 00 94 movwf E 0005 18 03 btfsc STATUS,C 0006 0A 95 incf E+1 0007 08 13 movf B+1,w 0008 07 95 addwf E+1WITHOUT DESTINATION OPTIMISATION
.sect bert_data_sect .port 0010 .org 16 0010 00 01 A .dw 1 0012 00 01 B .dw 1 0014 00 01 E .dw 1 ;---------------------- .sect bert_code_sect .code 0000 .org 0 ;;; E = A + B 0000 08 11 movf A+1,w 0001 00 81 movwf wacc_1+1 0002 08 10 movf A,w 0003 07 12 addwf B,w 0004 00 80 movwf wacc_1 0005 18 03 btfsc STATUS,C 0006 0A 81 incf wacc_1+1 0007 08 13 movf B+1,w 0008 07 81 addwf wacc_1+1 0009 08 00 movf wacc_1,w 000A 00 94 movwf E 000B 08 01 movf wacc_1+1,w 000C 00 95 movwf E+1