Taking advantage of FF1 and BITREF instructions

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Taking advantage of FF1 and BITREF instructions

1,976 次查看
mjbcswitzerland
Specialist V
Hi All

I am interested to find out whether CW can take advantage of the FF1 (Find First One) and BITREV instructions for the Coldfire.

Consider the following interrupt routine, which is a dispatcher for the RTC interrupt in the M5223X. The RTC has one interrupt which can have 6 different sources so there is a loop checking through the possible interrupt status bits and calling each corresponding handler until no more interrupts are waiting:

Code:
static __interrupt__ void _rtc_handler(void){     int iIRQBit = 0;    while ((RTCISR & RTCIENR) != 0) {                                    // while enabled interrupts exist        if ((0x01 << iIRQBit) & RTCISR & RTCIENR) {            RTCISR = (0x01 << iIRQBit);                                  // clear interrupt            if (RTC_handler[iIRQBit] != 0) {                RTC_handler[iIRQBit]();                                  // call the interrupt handler            }        }        if (++iIRQBit >= 6) {            iIRQBit = 0;        }    }}

 If this interrupt routine were to be coded in assembler it could possibly benefit from the use of the FF1 instruction to get the position of any set bits - effectively FF1 will give the value of iIRQBit directly (if the value it returns if >= 6 it has found no interrupt status bits). An experienced assembler programmer could probably improve the routine's speed and size.

my question is - can CW take advantage fo the Coldfire instruction set to optimise by using FF1 (and BITREV if necessary) or is this something which can not be automated?
Alternatively are there any C-coding style which will be better suited to CW so that it can do so?

Regards

Mark Butcher

www.uTasker.com


标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

583 次查看
CrasyCat
Specialist III
Hello
 
I am afraid the only solution here would be to use inline assembler.
 
Let me double check with engineering in case I missed something on that topic.
This might take some time as my contact is in vacation right now, but I should be able to provide
you with an  answer by the end of the month.
 
Thanks for your understanding.
 
CrasyCat
0 项奖励
回复

583 次查看
CrasyCat
Specialist III
Hello
 
I get a confirmation from engineering.
Only way to get a FF1 or BITREF instruction generated is to encode it in inline assembler.
 
The compiler does not generate these instructions.
 
CrasyCat
0 项奖励
回复

583 次查看
mjbcswitzerland
Specialist V
Hi CrasyCat

Many thanks for clearing that up. Since the use of these instructions seems most beneficial in interrupt routines (based on the fact that they should generally be as efficient as possible - and usually they are also short) I may review using some inline assemby as am improvement potentional.

Regards

Mark

0 项奖励
回复