SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 2.9.7 #5679 (Feb 8 2010) (MINGW32)
When using the pic18f4620 target (only one tried) a series of (uint8_t) "variable = 0xff" will somtimes not be converted to "setf _variable" in the assembler output
or sometimes a hanging "movlw oxff" will be generated if you use the --denable-peep then all but one of the series of " setf variable"/ "movlw 0xff , movf variable" will be commented out except maybe the last one --- I shave seen all these different types of behaviour ---
this used to work perfectly fine. i am not sure when it broke This WORKED
$ sdcc -v
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.1 #5471 (Jun 30 2009) (MINGW32)
This
; .line 26; ../main.c packet1.payload->chunk[0] =0x0 ;
MOVFF _packet1, r0x00
MOVFF (_packet1 + 1), r0x01
MOVFF r0x00, FSR0L
MOVFF r0x01, FSR0H
CLRF INDF0
; .line 27; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVLW 0xff
; .line 28; ../main.c PREINC0 =0xff;
MOVLW 0xff
; # MOVWF _PREINC0
; # MOVWF _PREINC0
; .line 29; ../main.c PREINC0 =0xff;
SETF _PREINC0
; .line 30; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; .line 31; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVWF _PREINC0
; .line 33; ../main.c PREINC0 =0xff;
SETF _PREINC0
; .line 34; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; .line 35; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVWF _PREINC0
; .line 37; ../main.c PREINC0 =0xff;
SETF _PREINC0
; .line 38; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; .line 39; ../main.c PREINC0 =0x0;
CLRF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVLW 0xff
; # MOVWF _PREINC0
; # MOVWF _PREINC0
; #; info ==> [localregs] exit begin
; .line 41; ../main.c PREINC0 =0xff;
SETF _PREINC0
MOVFF PREINC1, r0x01
MOVFF PREINC1, r0x00
RETURN
came from this
packet1.payload->chunk[0] =0x0 ;
PREINC0 =0x0;
PREINC0 =0xff;
PREINC0 =0xff;
PREINC0 =0x0;
PREINC0 =0x0;
PREINC0 =0xff;
PREINC0 =0xff;
PREINC0 =0x0;
PREINC0 =0x0;
PREINC0 =0xff;
PREINC0 =0xff;
PREINC0 =0x0;
PREINC0 =0x0;
PREINC0 =0xff;
PREINC0 =0xff;
using this
OPTFLAGS := --optimize-cmp --optimize-df --obanksel=9 --denable-peeps
## --
# Each subdirectory must supply rules for building sources it contributes
%.o: ../%.c
@echo 'Building file: $<'
@echo 'Invoking: SDCC Compiler'
sdcc -mpic16 -c -Wa-C -p18f4620 -Dpic18f4620 -I"D:\sdcc\include\pic16" --model-small ${OPTFLAGS} -o"$@" "$<" && \
echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \
sdcc -mpic16 -c -Wa-C -MM -p18f4620 -Dpic18f4620 -I"D:\sdcc\include\pic16" --model-small ${OPTFLAGS} "$<" >> $(@:%.o=%.d)
@echo 'Finished building: $<'
@echo ' '
small demo eclipse project
after enabling the --optimize-df a "hanging" movlw 0xff is left behind when optimising the movlw 0xff, movwf reg to setf reg.
after enabling the --denable-peeps pic16-rule 6 is erroneously applied to a volitile register with side effects .