If you are using Code Warrior, then you may want to take a look through
this tread:-
http://news.palmos.com/read/messages?id=203257#203257
The CW runtime library can be tweaked to allow you to set up the jump
tables for you. This makes building large apps much simpler.
Ben Combee wrote:
> Yes. Put a "lookup function" as the very first function in a segment
> using the link order mechanism in CodeWarrior. Call that function by
> locking the segment's resource and using the start of the segment as a
> function pointer, perhaps with a little offset to get past any data
> stored at the start of the segment. The function addresses will be
> PC-resolved in the lookup function since they're in the same segment.
>
Let's say function A is in segment 1 and function B is in segment 2 . If
I need to call function B of segment 2 in different launch situations,
what I understand is ..
1. Define a function router at start of segment 1
2. Load segment 2 resource, lock it
3. Add offset of function 2 to start of segment 2 and know the address
4. Function A calls function router which will push the address of
function 2 into the stack and launch?? Bit confused here.
No, the router should be in segment 2. Calls within a segment are
done using a PC-offset (save with no globals), but calls from one
segment to another are done through the jump table (requires globals).
You're getting around the jump table by locking segment 2 and using
the address of the locked resource to find the address of your
SEG2_ROUTER function. The router would return an address, then you'd
call the original function through the function pointer you were
returned, like
typedef void foo_fn(void);
typedef foo_fn *router_fn(void);
router_fn router = lock_segment_2() + offset;
foo_fn foo = router();
foo();
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/