Comments on AN60630 - PSoC® 3 – 8051 Code and Memory Optimization

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 This is a great app note.  I used a lot of the tips in here to free up a lot of space in my project.  Another technique that was not mentioned in the app note that I found in the Keil documentation is using the "small" and "compact" Keil keywords at the end of function declarations and definitions.  This instructs the compiler more clearly how you want it to handle arguments and returned values in memory.

   

I tried one of the techniques that ended up using more space than before I changed the code.  I have a global array of structs.  The array is stored in pdata memory and I was passing a pointer of a struct array element to a function and using the -> operator to access the struct members.  Since it is a global struct, I thought I would change the function argument to simply the uint8 index of the array element I wanted to work with and then access the members of the struct directly with the index.  After making the changes, and replacing probably two dozen -> operators, the code size was about 40 bytes larger.  I'm not really saying that the app note is wrong.  It may have been simply accessing of the array with the index.  In any case, it's food for thought.

0 Likes
1 Reply
Anonymous
Not applicable

Peter,

   

this is what forums are all about. Exchange of experience, talking about the good stuff, talking about the not so good stuff, what was missing and sharing your thoughts. As you said, it is food for thoughts and your point about the "small" and "compact" key words is well taken.

   

You tried out the tips, you got mostly success and reduced your code size (and probably even sped up some routines) and you also found one instance where the code size increased.

   

If all developers would study the application notes like you did with this one, there would be more happy campers 🙂

   

Thank you for sharing your experience and the good hints with the Keil key words

   

Robert

0 Likes