Keil Logo

C51: XOR GIVES INCORRECT RESULTS


Information in this article applies to:

  • C51 Version 5.50

SYMPTOMS

I have two arrays of values, a and b. I am trying to XOR (exclusive or) elements from the arrays together. The following works:

a[i] = b[i] ^ a[i];

However, both of the following place the result into b:

a[i] ^= b[i];
a[i] = a[i] ^ b[i];

Is this a bug in the compiler?

CAUSE

Yes. This was caused by a bug in the compiler.

RESOLUTION

A new version of the C51 compiler (5.50d) which corrects this problem is available. See the attached files section below to get this updated file.

A workaround is to use the code format that works. e.g.:

a[i] = b[i] ^ a[i];

ATTACHED FILES

Request the files attached to this knowledgebase article.

Last Reviewed: Saturday, May 28, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.