#2257 wrong position of banksel

open
nobody
PIC16
5
2015-01-22
2014-02-26
No

Hello

After a long debugging session i found the two following bugs (wich are probably connected).

When I assign a value from an array of structs to another variable and do some math on the same line, I get ot wrong values.

first bug

wrong value
uart_tx_buffer_LEN => 216

;    .line    87; src/modules/app_ep1_out.c    uart_tx_buffer_LEN = ep_bdt[2].Cnt-1;
    MOVFF    (_ep_bdt + 9), (_ep_bdt + 9)
    DECF    (_ep_bdt + 9), W, B
    BANKSEL    _uart_tx_buffer_LEN
    MOVWF    _uart_tx_buffer_LEN, B

oke value
uart_tx_buffer_LEN => 8

;    .line    87; src/modules/app_ep1_out.c    uart_tx_buffer_LEN = ep_bdt[2].Cnt;
    MOVFF    (_ep_bdt + 9), _uart_tx_buffer_LEN
    BANKSEL    _uart_tx_buffer_LEN
;    .line    88; src/modules/app_ep1_out.c    uart_tx_buffer_LEN--;
    DECF    _uart_tx_buffer_LEN, F, B

second bug

uart_tx_start_condition_index isn't incremented here

;   .line   329; my.c   TXREG = uart_start_condition[uart_tx_start_condition_index++];
    MOVFF   _uart_tx_start_condition_index, r0x00
    INCF    _uart_tx_start_condition_index, F, B
    CLRF    r0x01
    CLRF    r0x02
    MOVLW   LOW(_uart_start_condition)
    ADDWF   r0x00, F
    MOVLW   HIGH(_uart_start_condition)
    ADDWFC  r0x01, F
    MOVLW   UPPER(_uart_start_condition)
    ADDWFC  r0x02, F
    MOVFF   r0x00, TBLPTRL
    MOVFF   r0x01, TBLPTRH
    MOVFF   r0x02, TBLPTRU
    TBLRD*+ 
    MOVFF   TABLAT, _TXREG

this works as expected

;   .line   329; my.c   TXREG = uart_start_condition[uart_tx_start_condition_index];
    MOVLW   LOW(_uart_start_condition)
; removed redundant BANKSEL
    ADDWF   _uart_tx_start_condition_index, W, B
    MOVWF   r0x00
    CLRF    r0x01
    MOVLW   HIGH(_uart_start_condition)
    ADDWFC  r0x01, F
    CLRF    r0x02
    MOVLW   UPPER(_uart_start_condition)
    ADDWFC  r0x02, F
    MOVFF   r0x00, TBLPTRL
    MOVFF   r0x01, TBLPTRH
    MOVFF   r0x02, TBLPTRU
    TBLRD*+ 
    MOVFF   TABLAT, _TXREG
; removed redundant BANKSEL
;   .line   330; my.c   uart_tx_start_condition_index++;
    INCF    _uart_tx_start_condition_index, F, B

I'm using the most recent svn sdcc-version configured with :

./configure \
    --disable-doc \
    --disable-mcs51-port \
    --disable-z80-port \
    --disable-z180-port \
    --disable-r2k-port \
    --disable-r3ka-port \
    --disable-gbz80-port \
    --disable-ds390-port \
    --disable-ds400-port \
    --disable-hc08-port \
    --disable-s08-port \
    --disable-ucsim  \
    --enable-libgc \
    --enable-new-pics

and the most recent svn gputils.

The files are compiled with the following command line :

sdcc -o $(my.o) -mpic16 -p18f2550 --use-non-free --std-sdcc99 --obanksel=9 --opt-code-size --optimize-cmp --optimize-df --denable-peeps  $(my.include.paths) -c $(my.c)

Cheers,
Oli

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks