[A83] run-time libraries?


[Prev][Next][Index][Thread]

[A83] run-time libraries?




I've been toying around with a few ideas for this compression program
I'm writing - in particular, making it available as a run-time library.

Obviously, using a run-time library is much more efficient that static
libs since only one copy of the code needs to be kept on the calc. But
there is the problem of how the calling program would interface with the
library. Here are some of my thoughts... please feel free to give your
comments.

The entry points to the library routines would be stored at the end of
the program, so a program wishing to use the library would have to look
it up in the symbol table and calculate the address of the last byte of
the program, and then load the appropriate routine address.

As for actually executing code, I have two ideas. The first is the
straight-forward approach: The appropriate code is copied to a safe-RAM
area such as AppBackupScreen and executed there. The advantage is in
ease of implementation. I can just assembly the library code with an
origin of AppBackupScreen. The disadvantage is, obviously, the calling
program had better not be storing and data there (which I think might be
a problem for a compression library).

The second approach is to have the caller execute the code wherever it
is located. This is OK if the code only uses relative addressing (ie: no
JPs, CALLs, or LD (N) stuff). My code needs CALLs, though. I got around
this by storing 16 bytes of code right at the end of the stack memory
(norty me) and doing some other funky stuff to allow my program to
effectively make relative calls. This is slower and costs a few more
bytes, but it works. The big advantage is that no extra RAM is required
and accessing the library routines is a piece of cake.

Anyway... looking forward to your comments. I really can't decide on
this one. The first one is the most logical... but the second is so
extremely convoluted I don't think I can resist it ;)