Comments on AN60630 - PSoC® 3 – 8051 Code and Memory Optimization | Cypress Semiconductor
Comments on AN60630 - PSoC® 3 – 8051 Code and Memory Optimization
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.