View previous topic :: View next topic |
Author |
Message |
drdelphi
Joined: 22 Apr 2007 Posts: 22 Location: Romania
|
please save me from PCD |
Posted: Tue Oct 07, 2008 5:03 am |
|
|
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
|
|
Posted: Tue Oct 07, 2008 5:12 am |
|
|
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"
|
|
|
MicroManiac
Joined: 21 Aug 2008 Posts: 34
|
|
Posted: Tue Oct 07, 2008 5:14 am |
|
|
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
|
|
Posted: Tue Oct 07, 2008 5:16 am |
|
|
^ does not stand for addition. it is XOR eXclusive Or
any other suggestions ? |
|
|
drdelphi
Joined: 22 Apr 2007 Posts: 22 Location: Romania
|
|
Posted: Tue Oct 07, 2008 5:27 am |
|
|
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
|
|
Posted: Tue Oct 07, 2008 10:07 am |
|
|
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
|
|
Posted: Tue Oct 07, 2008 10:11 am |
|
|
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
|
|
Posted: Tue Oct 07, 2008 11:13 am |
|
|
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
|
|
Posted: Sun Dec 28, 2008 11:27 am |
|
|
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
|
|
Posted: Sun Dec 28, 2008 4:03 pm |
|
|
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
|
|
Posted: Sun Dec 28, 2008 4:28 pm |
|
|
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. |
|
|
|