[A83] Re: Applications...


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

[A83] Re: Applications...




Yep.  If you'd like to see an example of a "real", yet very very simple
linker, then take a look at my Game Boy linker:

http://david.acz.org/prog/gblink.zip

It works with my Game Boy assembler to link object files into a single ROM
image.  Since the Game Boy is similar z80, it doesn't try to handle
relocating everything, as true relocatable code would be a nightmare.  It
uses a ROM bank system similar to the calc.  Since it would be annoying to
calculate where addresses are across pages, it lets modules (which must fit
on a page) have external addresses.  These external addresses get filled in
by the linker at link time.  It only support linear offsets, as anything
else would be extremely complicated, and not worthwhile, since it wouldn't
make much sense anyway.

It has the special feature of allowing you to jump to, call and load
addresses that are on different pages, similar to the bcall feature on the
83+.  This is done using RST's (since you have full control of the entire
ROM).  The link corrects the addresses at link time, and warns if a load is
not possible, due to both the source code and the target address both being
on the relocatable page.

(In case anyone ever looked at gbasm or gblink before and was annoyed by it
having problems, I just fixed that by correctly replacing them all with
spaces, using JOE's excellent macro repeat feature).

> *Real* linkers take at least one file, read out the relocation-data it
> contains and write out a binary-file or a direct executable. When the
> linker finds references to routines or data that are not in the file it
> will search in the other files you gave to find the routine/data. This
will
> go on untill a link are resolved.





References: