__even_in_range()使用

在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语句的效率

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值