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
  • I am using a MetaLink ICE for the DS80C400 to look at the pointers.

    I am using version 7.06a (the latest version of the compiler) large memory model and the pointer and contents are in XDATA.

    When I use the work-around the pointer changes from 0x01748f to 0x17490 and the program runs correctly.

    When I use the original code the pointer changes from 0x01748f to 0x17590 and the program fails. I inspected the characters addressed by the pointers as a sanity check.

    Barry

Reply
  • I am using a MetaLink ICE for the DS80C400 to look at the pointers.

    I am using version 7.06a (the latest version of the compiler) large memory model and the pointer and contents are in XDATA.

    When I use the work-around the pointer changes from 0x01748f to 0x17490 and the program runs correctly.

    When I use the original code the pointer changes from 0x01748f to 0x17590 and the program fails. I inspected the characters addressed by the pointers as a sanity check.

    Barry

Children
  • "When I use the original code the pointer changes from 0x01748f to 0x17590 and the program fails."

    You might try inspecting the assembly code/listing looking to see whether 257 is added to the pointer "all at once" or is spread out more (e.g., pointer incremented by one, then 256 added to it elsewhere). That might help point us in the right direction.