CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

What is wrong with this compiler?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








What is wrong with this compiler?
PostPosted: Thu Oct 09, 2008 8:00 am     Reply with quote

What is wrong with this compiler?

Code:
 int1 data[10];
 int1 p_error;

if (data[index] ^ data[index-1] ^ data[index-2] ^ data[index-3] ^ data[index-4]) { p_error=1; }


Must split it out to:
Code:
int1 pbit,bit,bit1,bit2,bit3,bit4
 bit  = data[index];
 bit1 = data[index-1];
 bit2 = data[index-2];
 bit3 = data[index-3];
 bit4 = data[index-4];
 pbit = bit1 ^ bit2 ^ bit3 ^ bit4;


Compiler v 4.074

Some hints?
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Oct 09, 2008 8:28 am     Reply with quote

Thats nice.

To be fair, you have not given any indication of what the problem is, nor have you shown any results or explained the outcome of your code.
Further more, you have not supplied enough code to even compile a program let alone debug it from the little info you have shown.

None the less, someone most likely will come up with some helpfull info for you.

Either, give a complete program and show output and explain the problem or give a lot more detail than what is here.

I will not be trying to recreate the problem (whatever it is) with the simple snippets you have shown.

Sorry Smile
Guest








PostPosted: Thu Oct 09, 2008 8:45 am     Reply with quote

Sorry here are a working ex.

It compile BUT look at the ASM file!!!

Code:
void CompError() {
 int1 data[10];
 int1 p_error=0;
 int index=0;
 
 for (index=0; index<10; index++) { data[index] = index; }
 if (data[index] ^ data[index-1] ^ data[index-2] ^ data[index-3] ^ data[index-4]) { p_error=1; }
}
Guest








PostPosted: Thu Oct 09, 2008 9:34 am     Reply with quote

Try:
Code:
(data[index] && 1) ^ (data[index-1] && 1).....


It work for me Smile
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 09, 2008 12:35 pm     Reply with quote

You should also tell, which target respectively compiler type your talking about. I guess, there is a problem with accessing the correct bit position? I remember some issues with bit fields (and possibly bit arrays), that already existed in V3.
Ttelmah
Guest







PostPosted: Thu Oct 09, 2008 2:00 pm     Reply with quote

Seriously, you have to remember that the compiler has no error checking on array indexes. Your array allows locations 0 to 9, but your first loop accesses locations -4, -3, -2, -1 and 0. You need to perform error checking to have any hope of getting sensible results...

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group