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 support@ccsinfo.com

Passing variables from C to Assembler

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



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

Passing variables from C to Assembler
PostPosted: Thu Nov 21, 2013 7:43 am     Reply with quote

Could some one please show how the passing of variables is achieved between a Pic c program and an inline #ASM routine and perhaps how we can get ASM modified variables back into the C program once again ,
I am working with a PIC18F device and using the CCS c compiler ver 4.141
my search for this topic on this forum has not given any meaningful results
many thanks
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Nov 21, 2013 7:49 am     Reply with quote

A variable is stored in a ram location with a specific address... you can reference this adress directly on ASM.
_________________
CCS PCM 5.078 & CCS PCH 5.093
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Nov 21, 2013 7:54 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=50807&highlight=asm
_________________
Google and Forum Search are some of your best tools!!!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19366

View user's profile Send private message

PostPosted: Thu Nov 21, 2013 7:54 am     Reply with quote

You don't have to!....

You can just use the C variables in assembler.
Code:

void main()
{
   int a;
   a=10;
   
#asm
   MOVLW 4
   ADDWF A,W
   MOVWF A
#endasm
   //'a' is now 14...

  while (TRUE) ;
}

It will automatically bank switch to select the variable if needed.
However it is now almost totally unnecessary to use assembler in CCS. Just about everything that can be done in assembler can be done directly from the language without using this.

What do you want to do?.

Best Wishs
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