Subject:
SDCC pointers are working
From:
Scott Dattalo ####@####.####
Date:
31 May 2002 04:33:34 -0000
Message-Id: <Pine.LNX.4.44.0205302116350.8118-100000@ruckus.brouhaha.com>
I normally wouldn't post such detailed progress to this list, but this is
a follow up to the pointer bug report Bob posted to the list. For all of
the cases I've tested, pointers and arrays "work". This has been checked
into CVS.
I boiled the code down to the simplest case:
void index_by_pointer(unsigned char *index, unsigned char expected_value)
{
if(buff[*index] != expected_value)
failures++;
}
Two days ago this would cause SDCC to expose the core, whereas now it
produces:
;; -----------------------------------------
;; function index_by_pointer
;; -----------------------------------------
_index_by_pointer ;Function start
;#CSRC pointer1.c 93
; void index_by_pointer(unsigned char *index, unsigned char
expected_value)
MOVWF temp2 ;key=000,flow seq=016
MOVF s0xFFF,W ;key=001,flow seq=016
MOVWF temp1 ;key=002,flow seq=016
MOVF s0x1000,W ;key=003,flow seq=016
MOVWF r0x33 ;key=004,flow seq=016
;#CSRC pointer1.c 96
; if(buff[*index] != expected_value)
MOVF temp1,W ;key=005,flow seq=016
MOVWF FSR ;key=006,flow seq=016
MOVF INDF,W ;key=007,flow seq=016
MOVWF r0x34 ;key=008,flow seq=016
MOVF r0x34,W ;key=009,flow seq=016
ADDLW _buff ;key=00a,flow seq=016
MOVWF r0x35 ;key=00b,flow seq=016
MOVF r0x35,W ;key=00c,flow seq=016
MOVWF FSR ;key=00d,flow seq=016
MOVF INDF,W ;key=00e,flow seq=016
MOVWF r0x36 ;key=00f,flow seq=016
MOVF r0x36,W ;key=010,flow seq=016
;;peep 1 - test/jump to test/skip
;#CSRC pointer1.c 97
; failures++;
XORWF r0x33,W ;key=011,flow seq=016
BTFSS STATUS,2 ;key=012,flow seq=016
INCF _failures,F ;key=000,flow seq=017
_00162_DS_
RETURN ;key=001,flow seq=017
It's not what I'd call efficient, but it is correct.
Scott