Tool/software: TI C/C++ Compiler
Consider this short test code. The trouble is that that signed 32bit number comparison
if(foo<tempmin){
return total;
}
does not produce any assembler code, it always skips to the return. Why?
#include <msp430.h>
#include <stdint.h>
#define SHORT int16_t
#define LONG int32_t
#define USHORT uint16_t
SHORT Temp_Integral(SHORT total, USHORT value, USHORT setpoint, USHORT max);
/**
* main.c
*/
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
Temp_Integral(0, 4096, 4100,32);
return 0;
}
#pragma FUNC_CANNOT_INLINE(Temp_Integral)
SHORT Temp_Integral(SHORT total, USHORT value, USHORT setpoint, USHORT max){
LONG volatile tempmin=-0x7FFE;
LONG volatile foo;
LONG volatile diff=0;
/*
* Negative roll-over-check
*/
if(((LONG) value-setpoint)<tempmin){
return total;
}
diff=(LONG) value-(LONG) setpoint;
foo=total+diff;
if(foo<tempmin){
return total;
}
/*
* Wind-up limit
*/
if((total+diff)>max){
return max;
}
return total+diff;
}