Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


Weird shift behavior on pic14 code


  • Anonymous

    Hello. I've noticed a number of architectures suported by SDCC have issues with bit shift operations but i haven't read anything about pic14, so here it goes. I'm trying to perform a simple shift on a PIC 16F877A with SDCC 3.1.0:

    static unsigned char currentDigit = xxxx;
    unsigned char mask;
    // Enable digit cathode
    mask = (1 << currentDigit);
    PORTA = mask;

    …which generates the following output:

        SUBWF   _switchVisibleDigit_currentDigit_1_1,W
        BTFSC   STATUS,0
        CLRF    _switchVisibleDigit_currentDigit_1_1
        MOVLW   0x01
        MOVWF   _PORTA
        BANKSEL _switchVisibleDigit_currentDigit_1_1
        MOVF    _switchVisibleDigit_currentDigit_1_1,W
        SUBLW   0x00
        BTFSC   STATUS,2
        GOTO    _00140_DS_
        RLF _PORTA,F
        ADDLW   0x01
        BTFSS   STATUS,0
        GOTO    _00139_DS_

    which doesn't work, and also seems to be attempting rotation over PORTA directly. I can work around this using a simple lookup table, but i was wondering if this is still something to be fixed on pic14 or i'm missing something else here.

    Thanks in advance.