Kim Cheolho
Joined: 27 Nov 2013 Posts: 1
|
How can i use div.ud in compiled result? |
Posted: Wed Nov 27, 2013 3:56 pm |
|
|
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);
}
} |
Last edited by Kim Cheolho on Thu Nov 28, 2013 6:07 pm; edited 1 time in total |
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Thu Nov 28, 2013 2:33 am |
|
|
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 |
|