
Originally Posted by
HenrikOlsson
Mike,
So obviously BoostC compiles this to faster code but doesn't the BoostC compiled code you posted use GOTO as well?
I posted 16F1827 code. A slightly unfair comparison because 18F devices don't have a "lsrf" instruction.
I didn't realize you were using an 18F until you posted your assembler output, and so I tested the following code which is similar to yours, for an 18F in BoostC;
Code:
MB_CRC ^= work; //
for(MB_j=0; MB_j<8; MB_j++) //
{ if(MB_CRC.0) //
{ MB_CRC >>= 1; //
MB_CRC ^= 0xA001; //
}
else //
{ MB_CRC >>= 1; //
}
} // Next bit in the byte
Here's the BoostC output which uses "bra" instructions and runs in about 115 cycles (worst case);
Code:
0008 label1
0008 500A MOVF gbl_work, W
000A 1A05 XORWF gbl_MB_CRC, F
000C 6A09 CLRF gbl_MB_j
000E label2
000E 0E08 MOVLW 0x08
0010 6009 CPFSLT gbl_MB_j
0012 D7FA BRA label1
0014 A005 BTFSS gbl_MB_CRC,0
0016 D008 BRA label3
0018 90D8 BCF STATUS,C
001A 3206 RRCF gbl_MB_CRC+D'1', F
001C 3205 RRCF gbl_MB_CRC, F
001E 0E01 MOVLW 0x01
0020 1A05 XORWF gbl_MB_CRC, F
0022 0EA0 MOVLW 0xA0
0024 1A06 XORWF gbl_MB_CRC+D'1', F
0026 D003 BRA label4
0028 label3
0028 90D8 BCF STATUS,C
002A 3206 RRCF gbl_MB_CRC+D'1', F
002C 3205 RRCF gbl_MB_CRC, F
002E label4
002E 2A09 INCF gbl_MB_j, F
0030 D7EE BRA label2
Bookmarks