This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

16 bit pointers?

I have a piece of code that calls various function pointers in an array.
These are read-only in Flash, meaning on the Cortex-M3 I am using they
are always in the first 16 KB.

Is there any feature of the Keil compiler to use 16 bits for certain pointers,
an attribute or similar? I'm looking to save code space. My first thought
was to just have them cast to uint16_t, but I am worried that might interfere
with the compiler's ability to optimize.

Parents
  • I wonder if you can save any significant amount of ROM this way. You are only trying to save 2 bytes per function pointer in the array. If the number of pointers is roughly the same as the number of functions, function sizes will dominate massively. If, on the other hand, there are few functions and many (duplicate) function pointers, perhaps you can benefit from addressing the functions with a short (8-bit) index using a look-up table.

Reply
  • I wonder if you can save any significant amount of ROM this way. You are only trying to save 2 bytes per function pointer in the array. If the number of pointers is roughly the same as the number of functions, function sizes will dominate massively. If, on the other hand, there are few functions and many (duplicate) function pointers, perhaps you can benefit from addressing the functions with a short (8-bit) index using a look-up table.

Children