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

PCD Compiler 4.081 Breaks strlen() function

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



Joined: 29 Oct 2008
Posts: 8
Location: Irvine, CA

View user's profile Send private message AIM Address

PCD Compiler 4.081 Breaks strlen() function
PostPosted: Wed Oct 29, 2008 3:29 pm     Reply with quote

PCD Compiler has broken the strlen() function. The loop that iterates through the values in the string loops to an unknown address. See instruction below at address 135A.

Anybody else having this problem?

Code:

.................... unsigned int8 strlen(char *s)
.................... {
*
134C:  MOV     W5,[W15++]
....................    char *sc;
.................... ....................    for (sc = s; *sc != 0; sc++);
134E:  PUSH    F48
1350:  POP     F4A
1352:  MOV     F4A,W0
1354:  CP0.B   [W0]
1356:  BRA     Z,135C
1358:  INC     0F4A
135A:  BRA     1014                     <--------------- branching to unknown address
....................    return(sc - s);
135C:  MOV     F4A,W4
135E:  MOV     F48,W3
1360:  SUB     W4,W3,W0
.................... }
1362:  MOV     [--W15],W5
1364:  RETURN
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 29, 2008 4:26 pm     Reply with quote

I see a correct GOTO in this instruction with PCD V4.081. But it may be a position dependent error. Do you see the same behaviour with a minimal test program?
johnjohn7188



Joined: 29 Oct 2008
Posts: 8
Location: Irvine, CA

View user's profile Send private message AIM Address

PostPosted: Wed Oct 29, 2008 4:40 pm     Reply with quote

I'll try it out right now.
johnjohn7188



Joined: 29 Oct 2008
Posts: 8
Location: Irvine, CA

View user's profile Send private message AIM Address

PostPosted: Wed Oct 29, 2008 4:54 pm     Reply with quote

FvM wrote:
I see a correct GOTO in this instruction with PCD V4.081. But it may be a position dependent error. Do you see the same behaviour with a minimal test program?



It works with a simple program. Any idea why it breaks when the code is really long? Same code used to work with version 4.080.

Here's the result for using strlen() in a simple program.

Code:

.................... unsigned int8 strlen(char *s)
.................... {
*
101A:  MOV     W5,[W15++]
....................    char *sc;
.................... 
....................    for (sc = s; *sc != 0; sc++);
101C:  PUSH    81C
101E:  POP     81E
1020:  MOV     81E,W0
1022:  CP0.B   [W0]
1024:  BRA     Z,102A
1026:  INC     081E
1028:  BRA     1020
....................    return(sc - s);
102A:  MOV     81E,W4
102C:  MOV     81C,W3
102E:  SUB     W4,W3,W0
.................... }
1030:  MOV     [--W15],W5
1032:  RETURN
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 29, 2008 5:21 pm     Reply with quote

I also had inserted the strlen() in a complex application, without error...

I experienced some other PCD bugs to be position dependent, they couldn't be reproduced with a simple test program. Such things can happen. You should report to CCS support.

You possibly may not be motivated respectively have enough time to reveal the exact conditions that produce the bug.

My general strategy is to modify the code (in this case the strlen() function) until the error is gone, cut the one line code, e. g. by introducing auxilary variables or moving the increment operation.

Regards,
Frank
johnjohn7188



Joined: 29 Oct 2008
Posts: 8
Location: Irvine, CA

View user's profile Send private message AIM Address

PostPosted: Wed Oct 29, 2008 5:35 pm     Reply with quote

Well, my project is about 9000 lines long....
I wrote a library for an LCD that utilizes strlen() to determine how many bytes of a string to print to the LCD. I already reported it to CCS. I'll just have to work around it.

I'm really annoyed that bugs like this still exist in the PCD compiler. It's really eating into my development time....
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 29, 2008 6:19 pm     Reply with quote

I have somewhat below 10000 lines now and a lot of bug-workarounds included.

I never thought of, when I started working with PCD one month ago. In between, I considered to change to C30, but now the application is almost finished. Could be worse.
johnjohn7188



Joined: 29 Oct 2008
Posts: 8
Location: Irvine, CA

View user's profile Send private message AIM Address

PostPosted: Thu Oct 30, 2008 2:14 pm     Reply with quote

I've also considered changing compilers due to the large number of bugs in the CCS compilers. However, like you, I am almost done with my project, so moving over would require a lot more development time.
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