User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
how_to_mix_c_and_asm [2008/09/10 17:31]
audiocommander code plugin disappearance is killing me :/
how_to_mix_c_and_asm [2008/09/29 12:27]
Line 1: Line 1:
-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. 
-<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; ​ // range 
-    movf _PRODL, W 
-    mulwf _PRODH, 0 
-  return min + PRODH; 
-Also, as well as the above example of '​inline ASM', it is possible to include ASM code in .inc include files, and call that ASM code from within your C application. Please see the forum thread [[http://​​forum/​index.php?​topic=7698.0|using assembler in C - question about _ in front of macro names]] for more info. 
how_to_mix_c_and_asm.txt ยท Last modified: 2008/09/29 12:27 by wackazong