All data items are held in the native byte order of the MAXQ20 processor. The plain character type is signed by default. The floating-point types float and double are implemented as 32-bit and 64-bit IEEE floating-point.

Data Type Size in bytes Alignment in bytes
char, signed char, and unsigned char 1 1
int and unsigned int 2 2
short and unsigned short 2 2
long and unsigned long 4 2
long long and unsigned long long 8 2
float and double (compiled with -msd) 4 2
double and long double 8 2
type * (pointer) 2 2
enum (enumeration) 2 2
Pointer types

The MAXQ20 pointer registers can work in two modes, either as a pointer to a byte or as a pointer to a word. Thus, all data items in the MAXQ20 have a byte address and a corresponding word address. For byte-addressable data, the CrossWorks compiler stores a standard byte-address pointer. However, for data that can only be addressed as words, the compiler stores a word-address pointer.

The compiler does this to improve code density and execution speed, and in many cases this is exactly what you want. There are, however, a number of things that you must be aware of when passing pointers from C code to assembly language subroutines.

Examples

Consider the structure:

struct bytes
{
  char c1;
  char c2;
};

Because the structure contains only byte-aligned data, a struct bytes * pointer is a byte-address pointer.

Consider the structure:

struct words
{
  int i;
  float f;
};

Because the structure contains only word-aligned data, a struct words * pointer is a word-address pointer.

Now consider the structure:

struct mixed
{
  int i;
  char c;
  float f;
};

Because the structure contains both word-aligned and byte-aligned data, a struct mixed * pointer is a byte-address pointer.

The compiler transforms between byte pointers to word pointers transparently. However, because accesses to structures with members that have mixed data alignments are common, the C compiler will need to transform pointers between byte and word pointers with structures of this type which can lead to inefficient code. To improve code density and execution speed you could change the data types held in the structure so they all have the same alignment.