"Max Bian" <[EMAIL PROTECTED]> wrote in message news:71580@palm-dev-forum... > > Thanks for the information. > > I understand this now. From your answer, it seems that at run time 'func' will > have the absolute address value of function "MyFunc" when "func = MyFunc" is > execuated.
Right. > I looked at the disassembled code0001 resource, then that part come to this: > > 0000678a 4e560000 L858 LINK A6,#0 > 0000678e 2f0a MOVE.L A2,-(A7) > 00006790 42a7 CLR.L -(A7) > ...... > 000067bc 4e75 RTS > ...... > > 00006918 41fafe70 LEA L858,A0 > 0000691c 2808 MOVE.L A0,D4 > ...... > > where L858 is the lable for "MyFunc". I guess L858 is the relative address from > the head of the segment. So I am expecting the value stored in memory location > specified by D4 is actually PC+L858, is it right? D4 will have the actual address of MyFunc here. L858 is a "dynamic" label generated by the disassembler. The real value is PC + 0xFE70, and it gets stored into A0. The value here is inserted by the linker. > When the MyFunc is called via func, the code is like this: > > 000069da 2044 MOVEA.L D4,A0 > 000069dc 4e90 JSR (A0) > ...... > A0 should have the absolute address for JSR, right? Yes. > If that is the case, how would I declare a variable to store the relative > offset of the function "MyFunc"? Relative to what? > "int (*func)();" will get the absolute address value. Would it be different if > I have "void *funcP;" and use "funcP = MyFunc;"? No. There is no difference between a normal pointer and a C function pointer. C++ method pointers are more complex, since they store information about how the call is made. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
