在IAR提供的库函数里有以下内容:
/*
* Support for efficient switch:es. E.g. switch(__even_in_range(x, 10))
*
* Note that the value must be even and in the range from 0 to
* __bound, inclusive. No code will be generated that checks this.
*
* This is typically used inside interrupt dispatch functions, to
* switch on special processor registers like TAIV.
*/
原型为:
unsigned short __even_in_range(unsigned short value, unsignedshort upper_limit);
功能:
只能与switch 语句结合使用,判断value 是否为偶数且小于等于upper_limit。
在msp430里经常被用在多源中断的查询中,如 switch( __even_in_range(TAIV,10)
只有在TAIV的值是在0--10内的偶数时才会执行switch函数内的语句
其作用是提高switch语句的效率