main() instead of __main() erases my data section

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

main() instead of __main() erases my data section

914 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JamesB on Sat Jun 11 12:24:39 MST 2011
Hello,

if I set cr_startup_lpc13.c to use main() instead of Redlib's __main, my data section becomes only 4 bytes. I'm guessing the linker is eliminating it. What do I have to do to get it back? I don't have enough code space for Redlib's toupper() and the like (as shown by the map file) and don't use them anyway.

Thank you

James
0 Kudos
Reply
4 Replies

824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Jun 13 00:22:02 MST 2011
There have been numerous Redlib structural and initialisation changes in the forthcoming LPCXpresso4 which address issues of the sort you describe.

http://support.code-red-tech.com/CodeRedWiki/NewInVersion4

We expect LPCXpresso4 to be release later this month, but in the mean time you could try out an evaluation of Red Suite 4. Details of how to request an evaluation code can be found here:

http://support.code-red-tech.com/CodeRedWiki/UpgradingToRedSuite4

Regards,
CodeRedSupport
0 Kudos
Reply

824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JamesB on Sun Jun 12 10:02:04 MST 2011
An embedded one would be much better off using if (x >= 'A' && x <= 'Z') and the like for the various cases. Have a look at charmap. It would be two branches for tolower, two for toupper. So maybe 20 bytes of code and no RAM usage each.

In any case, I'm rid of it so that's good.
0 Kudos
Reply

824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Sun Jun 12 01:57:29 MST 2011
Do you actually understand how the toupper()/tolower/isupper()/etc functions work? You will find that any C library implements these function by having a character array (for all 256 characters possible in a 'char') that is then indexed by the character you are operating on. I think that you will find that EVERY C library will do it pretty much the same way.
0 Kudos
Reply

824 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JamesB on Sat Jun 11 15:58:29 MST 2011
Never mind. I just severely underestimated how bloated the minimal Redlib is... I figured those 500 bytes of RAM were [I]mine[/I]...
0 Kudos
Reply