Hi, I am porting my code from compiler C51 ver6.23 and BL51 to the new compiler and linker , C51 ver 7.00 and LX51 ver3.30 . This was to take advantage of the optimisation features of the LX51's linker code packing. The code when compiled and linked while disabling the Linker code packing works just fine. But once I enable the linker code packing the executable doesn't function properly on the target hardware. I feel some corruption of my data is occurring. Just by using this feature I could straight away reduce the code size by 3%. Any suggestions on how I could debug this?? And another problem I faced is untill I decalare my PDATA variables as static PDATA the LX51 linker doesn't put them into PDATA Segment...!! Thanks, -Binu
Just in case you didn't know you can viev a combined assembly/source listing by selecting: "Options for target", "Listing", "Linker code listing". If you have a reasonable idea where the program is going wrong you may be able to spot the problem in the generated assembler. It may be worth reducing the optimisation level to zero with the code packing switched on - this will give the code packer different code to work with. If your problem disappears, work up through the optimisation levels until the problem reappears then compare the .cod files from the working and faulty builds. I'd be very grateful if you'd let me know what problem you find as I am also using LX51 V3.30.
Have you tried it in the simulator?
Hi, Thanks for the suggestions! Dafydd, My target code memory is only 48.484K, anything lower than the current optimisation of 9 I get code a overflow. Andrew, I have not tried the simulator, by using the simulator how can I find the problem? could you be more specific? I know the program is crashing on invoking some specific function through key-board. thanks, -Binu
Hi, Looks like I have found the cause of the problem. First from the SEGMENTS directive in the Linker directive control file(project.lin) I removed all the constant and code segments and allowed the linker to place the Constants and Code wherever it wanted inside the 48K code space. When I linked the project with linker code packing enabled my executable worked fine. One by one I placed my constants and code segments in the linker file and checked the executable, but when I added one particular module(quite a large module) the program crashes. Now I need to find out why its happening, because I have to bunch all the functions in that module at a particular location. Any suggestions why this could be happening?? Thanks, -Binu
Why not disable linker code packing for that file (module)? Jon
"I have not tried the simulator, by using the simulator how can I find the problem? could you be more specific?" If it works in the simulator, but fails in the target, this suggests that the problem lies in your hardware. Unless you have a full ICE, you get much better debugging capabilities in the simulator - call trace, etc You can can usually run under much more controlled conditions in the simulator. "I know the program is crashing on invoking some specific function through key-board." Can you put a breakpoint on the call to that function, then step through and see where it all goes pear-shaped?
"Any suggestions why this could be happening??" Dodgy pointers? Faulty memory somewhere in that region?
Andrew, I am not using full ICE I just have ROM emulator for downloading my hex files. I am using prints for debugging my code right now! I checked the ACALL and AJMP in disassembly, everything seems to be fine. Jon, Is it possible to disable linker packing for a particular file. How do we do it from uV2 IDE? Now if I rearrange my code segments in the linker directive file the executable works fine. But unforutantely I need to place some code segments at particular location in the code memory and this is causing problem! I have a strong feeling the linker is violating some page boundary because the code genereated by the compiler shouldn't be affected by the link order. Correct me if I am wrong.... -Binu
Binu, If you right click on the appropriate file in the file list at the left hand side of the screen and select "Options for file", "C51" there is a check box for linker code packing for that particular file. In the project I'm working on at the moment the 'tick' in the box is greyed out and I can't uncheck it but you may be able to. I've had some strange behaviour from the IDE particularly with projects that have been converted from BL51, it seems to work better if you create a new project from scratch. It also seems a bit strange to me that code packing can be disabled for an individual module - I thought the call/jump optimisation would have to be performed on the complete program after linkage and all other optimisations to gain maximum benefit. If I were you I'd invest a bit more time investigating a build that doesn't work properly to try to find out exactly where the code is going wrong. If you 'fix' the problem by changing options or rearranging code location you will never know if you have a bug waiting to catch you out next time you make changes to the code, or even worse a bug that is affecting your program in some way that you're not spotting in testing. I find debugging (as you are doing) on the target via the serial port with printf() very effective in most cases. Of course I do have a vested interest - if you do find a bug in the linker I'd like to know about it! Dafydd
"I am not using full ICE I just have ROM emulator ... using prints for debugging..." In that case, you definitely need to try it in the simulator!
Jon, Is it possible to disable linker packing for a particular file. How do we do it from uV2 IDE? 1. Right click on a file or group in the project list. 2. Select Options for (filename or groupname). 3. Go to the C51 tab. 4. Uncheck linker code packing. Linker code packing is enabled for modules compiled with the objectadvanced directive. That's all that the linker code packing check box does. Take a look at the following knowledgebase article for more information: http://www.keil.com/support/docs/2297.htm Jon
"Linker code packing is enabled for modules compiled with the objectadvanced directive. That's all that the linker code packing check box does." Do you mean that the check box controls whether the OBJECTADVANCED directive is used or not? I can see the OBJECTADVANCED directive in the compiler control string window in the C51 tab and the linker code packing check box is checked with a greyed out tick. I cannot uncheck the check box or find any other way of removing the OBJECTADVANCED directive other than disabling it for the entire project via the target options. Any ideas?
I can see the OBJECTADVANCED directive in the compiler control string window in the C51 tab and the linker code packing check box is checked with a greyed out tick. I cannot uncheck the check box or find any other way of removing the OBJECTADVANCED directive other than disabling it for the entire project via the target options. Ahh yes. I see now. Well, sorry for that suggestion. That check box was enabled in a BETA version and I thought it would continue to be available. Jon