how_to_mix_c_and_asm
Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
how_to_mix_c_and_asm [2006/05/11 10:37] – created audiocommander | how_to_mix_c_and_asm [2006/10/15 09:35] – (old revision restored) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | It's actually quite easy! | ||
+ | As you can see in the example below, just enclose the ASM part with // | ||
+ | |||
+ | You might have to declare some additional variables, but the concept is quite straightforward. | ||
+ | |||
+ | |||
+ | <code c> | ||
+ | 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; | ||
+ | __asm | ||
+ | movf _PRODL, W | ||
+ | mulwf _PRODH, 0 | ||
+ | __endasm; | ||
+ | |||
+ | return min + PRODH; | ||
+ | } | ||
+ | </ | ||
how_to_mix_c_and_asm.txt · Last modified: 2008/09/29 12:27 by wackazong