PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Calling ASM functions from C |
Posted: Wed Feb 26, 2003 2:30 pm |
|
|
:=Hi All,
:=Is it possible to call asm function from C ?
--------------------------------------------------
It's best if you provide an individual C "wrapper"
function for each ASM function.
<PRE>
#include "16F877.h"
#fuses HS, NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
#use Delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
<BR>
char function1(char value);
<BR>
//======================================
main()
{
int result;
int c;
<BR>
c = 0x55;
<BR>
result = function1(c);
<BR>
printf("result= \%x\n\r", result);
<BR>
while(1);
}
<BR>
//=======================================
// This function adds 1 to the input value
// and returns the result.
<BR>
char function1 (char value)
{
#asm
movlw 0x01
addwf value,w
movwf _return_
#endasm
}
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12133 |
|