View previous topic :: View next topic |
Author |
Message |
johnjohn7188
Joined: 29 Oct 2008 Posts: 8 Location: Irvine, CA
|
PCD Compiler 4.081 Breaks strlen() function |
Posted: Wed Oct 29, 2008 3:29 pm |
|
|
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
|
|
Posted: Wed Oct 29, 2008 4:26 pm |
|
|
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
|
|
Posted: Wed Oct 29, 2008 4:40 pm |
|
|
I'll try it out right now. |
|
|
johnjohn7188
Joined: 29 Oct 2008 Posts: 8 Location: Irvine, CA
|
|
Posted: Wed Oct 29, 2008 4:54 pm |
|
|
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
|
|
Posted: Wed Oct 29, 2008 5:21 pm |
|
|
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
|
|
Posted: Wed Oct 29, 2008 5:35 pm |
|
|
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
|
|
Posted: Wed Oct 29, 2008 6:19 pm |
|
|
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
|
|
Posted: Thu Oct 30, 2008 2:14 pm |
|
|
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. |
|
|
|