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 CCS Technical Support

Doing int1 Comparisions

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



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

Doing int1 Comparisions
PostPosted: Sun Nov 20, 2011 4:20 pm     Reply with quote

Hi,

Should I need to keep casting elements in an int1 array to int8?

This returns false when the data in the two elements is equal:

Code:
         if(RawDataToDecode[i]==RawDataToDecode[i+64]){
         }


But this returns true:

Code:
         if((int8)RawDataToDecode[i]==(int8)RawDataToDecode[i+64]){
         }


Version 4.125 on a 18F4620

Cheers,
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 20, 2011 6:31 pm     Reply with quote

It also works if you put the array elements into temporary int1 variables
and compare the variables.

It just doesn't work if you compare the array elements directly.
I think it's a bug. You should report it.

I checked and in fact this bug has been around for a long time:
http://ccsinfo.com/forum/viewtopic.php?t=40661
It still fails in vs. 4.127. I doubt that it would be that hard for them to fix.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 21, 2011 4:35 am     Reply with quote

It apparently had been fixed in V4.112 (my "stable" CCS C working version) but returned later.
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Mon Nov 21, 2011 5:00 am     Reply with quote

Thanks,

CCS have been informed.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Nov 21, 2011 5:57 pm     Reply with quote

Quote:

"stable" CCS C working version


i just assume
Code:


if (!stable || !works) new_version=true;

Very Happy
bilko



Joined: 17 Oct 2003
Posts: 24
Location: Dorset, UK

View user's profile Send private message

PostPosted: Tue Nov 22, 2011 4:25 am     Reply with quote

This is all getting a bit silly.

I am getting endless similar bugs with structures, unions etc.

I seem to spend more time checking the compiler output than writing code.

Time to give up and try another compiler maybe.

Bill
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Nov 22, 2011 8:02 am     Reply with quote

This may be a Chicken-&-Egg thing. I have used 1 structure and 2 unions in the last 15 years or so of programming with CCS. Maybe nobody uses them because they don't work well, or maybe CCS doesn't put the effort into making them work well because no one uses them.

All I can say is once I looked up in K&R how they should work, they worked fine for me.
_________________
The search for better is endless. Instead simply find very good and get the job done.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Nov 22, 2011 2:33 pm     Reply with quote

i got burned in a similar way trying to manipulate int1 "arrays" too.

i managed to solve it this way:
in my instance, skipme is an unsigned int8 array of 12 bytes
set up to deal with 96 virtual int1 vars ,
but you can see how this concept can be expanded.

and of course , i is the array element number

Code:

....................          if ( bit_test(skipme[(i>>3)],(i&7)) ) {
5150:  RRCF   x0C,W
5152:  MOVWF  00
5154:  RRCF   00,F
5156:  RRCF   00,F
5158:  MOVLW  1F
515A:  ANDWF  00,F
515C:  MOVF   00,W
515E:  CLRF   03
5160:  ADDLW  BA
5162:  MOVWF  FE9
5164:  MOVLW  02
5166:  ADDWFC 03,W
5168:  MOVWF  FEA
516A:  MOVFF  FEF,A10
516E:  MOVF   x0C,W
5170:  ANDLW  07
5172:  MOVWF  x11
5174:  MOVFF  A10,00
5178:  MOVF   x11,W
517A:  MOVWF  01
517C:  BZ    5186
517E:  BCF    FD8.0
5180:  RRCF   00,F
5182:  DECFSZ 01,F
5184:  BRA    517E
5186:  BTFSS  00.0
5188:  BRA    51BE
....................                set_rsel(3); // 11-11



ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Nov 23, 2011 4:35 am     Reply with quote

For me the code listing above explains it all.
keep It Simple !!!

The PIC is very efficient in manipulating single bits inside a byte but once you try to manipulate individual bits combined with address arithmetic (pointers !) the number of required instructions explodes.

I do like the CCS compiler because of the great support in this forum, but I always keep in mind that it is a cheap compiler. Cheap comes at the price of reduced quality, I know and accept this. Keeping the code simple saves me a lot of time debugging compiler errors.

For me this is one of the reasons I minimize the use of int1 variables and use them only when I'm sure the compiler can replace it with a single bit manipulating instruction.
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