[A83] Re: CRT
[Prev][Next][Index][Thread]
[A83] Re: CRT
>A good idea for compatibility: have the shared libs in a program. On the
>83, this is kept in memory. On the 83+, this can be in RAM or archive.
>Shared and static libraries aren't too hard to maintain together.
That was the plan, have the shared library be it's own program that a C
program would find and then use.
>BTW, what would be the best way to integrate shared libraries? I doubt
>aslink has support. A static library wrapper maybe?
Here is how I was planning on doing it: The library would be a program in
memory. The first x*2 bytes of the program would be a table of entry points
(where x is the number of functions in the library). The entry points would
be a 16-bit adress that is an offset into the library that the function is
located at. For example, imagine there are three functions in the shared
library, printf(), getchar(), and putchar(). The first 6 bytes of the
library could look like this:
$0600AB10CD30
Which would be translated as:
+-----------+---------+
| Function | Address |
+-----------+---------+
| printf() | $0006 |
| getchar() | $10AB |
| putchar() | $30CD |
+-----------+---------+
Whereas all the adresses are offsets *into* the library. So printf(), being
the first function in the library, would be at bye $0006, the first byte
past the table. Hopefully the functions can be programmed in such a way
that all the jumps are relative, so that the library functions can be run
from anywhere in RAM.
To call a function, the code could look something like this (this is off the
top of my head, don't yell at me if it sucks):
;a call to ChkFindSym to point HL to the library
ld BC, 02 ; byte 2 of the table = getchar()
add HL, BC
jp [HL] ;jump into the library (don't call, to save a ret)
That, at least, is the idea I'm entertaining at the momment.
In order to keep combatiblity, it is imperative that the order of the
functions remains the same in the entry point table. It's ok if the
functions themselves are out of order, as long as the table remains intact.
This way even if better versions of the functoins are released, old programs
can still find and jump into the function they need without a problem.
Stupid like a fox!
Look ma, I'm an artist: http://aaronstj.deviantart.com
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus