This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

may be a BUG in Keil c51 ? (32bit calculations)

Look at this program:

/*------------------------------------------------------------------------------*/
#include <reg51.h>
#include <stdio.h>


typedef unsigned long uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;

#define MEMORY xdata

#define StructMEMORY xdata

typedef struct {
  uint16 lArg0;
  uint32 lArg1;
} MyStruct;

uint8 xdata * MEMORY lPtr;

MyStruct StructMEMORY m;

void MyInit() {

 m.lArg0=8;
 m.lArg1=2;

 lPtr=(uint8 xdata *)0xddd3;
}

void bug_0(MyStruct StructMEMORY *p) {
static uint32 MEMORY lResults[4];

 lResults[0]=((uint32)lPtr) + p->lArg1 + (uint32)(p->lArg0);
 lResults[1]=p->lArg1 + (uint32)(p->lArg0) + ((uint32)lPtr);


 lResults[2]=((uint32)lPtr);
 lResults[2]+=p->lArg1 + (uint32)(p->lArg0);

 lResults[3]=(uint32)(lPtr+p->lArg1 + (uint32)(p->lArg0));

 if (lResults[0]==lResults[1] && lResults[1]==lResults[2] && lResults[2]==lResults[3])
    printf("\nNo problems.");
  else
    for(;/* BUG */;);

}

void main() {

 MyInit();
 bug_0(&m);
}
/*------------------------------------------------------------------------------*/

Try to compile it and run it. You will get the endless loop.

i used a 7.01 ver. of c51

Project sets:
Target i8051AH
[v]Use on-chip rom
off-chip xdata memory: 0x0000-0x01ff
memory model: small, code rom size: small

Michael S.

Parents
  • Hello.

    Have you tried the latest version?
    No.

    Or at least looked at the Release Note to see if it mentions anything relevant...

    Yes, first of all I'm looked at release notes of c51 compiler, versions from 7.01 to latest and didn't find any topic, related to this problem.

    I have wrote to Keil support and will wait for responce.

Reply
  • Hello.

    Have you tried the latest version?
    No.

    Or at least looked at the Release Note to see if it mentions anything relevant...

    Yes, first of all I'm looked at release notes of c51 compiler, versions from 7.01 to latest and didn't find any topic, related to this problem.

    I have wrote to Keil support and will wait for responce.

Children