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

v.4.107 (pic24) calc error

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



Joined: 25 Jun 2009
Posts: 7

View user's profile Send private message

v.4.107 (pic24) calc error
PostPosted: Thu Oct 07, 2010 11:53 am     Reply with quote

Hi all.

I get strange result on v.4.107 for 24HJ128GP506

Code:

    int8 r0,r1,r2,r3;
    int8 column[4];

    r0 = column[1] ^ column[2] ^ column[3];
    r1 = column[0] ^ column[2] ^ column[3];
    r2 = column[0] ^ column[1] ^ column[3];
    r3 = column[0] ^ column[1] ^ column[2];




Code:

....................           r0 = column[1] ^ column[2] ^ column[3];
01A38:  MOV.B   1D55,W0L
01A3A:  XOR.B   1D56,W0L
01A3C:  MOV     W0,[W15++]
01A3E:  MOV.B   1D57,W0L
01A40:  MOV.B   W0L,1D4E
01A42:  MOV     [--W15],W0
01A44:  XOR.B   1D4E
....................           r1 = column[0] ^ column[2] ^ column[3];
01A46:  MOV.B   1D54,W0L
01A48:  XOR.B   1D56,W0L
01A4A:  MOV.B   1D57,W0L
01A4C:  MOV.B   W0L,1D4F
01A4E:  XOR.B   1D4F
....................           r2 = column[0] ^ column[1] ^ column[3];
01A50:  MOV.B   1D54,W0L
01A52:  XOR.B   1D55,W0L
01A54:  MOV     W0,[W15++]
01A56:  MOV.B   1D57,W0L
01A58:  MOV.B   W0L,1D50
01A5A:  MOV     [--W15],W0
01A5C:  XOR.B   1D50
....................           r3 = column[0] ^ column[1] ^ column[2];
01A5E:  MOV.B   1D54,W0L
01A60:  XOR.B   1D55,W0L
01A62:  MOV     W0,[W15++]
01A64:  MOV.B   1D56,W0L
01A66:  MOV.B   W0L,1D51
01A68:  MOV     [--W15],W0
01A6A:  XOR.B   1D51


r1 calculation result is wrong. I think one asm instruction is missing.

Somebody can test it on newlest or same compiler version?

upd: wrong asm was posted
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 07, 2010 12:18 pm     Reply with quote

Yes, the intermediate result is overwritten in the calculation of the second expression. And it's still wrong in most recent PCD V.4.112.
qseeker



Joined: 25 Jun 2009
Posts: 7

View user's profile Send private message

PostPosted: Thu Oct 07, 2010 3:23 pm     Reply with quote

Thanks FvM!
I'm definitely disappointed in 4.xx version.
tae



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

PostPosted: Thu Oct 07, 2010 4:06 pm     Reply with quote

Code:
void main()
{
    int8 r0,r1,r2,r3;
    int8 column[4];

    r0 = column[1] ^ column[2] ^ column[3];
    r1 = column[0] ^ column[2] ^ column[3];
    r2 = column[0] ^ column[1] ^ column[3];
    r3 = column[0] ^ column[1] ^ column[2];
}


Code:
.................... void main()
.................... {
*
00200:  BSET.B  81.7
00202:  SETM    32C
00204:  SETM    32A
00206:  MOV     #1F80,W15
00208:  MOV     #1FFF,W0
0020A:  MOV     W0,20
0020C:  NOP     
....................     int8 r0,r1,r2,r3; 
....................     int8 column[4]; 
.................... 
....................     r0 = column[1] ^ column[2] ^ column[3]; 
0020E:  MOV.B   809,W0L
00210:  XOR.B   80A,W0L
00212:  MOV.B   80B,W0L
00214:  MOV.B   W0L,803
00216:  XOR.B   803
....................     r1 = column[0] ^ column[2] ^ column[3]; 
00218:  MOV.B   808,W0L
0021A:  XOR.B   80A,W0L
0021C:  MOV     W0,[W15++]
0021E:  MOV.B   80B,W0L
00220:  MOV.B   W0L,804
00222:  MOV     [--W15],W0
00224:  XOR.B   804
....................     r2 = column[0] ^ column[1] ^ column[3]; 
00226:  MOV.B   808,W0L
00228:  XOR.B   809,W0L
0022A:  MOV.B   80B,W0L
0022C:  MOV.B   W0L,805
0022E:  XOR.B   805
....................     r3 = column[0] ^ column[1] ^ column[2]; 
00230:  MOV.B   808,W0L
00232:  XOR.B   809,W0L
00234:  MOV     W0,[W15++]
00236:  MOV.B   80A,W0L
00238:  MOV.B   W0L,806
0023A:  MOV     [--W15],W0
0023C:  XOR.B   806
.................... }
0023E:  PWRSAV  #0

CCS v4.110
I'm shocked Evil or Very Mad
tae



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

PostPosted: Thu Oct 07, 2010 4:17 pm     Reply with quote

Here's another trick Shocked

Code:
int8 r0,r1,r2,r3;
int8 column[4];

void main()
{
    r0 = column[1] ^ column[2] ^ column[3];
    r1 = column[0] ^ column[2] ^ column[3];
    r2 = column[0] ^ column[1] ^ column[3];
    r3 = column[0] ^ column[1] ^ column[2];
}


Code:
.................... 
....................     int8 r0,r1,r2,r3; 
....................     int8 column[4]; 
.................... 
.................... 
.................... void main()
.................... {
*
00200:  BSET.B  81.7
00202:  SETM    32C
00204:  SETM    32A
00206:  MOV     #1F80,W15
00208:  MOV     #1FFF,W0
0020A:  MOV     W0,20
0020C:  NOP     
.................... 
.................... 
....................     r0 = column[1] ^ column[2] ^ column[3]; 
0020E:  MOV.B   805,W0L
00210:  XOR.B   806,W0L
00212:  MOV     W0,[W15++]
00214:  MOV.B   807,W0L
00216:  MOV.B   W0L,800
00218:  MOV     [--W15],W0
0021A:  XOR.B   800
....................     r1 = column[0] ^ column[2] ^ column[3]; 
0021C:  MOV.B   804,W0L
0021E:  XOR.B   806,W0L
00220:  MOV.B   807,W0L
00222:  MOV.B   W0L,801
00224:  XOR.B   801
....................     r2 = column[0] ^ column[1] ^ column[3]; 
00226:  MOV.B   804,W0L
00228:  XOR.B   805,W0L
0022A:  MOV     W0,[W15++]
0022C:  MOV.B   807,W0L
0022E:  MOV.B   W0L,802
00230:  MOV     [--W15],W0
00232:  XOR.B   802
....................     r3 = column[0] ^ column[1] ^ column[2]; 
00234:  MOV.B   804,W0L
00236:  XOR.B   805,W0L
00238:  MOV     W0,[W15++]
0023A:  MOV.B   806,W0L
0023C:  MOV.B   W0L,803
0023E:  MOV     [--W15],W0
00240:  XOR.B   803
.................... }
00242:  PWRSAV  #0
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 07, 2010 11:34 pm     Reply with quote

A comment from a previous discussion
Quote:
Most of these bugs show some kind of confusion with working registers. It seems like it's too much for PCD to keep track of them.
selsen



Joined: 16 Mar 2007
Posts: 9

View user's profile Send private message

PostPosted: Wed Oct 13, 2010 1:30 am     Reply with quote

There are alot of bugs with PCD. I am using 24f...GB series and having lots of trouble. I am fighting with trap conflict errors. PCD has mistakes with addressing. I have sent lots of mails to CCS they sent me some dll's. But still have problems. I am trying to change compiler or microcontroller because of those problems.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 13, 2010 2:21 am     Reply with quote

I see, that you also have the pleasure since two years. Working with PCD is still like driving an old car: Don't press this button, or something gonna break. Don't turn the steering wheel too fast, or ... Have your tool bag with you, ready for some repair on the road.
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