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

Call a C function from a asm code ?

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







Call a C function from a asm code ?
PostPosted: Mon Aug 20, 2007 9:01 am     Reply with quote

hello,
i dont arrive to call a function from a asm code declared between the beacon #asm ... #endasm.

Code:

#INT_GLOBAL
isr()             
{
#asm

/* Rb0 : */
   btfsc   INTCON, INT0IE
   btfss   INTCON, INT0IF
   bra   finIntHP
/*endasm
   intRb0();                                   /* RUN !!!*/
#asm*/
   call           intRb0                       /* BUT NOT HERE*/

   bcf      INTCON, INT0IF
   bra    finIntHP

finIntHP:
         retfie   FAST
#endasm
}

void intRb0(void)
{
   ledverte   = !ledverte;
}

=>
*** Error 72 "D:\Projet\Projet Pic\test\ccs\18 f 258\flashLed.c" Line 233(1,7): Incorrectly constructed label



I dont arrive to bind C function with asm.
I have test to declare label or call _intRb0 or _intRb0_ or other but nothing run.

Thanks
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Aug 20, 2007 10:31 am     Reply with quote

A function needs to be either forward referenced or actually declared before
the compiler encounters its use.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 20, 2007 10:33 am     Reply with quote

See the post at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?p=15502
Fgazier
Guest







Re
PostPosted: Mon Aug 20, 2007 11:11 am     Reply with quote

Yes ,I know and I use that but this way isn't very beautiful ...

but more pesky is that, I can work with asm declaration (... EQU ...) and I dont arrive to master the whole compilation, assemblage and binding.

PS : with other compiler, for using label asm in C, we must add __ before each label. May be there is the same trick in CCS.
=> here it is the inverse.
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Mon Aug 20, 2007 11:58 am     Reply with quote

Why do you need to use assembly?

Everything you posted can be handled with c statements.

Just an example
Code:

#pragma byte INTCON = getenv( "SFR:INTCON" )
#pragma bit INT0IE = INTCON.4
#pragma bit INT0IF = INTCON.1


#pragma INT_GLOBAL
void isr( )
{
   if ( !INT0IE )
      return;

   if ( INT0IF }
      return
      
   intRb0();
}
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Tue Aug 27, 2019 3:38 pm     Reply with quote

Old topic but no other thread about the issue.

http://www.ccsinfo.com/forum/viewtopic.php?p=15502 is not valid anymore.

Does anybody know the trick?
temtronic



Joined: 01 Jul 2010
Posts: 9236
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 27, 2019 4:02 pm     Reply with quote

he could also just convert the line...

ledverte = !ledverte;

into asm...
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Tue Aug 27, 2019 11:47 pm     Reply with quote

You don't say 'what PIC'?.
Important, since a lot of PIC18's have a bug with the RETFIE FAST
instruction. If your chip has this, you will need to be saving the registers
yourself...
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Mon Sep 02, 2019 4:28 pm     Reply with quote

Mine are the 4620 and 46k42.

The question is actually how does CCS see the C defined functions in the #asm blocks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Sep 02, 2019 11:51 pm     Reply with quote

Basically it doesn't.
The way to call a C function, is to do it in C as is shown. The C function
is not a label that can be called, and the compiler can change it's mind
about whether a function is callable or jumpable to (or even inline).
'Called' in C, the compiler will keep track of the various forms, and
correctly handle all three methods. Trying to do it directly from assembler
is 'asking for problems'.
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