CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Calling ASM functions from C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joe06
Guest







Calling ASM functions from C
PostPosted: Wed Feb 26, 2003 6:45 am     Reply with quote

Hi All,
Is it possible to call asm function from C ?
as follow :

// ******************** ASM FUNCTIONS HERE ****************
void asm_source(void)
{
#asm
call function1
call function2

function1: return
function2: return

#endasm
}

// ******************** CALLS IN C HERE ****************
void main(void)
{
function1(); // How to prototype this ASM function ?
function2(); // How to prototype this ASM function ?

// or do I need to call from inline ASM as well

#asm
call function1
call function2
#endasm
}

any help greatly appreciated ...
joe
___________________________
This message was ported from CCS's old forum
Original Post ID: 12115
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Calling ASM functions from C
PostPosted: Wed Feb 26, 2003 2:30 pm     Reply with quote

:=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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group