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

please save me from PCD

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



Joined: 22 Apr 2007
Posts: 22
Location: Romania

View user's profile Send private message Yahoo Messenger

please save me from PCD
PostPosted: Tue Oct 07, 2008 5:03 am     Reply with quote

hey

pic24FJ32GA002, PCWHD 4.080

Code:
const int ID = 20015;
char a, b;
a = ID >> 8; // a is 78 - ok
b = ID; // b is 47 - ok ... 78 * 256 + 47 = 20015

a ^= 170; // a is 228 - perfect
b ^= 85; // b is 177 ??? should be 122

ok ... let's switch the last two lines ...

...
Code:
b ^= 85; // b is 27 ??? should be 122
a ^= 170; // a is 228 - perfect

What am I missing here ?
drdelphi



Joined: 22 Apr 2007
Posts: 22
Location: Romania

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Oct 07, 2008 5:12 am     Reply with quote

one more for the road ...

Code:
  boolean v, g;
  g = false;
  v = true;
  printf("G=%u V=%u\n\r", g, v);

Guess what the output is ?
"G = 0 V = 0"
Shocked
MicroManiac



Joined: 21 Aug 2008
Posts: 34

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Oct 07, 2008 5:14 am     Reply with quote

one small question because i didn't understand what you are doing,
if you want to add why don't you use the a+=170??
_________________
"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
Albert Einstein
Guest








PostPosted: Tue Oct 07, 2008 5:16 am     Reply with quote

^ does not stand for addition. it is XOR eXclusive Or
any other suggestions ?
drdelphi



Joined: 22 Apr 2007
Posts: 22
Location: Romania

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Oct 07, 2008 5:27 am     Reply with quote

I found one way to solve the first problem:

const int ID = 20015;
char a, c, b;
a = ID >> 8;
b = ID;
a ^= 170;
b ^= 85; // b is 122 as expected

so just adding a dummy 'c' variable between a and b solved the problem.

before
.................... a ^= 170;
0AD0: MOV 2414,W0
0AD2: XOR.B #AA,W0L
0AD4: PUSH 2414
0AD6: MOV.B W0L,[W15-#2]
0AD8: POP 2414
.................... b ^= 85;
0ADA: MOV 2414,W0
0ADC: XOR.B #55,W0L
0ADE: PUSH 2414
0AE0: MOV.B W0L,[W15-#1]
0AE2: POP 2414

now
.................... a ^= 170;
0AC8: MOV 2414,W0
0ACA: XOR.B #AA,W0L
0ACC: PUSH 2414
0ACE: MOV.B W0L,[W15-#2]
0AD0: POP 2414
.................... b ^= 85;
0AD2: MOV 2416,W0
0AD4: XOR.B #55,W0L
0AD6: PUSH 2416
0AD8: MOV.B W0L,[W15-#2]
0ADA: POP 2416
Ttelmah
Guest







PostPosted: Tue Oct 07, 2008 10:07 am     Reply with quote

Yes, PCD, is still showing strong signs of 'beta' status...
There have been several other oddities reported here in the recent weeks.
As a completely 'silly' test, what happens if you use explicit, rather than implicit allocation of the source. So:
Code:

a = a ^ 170;
b = b ^ 85;

You need to report the fault ASAP, anyway, but it'd be interesting if this changed things.

Best Wishes
drdelphi



Joined: 22 Apr 2007
Posts: 22
Location: Romania

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Oct 07, 2008 10:11 am     Reply with quote

It doesn't change anything.
this problem appears only with char type. if I declare the variables of type int which in this version is signed int16, it works.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Oct 07, 2008 11:13 am     Reply with quote

Welcome to the PCD beta tester community!

I've found, that int8 operations generally have a higher risk of revealing PCD bugs. This shouldn't be accepted, but apart from claiming correct operation with int8, using int16 produces more effective code in most cases. Thus, if your RAM isn't running short with your application, you should consider to use int16 for simple work registers and similar purposes.

Although I recently found 3 different PCD bugs at one day, I can say, that I already finished a complex application, involving e. g. a MODBUS slave and EEPROM emulation with PIC24F. Many things have been working from the start. Thus I won't shout "Save me from ...". There is however a lot of work left for CCS, and I think, they know about.

Best regards,
Frank
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 28, 2008 11:27 am     Reply with quote

The bug discussed above has been finally fixed in V4.084, also some wrong SFR addresses related to IO-ports. Unfortunately, a lot of other bugs apparently hasn't been touched yet. PersonaIly, I have still 6 pending bug reports of october and november, and I expect there are some more.

Best regards and a Happy New Year!
Frank
dolleman
Guest







PostPosted: Sun Dec 28, 2008 4:03 pm     Reply with quote

the easyist way in pcd is to break your code into smaller lines. to find where it breaks, it may take more lines of code but then it works. just because it's leagal code does not mean ccs has it all working.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 28, 2008 4:28 pm     Reply with quote

This is, what I basically did. To understand, what this easyist way really means, I suggest to take the RFC1321 MD5 implementation and break the code into smaller lines until it operates correctly. A mathematician would say: a finite solution exists.
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