> Steve Underwood wrote:
> If you want specific lengths for integers, the standards compliant
> method is to include <stdint.h> and use:
> int8_t or uint8_t
> int16_t or uint16_t
> int32_t or uint32_t
> int64_t or uint64_t
To clear up confusion, signed and unsigned long long int are 64 bit wide for
MSP430-GCC. I can see this in the .stabs (debugging info inside elf):
long long
int:t(0,6)=...@s64;r(0,6);01000000000000000000000;0777777777777777777777;
long long unsigned
int:t(0,7)=...@s64;r(0,7);0000000000000;01777777777777777777777;
The recommended types from <stdint.h> are just an alias for then - see
.stabs:
int64_t:t(6,7)=(0,6)
uint64_t:t(6,8)=(0,7)
And if you look into <stdint.h> you can see simply
typedef long long int64_t;
typedef unsigned long long uint64_t;
Therefore this can't be the source of the problem. I can only guess, that
these 64 bit integers are not bug-free implemented in MSP430-GCC.
> In addition, because the relative lengths
> of ints and pointers varies, casting between ints and pointers should
> use intptr_t for the integer. This is guaranteed to be an integer
> capable of holding the full value of a pointer.
_This_ is what I want to avoid. Using a pointer makes my variable a stack
variable, which leads to time- and power-consuming RAM-accesses. I am using
the 64 bit integer as a concatenated vector with "elements" beeing 8, 16 or
32 bits wide, because 64 bit integers are passed to functions via registers
and if used as function result this holds, too. (Because there is only one
function result, I have to concatenate my results to a vector.)
Ok, usually one would use for this purpose something like that
typedef struct{
unsigned long element32 : 32;
unsigned int element16 : 16;
unsigned int element8a : 8;
unsigned int element8b : 8;
} mystruct;
but as a big disadvantage, MSP430-GCC maps such bitfields to the stack, if
they are bigger than 32 bits. And so my solution was the 64 bit integer
type, that is mapped to registers (if available). And because I have a
element of type unsigned char inside this unsigned long long int vector, I
found these bugs.
Ralf