Ok, in this thread, I will periodicly post short functions (such as the one below), that I believe would be quicker in asm. Now, it's time for the great asm coders at pm, to show their stuff, and prove me right (hopefully).
This first funtion multipliest 2 UINT32 (unsigned long ints) together.
Although that may be efficient c (it still looks like it could be reduced, I bet that we can get more efficient arm asm, so have at it, and good luck.
This first funtion multipliest 2 UINT32 (unsigned long ints) together.
- Code:
static void multu(UINT32 v1,UINT32 v2)
{
UINT32 v1h,v1l,v2h,v2l;
UINT32 ll,hl,lh,hh,mid,mid2;
v1l = (UINT16)v1;
v1h = ((UINT32)v1)>>16;
v2l = (UINT16)v2;
v2h = ((UINT32)v2)>>16;
ll = v1l*v2l;
hl = v1h*v2l;
lh = v1l*v2h;
hh = v1h*v2h;
/*
|ll|ll|
|lh|lh|
|hl|hl|
|hh|hh|
--------------
| mid |
|carry|
*/
mid = hl+lh;
if (mid<hl) hh+=0x10000;
mid2 = mid + (ll>>16);
if (mid2<mid) hh+=0x10000;
rLO = (UINT16)ll|(mid2<<16);
rHI = hh+(mid>>16);
}
Although that may be efficient c (it still looks like it could be reduced, I bet that we can get more efficient arm asm, so have at it, and good luck.