Taking advantage of FF1 and BITREF instructions

Discussion created by Butcher on Aug 14, 2007
Latest reply on Aug 29, 2007 by Butcher
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:

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?


Mark Butcher