"Wayne" <[EMAIL PROTECTED]> wrote in message
news:64245@palm-dev-forum...
>
> It's my understanding that when a program is on the palm it is
executed from
> where it is at in memory, but where it is at is determined by the OS
when it
> was loaded (can I use that word?) onto the palm, so it really doesn't
know
> where it is at.  Correct?
>
> The OS doesn't do any relocating the program once its in memory,
therefore
> the program remains the same from when it was assembled and converted
to
> .prc format on the development computer to when it is loaded into the
palm's
> memory.  Correct?
>
> So my questions are:
> How do calls and jumps work?  Is the code for the subroutine called
relative
> to where the PC is at currently?  It seems it would have to be.

Most calls and jumps are made using PC-relative instructions.  While the
code doesn't know exactly where its jumping, it knows how far from the
current instruction the code its referencing is.

A jump to another segment is made through a segment jump table.  This is
a table setup in the global variable space that gets fixed at program
start time with the addresses of any functions called from a different
segment.  To make a cross segment jump, the code jumps into the table,
which has another jump instruction that forwards to the destination.

Global data is referenced as an offset from the A5 register.  This
offset is set at build time by the linker.  A5 is setup by the OS to
point into the middle of the data region, which is allocated on the heap
and setup at program start time.




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to