Reply by Franco Bucafusco●October 19, 20092009-10-19
Yoy may define a pointer to function type. And then, define all your
"pointed" functions using a macro.
When you need the address of the funtion is just like a variable.
funtion_pointer_type *var;
var= &function_name;
On Thu, Oct 8, 2009 at 5:13 PM, crandel_z wrote:
> Hi, I new with MSP430. I want to get the address of
one of my program
> function. In assembler I can do:
>
> MOV #MyFunctionName,R4
>
> in c++ ?
>
> thx
>
> Crandel
>
Reply by Anders Lindgren●October 14, 20092009-10-14
crandel_z wrote:
> Hi, I new with MSP430. I want to get the address of
one of my program
> function. In assembler I can do:
>
> MOV #MyFunctionName,R4
>
> in c++ ?
Hi!
Basically, there is no difference in C and C++, well, not for normal
functions that is.
Basically, writing the name of the function "foo" yields a pointer to
that function. What is tricky is getting the syntax right for the type
of the pointer. The best way to do this, in my opinion, is to define a
typedef representing a function type, then using this as the base for
the pointer type.
In the example below, "func_t" is a function type. "func_t *" is a
function pointer type. The program simply returns the address of "my_func".
-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.
Reply by crandel_z●October 9, 20092009-10-09
Thank you, was lack me to make the cast
WORD ptMF = (WORD)&MyFunctionName;
Crandel
--- In m..., Dan Bloomquist wrote: >
> crandel_z wrote:
> > Hi, I new with MSP430. I want to get the address of one of my program
function. In assembler I can do:
> >
> > MOV #MyFunctionName,R4
> >
> > in c++ ?
> >
>
> Without knowing your compiler and compliance...
> Best, Dan.
>
Reply by Dan Bloomquist●October 9, 20092009-10-09
crandel_z wrote: > Hi, I new with MSP430. I want to get the address of
one of my program function. In assembler I can do:
>
> MOV #MyFunctionName,R4
>
> in c++ ?
>
Without knowing your compiler and compliance...
Best, Dan.
Reply by crandel_z●October 9, 20092009-10-09
Hi, I new with MSP430. I want to get the address of one of my program function.
In assembler I can do: