ARM Technical Support Knowledge Articles

XOR GIVES INCORRECT RESULTS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


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.

Article last edited on: 2005-05-28 22:37:33

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential