how_to_mix_c_and_asm
This is an old revision of the document!
It's actually quite easy! As you can see in the example below, just enclose the ASM part with __asm and __endasm;
You might have to declare some additional variables, but the concept is quite straightforward.
unsigned char Scale_7bit(unsigned char evnt2, unsigned char min, unsigned char max) { // scaled value is (<8-bit random> * ) >> 8 PRODL = evnt2 << 1; // 8bit value PRODH = max-min+1; // range __asm movf _PRODL, W mulwf _PRODH, 0 __endasm; return min + PRODH; }
how_to_mix_c_and_asm.1160904901.txt.gz · Last modified: 2007/04/07 02:47 (external edit)