Does any one else have problems with the higher levels of optimisation available to C51? With common block subroutines switched on, sometimes, just sometimes, C51 will generate completely wrong code. I have noticed that the problems are often associated with pointers that are automatic variables and where there is a variable of the same name in another function. Common block subroutines have a dramatic affect on code size, but I don't use this level of optimisation because it just does not seem to be reliable.
Below are the results of a more systematic study I have made. It seems that I was wrong, the problem actually starts with optimisation level 10. Optimisation level 8: This code works fine.
197: a++; 009CB7 903B68 MOV DPTR,#a+01H 009CBA E0 MOVX A,@DPTR 009CBB 240F ADD A,#0FH 009CBD F0 MOVX @DPTR,A 009CBE 903B67 MOV DPTR,#a 009CC1 E0 MOVX A,@DPTR 009CC2 3400 ADDC A,#00H 009CC4 F0 MOVX @DPTR,A 198:
197: a++; 008531 903B68 MOV DPTR,#a+01H 008534 E0 MOVX A,@DPTR 008535 240F ADD A,#0FH 008537 F17E ACALL ?L?COM020C 198: ----- FUNCTION ?L?COM020C (BEGIN) ----- 00877E F0 MOVX @DPTR,A 00877F 903B67 MOV DPTR,#v 008782 E0 MOVX A,@DPTR 008783 3400 ADDC A,#00H 008785 F0 MOVX @DPTR,A 008786 22 RET ----- FUNCTION ?L?COM020C (END) -------
197: a++; 007BE0 903B68 MOV DPTR,#a+01H 007BE3 E0 MOVX A,@DPTR 007BE4 903B67 MOV DPTR,#a 007BE7 12BF63 LCALL ?L?COM016E 198: ----- FUNCTION ?L?COM016D (BEGIN) ----- 00BF5C 903B45 MOV DPTR,#a+01H 00BF5F E0 MOVX A,@DPTR 00BF60 903B44 MOV DPTR,#a 00BF63 ?L?COM016E: 00BF63 240F ADD A,#0FH 00BF65 F0 MOVX @DPTR,A 00BF66 E0 MOVX A,@DPTR 00BF67 3400 ADDC A,#00H 00BF69 F0 MOVX @DPTR,A 00BF6A 22 RET ----- FUNCTION ?L?COM016D (END) -------
Error! Forum Overflow. Please contact the Administrator.
This is not a problem of C51, but from the LX51 Linker/Locater. Which LX51 version are you using.
We are using LX51 version 3.51.
"This is not a problem of C51, but from the LX51 Linker/Locater." So it is a problem, then?
Graham, When I first switched to using LX51 I tried optimisation levels 10 and 11 (with "Favour size" selected) and encountered some problems with previously working code. I didn't bother to investigate, however, because I found that the code size in all three projects tested actually grew by about 0.5% with level 11 as opposed to level 9. Have you found these additional optimisation levels to be of any benefit (when they work)? Stefan
Stefan: how well does each level of optimisation work? I performed an experiment using my current development project and built it with various possible levels of optimisation in order to find out. The project is pretty typical, it has no floating point and has ANSI promotion turned on for about 50% of the code. Linker code packing is enabled.
Optimisation Favour Favour Difference Difference from level 8 Level Speed Size for size Speed Size 8 59288 56882 4.06% 00.0% 00.0% 9 49502 48358 2.31% 16.5% 15.0% 10 49499 48417 2.18% 16.5% 14.9% 11 49499 48417 2.18% 16.5% 14.9%
Graham, "whereas levels 10 and 11 have very little to offer" Indeed, you're seeing a slight increase in code size over level 9 with 'Favour size' as I am. My projects all use a great deal of floating point, I build with linker code packing on and integer promotion off. Perhaps Keil would like to comment on whether there are any specific situations where 10 and 11 make a significant improvement? Stefan
"Perhaps Keil would like to comment on whether there are any specific situations where 10 and 11 make a significant improvement?" Apparently not. Is this because levels 10 and 11 are in fact a marketing gimmick? "So it is a problem, then?" Presumably silence means 'yes'? Look Keil, we understand that there will be bugs in your software from time to time. In general your tools are of a very high quality and very well supported. But please, when there is a problem we want to know what it is, what it affects and when it will be fixed. At a minimum please describe bug fixes in detail in your version release notes. Stefan
"please describe bug fixes in detail in your version release notes." I've been moaning about the lack of information in the so-called "release notes" for ages! I think all the "release notes" for all the 6.xx versions were identical apart from the value of the "xx"!!! (yes, I even did a text compare once!) Things have improved recently, but there's still a way to go; eg proper documentation of bugs/issues fixed, and known issues remaining.
We can confirm that your problem is most likely fixed in the current version. Take a look to http://www.keil.com/update/_c51/c51v703a.htm which are the release notes of the current revision. In the first item under V7.02 we refer to the fact that we have corrected some problems with linker code packing.