User Tools

Site Tools


how_to_mix_c_and_asm

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to_mix_c_and_asm [2006/10/15 09:35]
127.0.0.1 (old revision restored)
how_to_mix_c_and_asm [2008/09/29 12:27] (current)
wackazong
Line 4: Line 4:
 You might have to declare some additional variables, but the concept is quite straightforward. You might have to declare some additional variables, but the concept is quite straightforward.
  
 +Do not forget to include the header file of your processor from the SDCC header files, or variables like PRODL will not be defined: e.g. #include <​pic18f4685.h>​
  
 <code c> <code c>
-unsigned char Scale_7bit(unsigned char evnt2, unsigned char min, unsigned char max) +unsigned char Scale_7bit(unsigned char evnt2, unsigned char min, unsigned char max) {
-{+
   // scaled value is (<8-bit random> * ) >> 8   // scaled value is (<8-bit random> * ) >> 8
   PRODL = evnt2 << 1; // 8bit value   PRODL = evnt2 << 1; // 8bit value
Line 20: Line 20:
 </​code>​ </​code>​
  
 +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://​www.midibox.org/​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.1160904901.txt.gz · Last modified: 2007/04/07 02:47 (external edit)