6.4. Data Type Conversion

The Cortex®-M processors support a number of instructions for converting data between different data types.

6.4.1. Conversion of Data Size

On compilers for ARM® architecture, different data types have different sizes. A number of commonly used data types and its corresponding sizes on ARM compilers are shown in the following table (Table 6.7).

Table 6.7

Size of commonly used data types in C language for ARM® architecture

C data typeNumber of bits
“char”, “unsigned char”8
“enum”8/16/32 (Smallest is chosen)
“short”, “unsigned short”16
“int”, “unsigned int”32
“long”, “unsigned long”32
When converting a data value from one type to another type with a larger size, we need to sign extend or zero extend it. A number of instructions are ...

Get The Definitive Guide to ARM® Cortex®-M0 and Cortex-M0+ Processors, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.