The mspgcc in use is msp430-gcc (GCC) 3.2.3, running on winXp with the
following compiler options:
-mmcu=msp430x436 -g -Os -Wall -Wcast-align -Wcast-qual -Wimplicit
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith
-Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch
-Wunused -Winline
The cpu is msp430f436.
I've the following error code:
typedef unsigned long u32;
typedef unsigned long long u64;
#define U32_MAX ((u32)4294967295uL)
u64 macc;
if (macc > (u64)U32_MAX)
{
macc = U32_MAX;
}
The compiler generate a code of the comparison "if (macc > (u64)U32_MAX)"
completely wrong and the expression "macc = U32_MAX;" is executed every
time. The compiled code is the following:
.LM160:
cmp #llo(1), 6(r1) ; 180 *cbranchhi [length = 3]
jhs .L161
cmp #llo(0), 6(r1) ; 181 *cbranchhi [length = 3]
jne .L160
cmp #llo(1), 4(r1) ; 183 *cbranchhi [length = 3]
jhs .L161
cmp #llo(0), 4(r1) ; 184 *cbranchhi [length = 3]
jne .L160
cmp #llo(0), 2(r1) ; 186 *cbranchhi [length = 3]
jhs .L161
cmp #llo(-1), 2(r1) ; 187 *cbranchhi [length = 4]
jne .L160
cmp #llo(0), @r1 ; 188 *cbranchhi [length = 3]
jlo .L160
.L161:
.stabn 68,0,639,.LM161-U32mulFloatToU32
.LM161:
mov #llo(-1), @r1 ; 196 *movdi3 [length = 8]
mov #lhi(-1), 2(r1)
mov #llo(0), 4(r1)
mov #lhi(0), 6(r1)
.L160:
Andrea