Most efficient data length?
I'm still new to the Cortex M architecture, but I was wondering which is the most performing data type for integers smaller than 256 if space is abundant? Is it uint8_t, uint16_t, or uint32_t, or are they all the same?
I'm still new to the Cortex M architecture, but I was wondering which is the most performing data type for integers smaller than 256 if space is abundant? Is it uint8_t, uint16_t, or uint32_t, or are they all the same?
Depends what you're doing with the data, manipulating it as 32-bit is generally the most efficient, ie using 8-bit or 16-bit isn't faster, and might require masking or shifting. The compiler's default 'int' size is 32-bit, and you should use this for loop iterators rather than the smallest thing you can fit it in.
If you have large tables/arrays of constants use the 8, 16 or 32-bit form the data fits into.
In assembler immediate loads have a format that goes beyond 8-bit (8-bit pattern shifted across 16 positions), things that can't be represented with the scheme are placed in a literal pool usually at the end of the function, and a PC relative load. The assembler/compiler can choose how to represent values in the most efficient fashion.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.