#816 probably buggy pic16_genNot?

closed-fixed
5
2013-05-25
2004-09-22
No

The following code produces wrong results:

#include <pic18fregs.h>

#pragma stack 0x3ff

int main () {
volatile char c1, c2;
volatile char result;

PORTE=0;

c1 = 0x03;
c2 = 0x02;

result = (c1 != c2) ? 2 : 1;

PORTE=result;

return 0;
}

When run, PORTE should contain 2 in the end, but does
contain 1.

Looking at the assembly code I think genNot might not
do as intended: genNot sets the Carry according to the
state of WREG (WREG != 0 ==> Carry bit set, WREG==0 ==>
Carry bit cleared). Probably the inverse operations on
the CARRY bit were intended.

A patch for genutils.c is attached, to be applied with
-p0 in src/pic16.

Found in SDCC : pic16 2.4.4 #846 (Sep 21 2004) (UNIX),
compiled with sdcc -mpic16 -p18f452 ifx_cond.c

Raphael Neider

Discussion

  • Raphael Neider

    Raphael Neider - 2004-09-22
     
  • Vangelis Rokas

    Vangelis Rokas - 2004-09-24
    • milestone: --> fixed
    • assigned_to: nobody --> vrokas
    • status: open --> closed-fixed
     
  • Vangelis Rokas

    Vangelis Rokas - 2004-09-24

    Logged In: YES
    user_id=770505

    Fixed in genutils.c 1.5

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks