CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How can i use div.ud in compiled result?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kim Cheolho



Joined: 27 Nov 2013
Posts: 1

View user's profile Send private message

How can i use div.ud in compiled result?
PostPosted: Wed Nov 27, 2013 3:56 pm     Reply with quote

Hi!

I need high speed division unsigned 32bit/16bit.
But compiler does't support div.ud command.
Only private code which take long long time.
So I made #asm code like below.
How can i use div.ud in compiled result like MyDiv code?
Code:

//////  sample code for dsPIC30F2011
//////  Compiler version is 5.016
unsigned int16 MyDiv(unsigned int32 i32, unsigned int16 i16)
{
   unsigned int16 hi,lo, rt;
   
   lo = (unsigned int16)i32;
   hi = (unsigned int16)(i32>>16);

#asm
   mov lo, w6;
   mov hi, w7;
   mov i16, w8;
   repeat #17;
   div.ud w6, w8;
   mov w0, rt;
#endasm
return rt;
}
void main()
{

unsigned int32 i32 = 691200;
unsigned int16 i16 = 500;
unsigned int16 result;

   while(TRUE)
   {
      result = i32 / i16;
      result = MyDiv(i32, i16);
   }

}
Very Happy

Last edited by Kim Cheolho on Thu Nov 28, 2013 6:07 pm; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Thu Nov 28, 2013 2:33 am     Reply with quote

You already are...

Nothing better at the moment, _but_ point out to CCS, that these chips have a hardware unsigned division, and hopefully they will consider adding it's use to their code.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group