View previous topic :: View next topic |
Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
Doing int1 Comparisions |
Posted: Sun Nov 20, 2011 4:20 pm |
|
|
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
|
|
Posted: Sun Nov 20, 2011 6:31 pm |
|
|
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
|
|
Posted: Mon Nov 21, 2011 4:35 am |
|
|
It apparently had been fixed in V4.112 (my "stable" CCS C working version) but returned later. |
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Mon Nov 21, 2011 5:00 am |
|
|
Thanks,
CCS have been informed. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Nov 21, 2011 5:57 pm |
|
|
Quote: |
"stable" CCS C working version
|
i just assume
Code: |
if (!stable || !works) new_version=true;
|
|
|
|
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Tue Nov 22, 2011 4:25 am |
|
|
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
|
|
Posted: Tue Nov 22, 2011 8:02 am |
|
|
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
|
|
Posted: Tue Nov 22, 2011 2:33 pm |
|
|
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
|
|
Posted: Wed Nov 23, 2011 4:35 am |
|
|
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. |
|
|
|