Topic: Dividing speed and page0 problems
Hi,
I have some questions about the compiler:
1) I want to divide a variable to 2000 as fast as the STM8S microcontroller can. Is there a difference between the statements below in terms of speed?
x = y / 2000;
// and
x = (y >> 4) / 125; // (y >> 4) is equal to (y / 16)
2) Is there a difference in terms of speed between dividing a variable to a small number or to a big number of same type? For example:
a = b / 1000; //1000 is short
// and
a = b / 2000; //2000 is also short
3) I have a problem about page0 keyword. The code is like below:
static page0 signed int VariablesArray[3];
static page0 signed long SumOfSquaresArray[3];
...
...
for(a=0; a<3; i++)
{
SumOfSquaresArray[a] += (long) VariablesArray[a] * VariablesArray[a];
}
If a define SumOfSquaresArray in page0 like above, I see that the multiplication process does not execute. But if I remove the page0 keyword from the definition of SumOfSquaresArray, the multiplication executes successfully.
Instead of using SumOfSquaresArray, I used 3 different page0 variables and I saw that multiplication executed successfully.
If I use a page0 pointer instead of using SumOfSquaresArray, I see the same error.
What is the cause of this unsuccessful multiplication?
And I also want to learn whether I can define a pointer in page0 or not?
Thanks!