Hi. I'm using SDCC to target a PIC16F887 and am having some difficulty with correct behavior of pointers to file registers. The code generated by SDCC appears to set the STATUS.IRP bank selection bit incorrectly in some cases. In particular, indirect access to the TRISC register (0x87, bank 1) generates code with IRP==1, which causes the indireciton to act instead upon the BAUDCTL register (0x187, bank 3).
Consider the following example: -------- /* sdcc --use-non-free --debug-xtra -mpic14 -p16f887 test_irp.c */ #define __16f887 #define NO_BIT_DEFINES #define NO_LEGACY_NAMES #include <pic16f887.h> // These pointers must be explicitly defined as being to data space, // or 'check_data' in macros.inc results in them being generic, and // skipped. __data unsigned char *TRISCptr = &TRISC; void main(void) { volatile unsigned char a; a = *TRISCptr; while(1); } --------- The generated code sets FSR = 0x87, as it should. However, before accessing INDF, it sets bit 7 of STATUS. This is incorrect: MOVWF FSR ;id=162,key=00a,inCond:10,outCond:1,flow seq=001 ;;; gen.c:5556:SetIrp *{* ;; >>> gen.c:5577:SetIrp ;; BANKOPT1 BANKSEL dropped; STATUS present in all of FSR's banks BCF STATUS,7 ;id=165,key=00b,inCond:21,outCond:21,flow seq=001 ;; >>> gen.c:5580:SetIrp BANKSEL r0x1004 ;id=207,key=00c,inCond:0,outCond:0,flow seq=001 BTFSC r0x1004,0 ;id=167,key=00d,inCond:21,outCond:0,flow seq=001 ;<>Start of new flow, seq=0x2 ancestor = 0x1 ; from: 001 ; to: 003 ;; >>> gen.c:5581:SetIrp BSF STATUS,7 ;id=169,key=000,inCond:21,outCond:21,flow seq=002 ;<>Start of new flow, seq=0x3 ancestor = 0x1 ; from: 002 001 ; to: 004 ;; *** genNearPointerGet 5951 ;; >>> gen.c:5958:genNearPointerGet BANKSEL INDF ;id=208,key=000,inCond:0,outCond:0,flow seq=003 MOVF INDF,W ;id=172,key=001,inCond:1,outCond:14,flow seq=003 I'd appreciate any help with this. Thanks. ~Jacob
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user