Menu

#1247 PIC14, bitwise test

closed-fixed
nobody
5
2013-05-25
2006-11-26
mikasaari
No

Description:
When compiling the C-file, the code isn't working. After checking the asm file the bitwise operations seems to be wrong => i&0x01 should be BTFSC r0x1000,0 now it is BTFSC r0x1000,7

SDCC version: Latest svn (
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.6.1 #4477 (Nov 26 2006) (UNIX))

Compile Command: "sdcc --verbose -mpic14 -p16f690 test.c -I/usr/local/share/sdcc/include"

Sample Codes:
C-code
if((i & 0x01)==0) PORTC = 0x03;
if((i & 0x02)==0) PORTC = 0x03;
if((i & 0x04)==0) PORTC = 0x03;
if((i & 0x80)==0) PORTC = 0x10;

cuts from ASM-code
; .line 10; "test.c" if((i & 0x01)==0)
BANKSEL r0x1000
BTFSC r0x1000,7
GOTO _00106_DS_

; .line 12; "test.c" if((i & 0x02)==0)
BANKSEL r0x1000
BTFSC r0x1000,0
GOTO _00108_DS_

; .line 14; "test.c" if((i & 0x04)==0)
BANKSEL r0x1000
BTFSC r0x1000,1
GOTO _00110_DS_

; .line 24; "test.c" if((i & 0x80)==0)
BANKSEL r0x1000
BTFSC r0x1000,6
GOTO _00124_DS_

Discussion

  • Raphael Neider

    Raphael Neider - 2006-11-27
    • milestone: --> unreproducable
    • status: open --> pending-fixed
     
  • Raphael Neider

    Raphael Neider - 2006-11-27

    Logged In: YES
    user_id=1115835
    Originator: NO

    This is an off-by-one bug regarding the bit-position (7(= -1) for 0, 0 for 1, 1 for 2, 6 for 7). Already fixed this one in r4478, you are just a single revision too early! Please update and try again.

    Regards,
    Raphael

     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.