Electronics > Microcontrollers

Calling ASM functions in C

<< < (6/6)

nctnico:

--- Quote from: Psi on April 29, 2012, 12:23:55 am ---Yeah, for my above example that will work because min/max are read out of eeprom at poweron, so the reciprocal can be calculated once at that point. Thanks

But i can't see it working in other areas of my code, such as this table X/Y interpolate function.
As the variables change in realtime


--- Code: ---// (T,B,L,R = top/bot/left/right)
uint8_t quadinterpolate(uint8_t *quadTL, uint8_t *quadTR, uint8_t *quadBL, uint8_t *quadBR,
                        uint8_t *rowlabel1, uint8_t *rowlabel2, uint8_t *collabel1, uint8_t *collabel2,
                        uint8_t *inputrow, uint8_t *inputcol)
{
uint8_t colstep,rowstep,quadCAB,quadDAB,temp1;
div_t divout;

colstep = *collabel2-*collabel1;
rowstep = *rowlabel2-*rowlabel1;
temp1 = *inputcol - *collabel1;

divout =  div( (*quadTL-*quadTR) , colstep );
quadCAB = *quadTL - (divout.quot * temp1);

divout =  div( (*quadBL-*quadBR) , colstep );
quadDAB = *quadBL - (divout.quot * temp1);

divout =  div( (quadCAB-quadDAB) , rowstep );
return (quadCAB - (divout.quot * (*inputrow - *rowlabel1)));
}
--- End code ---

--- End quote ---
Because this is all 8 bit you can use lookup tables. If you don't have the space you should consider moving to a faster controller. That will make these headaches go away very quickly. I doubt you can get more speed by using ASM. C compilers are very good at optimizing but on an 8 bit controller performance is very limited.

Psi:
Ok, I'll continue to have a play with the code.  It's not too bad at present, just slower than i would like.
The mcu isn't running at its max speed yet, so i have some other options available.

Thanks

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod