First of all, I just wann to thank you, MikroElektronika, for you developments.
I used to work with PIC18 controllers. But I wasn't satisfied by speed of multiplying and dividing operations. So why I decided to work with PIC24. Datasheets promise that 16x16 multyplying operation require 1 cycle and dividing 32x16 - 19 cycles. I was very impressed by perfomance of PIC24s, and downloaded mikroC PRO for dsPIC30/33 and PIC24. When I checked the speed of dividing 32x16, I was very dissapointed, because in fact it required almost 500(!) cycles! When I looked through .asm file, I understood, what is the problem. Look at the code below:
Code: Select all
int quotient, divisor;
long dividend;
void main{
/*...*/
dividend = 1000000;
divisor = 1000;
quotient = dividend / divisor;
/*...*/
}
Code: Select all
;MyProject.c,85 :: quotient = dividend / divisor;
MOV _divisor, W2
ASR W2, #15, W3
MOV _dividend, W0
MOV _dividend+2, W1
SETM W4
CALL __Divide_32x32
MOV W0, _quotient
The code that compiler should create:
Code: Select all
MOV _dividend, W0
MOV _dividend+2, W1
MOV _divisor, W2
REPEAT #17
DIV.SD W0, W2
MOV W0, _quotient
I hope, you pay some attention to this message and take account of it in future.