Hi all, We are using the C51 with OPTIMIZE (9, SIZE) and we have a problem the code space. The question is : if we change to CX51 and use OPTIMIZE (11, SIZE) , do you think we can save some code bytes? We are using a w925EC625 from WINBOND, 80c51 based standard. Do you have another idea to reduce the code size ?. Best Regard and thanks for your help.
Yes - I had a case where moving 1 variable from XDATA to DATA saved several Kbytes !! (the variable was a "key" used throughout the code).
Firstly, thanks to all for your answers. Until now, we had applied different techniques to reduce the code: - Pass xdata to data and idata selectively in order to reduce the code an loss speed. - Use of global variables to pass and share parameteres with functions. - No registeer bank swithing, using the BANK1-BANK3 as a data variables. - Overlay of variables in data estructures. - Compressing the MMI display messages. - Extensive use of assembler... But unfortunately we was very near of the boundary of code. Yesterday we had the chance to compile with the LX51 (Thanks Andy), and really it manages to decrease the code size. Best regards, and thanks to all.
Until now, we had applied different techniques to reduce the code: Strange. A good number of those are useless, some even counter-productive as far as conserving code space is concerned. Those are mostly measures for reducing data memory usage. Now, being efficient in your use of DATA space will generally help keep the code small, too. But at least some of the techniques you've used for that (manual overlaying, manual globalization of function arguments) will interfere with the compiler doing the same or similar things. You may be doing yourself a disservice there. Same with the 'extensive use of assembler' stuff --- that may help, or it may disrupt the compiler's own optimizations just enough to finally yield bigger instead of smaller code.
Pass xdata to data and idata selectively in order to reduce the code an loss speed Possibly just a language problem. Does the above mean "change a variables declaration from xdata to data" or does it mean "move that value from xdata to data before processing it" One is very effective, the other may be counterproductive. Erik
Hi, Sorry for my poor English, the general idea is, "change a variables declaration from xdata to data". The reality is to move selected xdata variables to data, and the original ones in data move to xdata in order to reduce code size, and not to decrease the stack size. Additionally defining the pointers in idata, has the same effect than in data. Then is more convenient to use the data segment for other types of varables due to the diferente addressing mode of each area. Thanks Erik.
just a fact (I see it as such): If you use the large/huge model and change some variables to DATA you will get less gain than if you use the small model and change some to XDATA. Just the process is different, but the difference in result can be dramatic. Must be something about the way a DNA computer works. Erik