Very long dividing 32x16.

Post your requests and ideas on the future development of mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
slavyannn
Posts: 1
Joined: 08 Jan 2014 22:21

Very long dividing 32x16.

#1 Post by slavyannn » 08 Jan 2014 23:08

Hello!

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;
/*...*/
}
Compiler creates:

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
This code reqires 450-500 cycles.

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
In this case operation requires 19 cycles.

I hope, you pay some attention to this message and take account of it in future.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Very long dividing 32x16.

#2 Post by dejan.odabasic » 13 Jan 2014 17:06

Hello,

Thank you very much for sending us your suggestions with such elaborate explanation.
I'll present your detailed explanation to our developers and they will consider it for future update.

Best regards.

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 Wish List”