xLink Documentation


Table of Contents




History

The history of xLink
Version Dated Release notes
1.0 1 Oct. 96 First release (RGBDS)
1.01 3 Dec. 96 BANK() didn't work. Fixed.
Sections were quite often output in the wrong order. Fixed.
1.02 12 Feb. 97 -s switch and mapfile option added
1.03 23 Mar. 97 Mapfile now shows BSS, VRAM and HRAM areas
There was a bug regarding fixed HOME sections.
1.04 03 July 1997 First ASMotor release. Supports big-endian CPUs as well. Usage changed to allow for different output fileformats
1.05 20 July 1997 We can now do range checking on intermediate results in an expression. This is necessary to support different types of CPUs.
RGBLink DIDN'T know about the special PC symbol "@" so if you used it more than once per sourcefile in an expression the linker had to resolve, things would go horribly wrong.
1.06 21 September 1997 Smart linking and library support added
Program renamed to xLink



Usage

    xlink [options] linkfile

Options are preceded by a dash (-) and go as follows:

    h         : Short help text

    mmapfile  : Write a mapfile

    t         : Output target:

      tg      : Gameboy ROM image (default)

      ts      : Gameboy Small mode (32kB) ROM image

      tp      : Psion2 relocatable module

    zHX       : Set the byte value (hex format) used for uninitialised data (default is ? for random)



The Linkfile

A linkfile is used to tell xLink which objects to include and what the outputname should be. It is in plain ASCII-format.

    # Linkfile for foobar.gb

      

    [Objects]

    foo.obj

    bar.obj

      

    [Libraries]

    mylib.lib




    [Output]

    foobar.gb

A line starting with # is ignored.

If you use libraries they will only be included if one of the objects actually reference them. This works on a SECTION level and not on a module level. This means that when you write libraries you can put each subroutine in its own SECTION so only the relevant bits are included.



Operation for Gameboy (-tg)

Sections created with HOME in the assembler are placed in the GB bank #0 (the fixed bank $0000-$3FFF) in the order they are loaded from the objectfiles specified in the linkfile. So you want the first file in the linkfile to contain your header. CODE/DATA sections are placed in any bank other than #0. This means you have absolutely no control over which sections goes where. This insures minimal slack (unused bytes) at the end of each bank in the image.

Currently the linker doesn't calculate the GB checksums. You must use RGBFix to do this.




Operation for Gameboy small mode (-ts)

Small mode forces all DATA/CODE sections to be of type HOME and increases the HOME section size from 16kB to 32kB. This also means that CODE/DATA/HOME sections are written to the final image in the order you have specified in the linkfile.

Currently the linker doesn't calculate the GB checksums. You must use RGBFix to do this.




Operation for Psion2 relocatable modules (-tp)

This is a fileformat for the Psion2 that allows you to load your code into where ever there's any free space. The only sections types allowed are HOME, DATA and BSS. All CODE and DATA sections are written to the output file in the order specified in the linkfile. The BSS are actually then expanded to DATA sections filled with zeroes and appended. This might change later.
The file looks like this (all values are big endian):


LONG    NumberOfDataBytes

REPT    NumberOfDataBytes

    DB  x

ENDR

LONG    NumberOfPatches

REPT    NumberOfPatches

    LONG    x    ; A value to add to the word at address x in the code

ENDR


Last updated 08 October 1997 by Carsten Sorensen