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

Why does the Keil compiler generate bad code for the DS400C80?

The following code:
fwsUniChar c;
fwsUniChar *temp;

temp=p->inPtr;
c = *temp;
temp++;
p->inPtr = temp;
correctly increments the pointer p by 0x01


instead of
fwsUniChar c = p->inPtr++;
which incorrectly increments the pointer p by 0x101
This code compiles and runs correctly with ANSI C compilers



Also
routine1() reentrant
{
enum ElementTagType type;

routine2(&type);
}

routine2(enum ElementTagType *type)
{
type = START_TAG;
}


does not work (i.e. type in routine1 is not set to START_TAG after calling routine 2.

There is a default XBPSTACK

Any Ideas

Thanks

Barry

Parents
  • "The following code:

    fwsUniChar c;
    fwsUniChar *temp;
    
    temp=p->inPtr;
    c = *temp;
    temp++;
    p->inPtr = temp;
    correctly increments the pointer p by 0x01"

    You did not show us how p is declared. That aside, wouldn't that be incrementing the inPtr member of whatever p is pointing to, not p?.

    "instead of
    fwsUniChar c = p->inPtr++;
    which incorrectly increments the pointer p by 0x101"


    Again, see above. Also, are you certain that storing into c, the value of the inPtr member of whatever p is pointing to, is what you are trying to achieve here? If the inPtr member is a pointer, wouldn't you want:
    fwsUniChar c = *p->inPtr++;

Reply
  • "The following code:

    fwsUniChar c;
    fwsUniChar *temp;
    
    temp=p->inPtr;
    c = *temp;
    temp++;
    p->inPtr = temp;
    correctly increments the pointer p by 0x01"

    You did not show us how p is declared. That aside, wouldn't that be incrementing the inPtr member of whatever p is pointing to, not p?.

    "instead of
    fwsUniChar c = p->inPtr++;
    which incorrectly increments the pointer p by 0x101"


    Again, see above. Also, are you certain that storing into c, the value of the inPtr member of whatever p is pointing to, is what you are trying to achieve here? If the inPtr member is a pointer, wouldn't you want:
    fwsUniChar c = *p->inPtr++;

Children