I've writing code for selecting bits from registers. My code in C is:
int16_t nextPhI=((RES2<<1) |((RES1&0x8000)==0x8000)) +((RES1&0x4000)==0x4000);
This gives the assembler
40: 5f 02 rlam #1, r15 ; 42: 4e 19 0a 10 rpt #15 { rrux.w r10 ; 46: 0f da bis r10, r15 ; 48: 4d 19 0e 10 rpt #14 { rrux.w r14 ; 4c: 5e f3 and.b #1, r14 ;r3 As==01
Then merges lower down.
But should be able to implement this as
BIT #8000, RES1 RLC RES2 BIT #4000, RES1 ADDC #0, RES2
Or
RLC RES1 RLC RES2 RLC RES1 ADDC #0, RES2
Where RES1 and RES2 are which ever registers they end up in.
Now can't find how many instruction cycles rpt#15 { rrux.w takes - but it can't be good.
So is there a way to get gcc to c code that compiles to the simple code above, or do I have to do it as "asm" code?