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

Pointer to function using #ASM

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



Joined: 02 Mar 2004
Posts: 1

View user's profile Send private message

Pointer to function using #ASM
PostPosted: Tue Mar 02, 2004 5:42 am     Reply with quote

I read is not possible in CCS to obtain a pointer to a function.
So I thought I could obtain it by an assembly sobroutine and using the symbol table... i.e.:

void
my_function(){
}

main() {

....
#ASM
MOVFF my_function, FSR0L
//or something similar
#ASM
...
}

I tried this but compiler reports the following error: "Expression must evaluate to a constant"... I can't understand why! I looked at the symbol table and to the symbol my_function is rightly assigned the program memory address of th function!
Could anyone help me, please?
Thanks!! Sad
mpfj



Joined: 09 Sep 2003
Posts: 95
Location: UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Mar 02, 2004 6:03 am     Reply with quote

You're almost there ... !!

What you can do is use the #org directive to force the function to a known location .. e.g.

Code:
#org 0x8000, 0x81ff
void function(void) {
}

You can then use the following to call the function ...

Code:
#asm
   call 0x8000
#endasm

The downside is that you can't pass parameters, although you can just make them globals and the you're away !!
Ttelmah
Guest







Re: Pointer to function using #ASM
PostPosted: Tue Mar 02, 2004 11:08 am     Reply with quote

Beppe wrote:
I read is not possible in CCS to obtain a pointer to a function.
So I thought I could obtain it by an assembly sobroutine and using the symbol table... i.e.:

void
my_function(){
}

main() {

....
#ASM
MOVFF my_function, FSR0L
//or something similar
#ASM
...
}

I tried this but compiler reports the following error: "Expression must evaluate to a constant"... I can't understand why! I looked at the symbol table and to the symbol my_function is rightly assigned the program memory address of th function!
Could anyone help me, please?
Thanks!! Sad

Actually pointers to functions, _are_ now supported (though with significant 'caveats').

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