Menu

#1174 Bit inversion in pic16F74

open
nobody
PIC14
5
2013-07-16
2006-07-22
Anonymous
No

When I try to do clear bit operation ( PORTD &= ~0x40 ) the sdcc
produces ( CLRF PORTD ) assembly code from it. The problem is only in
bit inversion because the same assembly code is produced from ( PORTD
= ~0x40) too. Is this a known bug or is there coming to fix?

Compilation command from Makefile:
sdcc -S -V -mpic14 -p16F74 $<

sdcc -v
> SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/
ds400/hc08 2.5.6 #4252 (Jul 1 2006) (UNIX)

--
Aki Penttinen
Email: aki.p.penttinen@lut.fi

Discussion

  • Raphael Neider

    Raphael Neider - 2006-07-28

    Logged In: YES
    user_id=1115835

    You need to post some code, with
    <code name="b1526968.c">
    #include <pic14regs.h>
    void foo(void) {
    PORTD &= 0x40;
    PORTD = ~0x40;
    }
    </code>
    and
    sdcc -mpic14 -p16f74 -S b1526968.c
    I obtain the desired results (BCF _PORTD, 6; MOVLW 0xbf;
    MOVWF _PORTD). Tested with SDCC 2.5.6 #4290 and 2.6.0 #4308.

     
  • Nobody/Anonymous

    Logged In: NO

    SDCC 2.6.0 #4309, compiled with MacBook
    and with your code the output is still:

    ; .line 3; "b1526968.c" PORTD &= 0x40;
    MOVLW 0x40
    BCF STATUS,5
    BCF STATUS,6
    ANDWF _PORTD,F
    ; .line 4; "b1526968.c" PORTD = ~0x40;
    CLRF _PORTD

    But I tried the same code with SDCC version 2.5.6 with my linux computer
    and the results was:
    ; .line 3; "b1526968.c" PORTD &= 0x40;
    MOVLW 0x40
    BCF STATUS,5
    BCF STATUS,6
    ANDWF _PORTD,F
    ; .line 4; "b1526968.c" PORTD = ~0x40;
    MOVLW 0xbf
    MOVWF _PORTD

    So now the code was as it should be. The problem seems to be my MacBook's
    sdcc. By now I should atleast continue compiling code with linux machine.

     
  • Philipp Klaus Krause

    • Category: --> PIC14
     

Log in to post a comment.

Auth0 Logo