This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
I was going through TI's CRC Guide - Page 3 where I found a statement that says
"Processors tend to be much better at operating on bytes and words than bits"
Could someone please clarify what does it mean by "better" over here? Is it in terms of number of machine cycles taken by instructions? If I am not mistaken then, then the last time, I checked machine cycles of each instruction, byte instructions such as DIV and MUL took 4 machine cycles for the ancient Intel CPU's which more than any other instruction. Am I being mistaken when I say than bit operations such as Left Shift or right Shift are inefficient when compared to Byte Operations?
When you want to change a single bit, you either have to use separate one-byte variables for each bit, or you have to mask out the bit so that the other bits in the variable are not affected.
The MSP430 has BIS/BIC instructions to set/clear bits, but this would still require two instructions:
// one byte a = new_value; // one bit a &= ~BIT_MASK; a |= new_bit;
If you do not know the bit number, you have to add more instructions for shitfting.
The MSP430 does not have a barrel shifter; more shift steps need more cycles.
I am sorry but my concern remain still at the same state. Allow me to share an example to explain the doubt I have.
Suppose, int x = 2; and in another variable int result=0; I am supposed to get the twice of variable x. Now, in (Case 1) I make the use of arithmetic operators and I write something like:
result = x * 2;
whereas in (Case 2) I make the use of shift operator and write something like:
result = x<<1;
Could you please elaborate that which case is likely to execute faster and why?
Is the statement in the CRC pdf Document, applicable for most of the CPU's or just MSP430's ?
Clemens Ladisch said:But CRC does not use multiplication; it is defined on a bit stream, and that is what the application note is talking about.
Thanks. Pretty much puts most of my questions to rest.
**Attention** This is a public forum