shithub: rgbds

ref: e895832b2b89cf341ef84ee43e70aaa41f002fed
dir: /doc/LINK.HTM/

View raw version
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<TITLE>xLink</TITLE>
</HEAD>

<BODY BGCOLOR="#692764" TEXT="#F5A0D8" LINK="#8AAEE6" VLINK="#2B9DA4" ALINK="#95F0DA">
<HR SIZE="3">
<CENTER>
<TABLE CELLPADDING=25 BORDER=0 BGCOLOR="#000000">
<TR>
	<TD><FONT COLOR="#FFFFFF"><H2>xLink Documentation</H2></FONT></TD>
</TR>
</TABLE>
<HR><H2>Table of Contents<BR></CENTER></H2>
<UL>
<LI><A HREF="#History"> History</A>
<LI><A HREF="#Usage"> Usage</A>
<LI><A HREF="#Linkfile"> The Linkfile</A>
<LI><A HREF="#OperationTG"> Operation for Gameboy</A>
<LI><A HREF="#smallmode"> Operation for Gameboy small mode</A>
<LI><A HREF="#psion2"> Operation for Psion2 relocatable modules</A>
</UL>
<H3><BR>
<HR SIZE="3">
<BR>
<A NAME="History">History</A></H3>
<TABLE BORDER=1>
	<CAPTION><I>The history of xLink</I></CAPTION>
<TR>
	<TD ALIGN="Center"><B><I>Version</I></B></TD>
	<TD ALIGN="Center"><B><I>Dated</I></B></TD>
	<TD><B><I>Release notes</I></B></TD>
</TR>
<TR>
	<TD ALIGN="Center">1.0</TD>
	<TD ALIGN="Center">1 Oct. 96</TD>
	<TD>First release (RGBDS)</TD>
</TR>
<TR>
	<TD ALIGN="Center">1.01</TD>
	<TD ALIGN="Center">3 Dec. 96</TD>
	<TD>BANK() didn't work. Fixed.<BR>
		Sections were quite often output in the wrong order. Fixed.</TD>
</TR>
<TR>
	<TD ALIGN="Center">1.02</TD>
	<TD ALIGN="Center">12 Feb. 97</TD>
	<TD><A HREF="#Usage">-s switch and mapfile option</A> added</TD>
</TR>
<TR>
	<TD ALIGN="Center">1.03</TD>
	<TD ALIGN="Center">23 Mar. 97</TD>
	<TD><A HREF="#Usage">Mapfile</A> now shows BSS, VRAM and HRAM areas<BR>
	There was a bug regarding <A HREF="#Operation">fixed HOME sections.</A> <BR></TD>
</TR>
<TR>
	<TD ALIGN="Center">1.04</TD>
	<TD ALIGN="Center">03 July 1997</TD>
	<TD>First ASMotor release. Supports big-endian CPUs as well. <A HREF="#Usage">Usage</A> changed to allow for different 	output fileformats</TD>
</TR>
<TR>
	<TD ALIGN="Center">1.05</TD>
	<TD ALIGN="Center">20 July 1997</TD>
	<TD>We can now do range checking on intermediate results in an expression. This is necessary to support
different types of CPUs.<BR>
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.<BR>
</TD>
<TR>
	<TD ALIGN="Center">1.06</TD>
	<TD ALIGN="Center">21 September 1997</TD>
	<TD>Smart linking and library support added<BR>
	Program renamed to xLink<BR>
</TD>
</TABLE>
<BR>
<HR>
<BR>
<H3><A NAME="Usage">Usage</A></H3>
<PRE>    xlink [options] linkfile</PRE>
<P>Options are preceded by a dash (-) and go as follows:<BR>
<BR>
<PRE>    h         : Short help text
    m<B>mapfile</B>  : Write a mapfile</A>
    t         : Output target:
      tg      : Gameboy <A HREF="#OperationTG">ROM image</A> (default)
      ts      : Gameboy <A HREF="#smallmode">Small mode (32kB)</A> ROM image
      tp      : <A HREF="#psion2">Psion2</A> relocatable module
    z<B>HX</B>       : Set the byte value (hex format) used for uninitialised data (default is ? for random)
</PRE>
<HR>
<H3>
<BR>
<A NAME="Linkfile">The Linkfile</A></H3>
<P>A linkfile is used to tell <B>xLink</B> which objects to include and what the outputname should be. It is in plain ASCII-format.<BR>
<BR>
<PRE>    # Linkfile for foobar.gb
      
    [Objects]
    foo.obj
    bar.obj
      
    [Libraries]
    mylib.lib

    [Output]
    foobar.gb</PRE>
<P>A line starting with # is ignored.<BR>
<P>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.
<BR><HR><H3><BR>
<A NAME="OperationTG">Operation for Gameboy (-tg)</A></H3>
<P><A HREF="asm.htm#sections">Sections</A> created with <B>HOME</B> 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.
<B>CODE/DATA</B> sections are placed in <I>any bank other than #0</I>. This means you have absolutely <U>no</U> control over which sections goes where. This insures minimal slack (unused bytes) at the end of each bank in the image.
<P>Currently  the linker doesn't calculate the GB checksums.
You must use <A HREF="fix.htm">RGBFix</A> to do this.<BR><BR>

<BR><HR><H3><BR>
<A NAME="smallmode">Operation for Gameboy small mode (-ts)</A></H3>
<P>Small mode forces all <B>DATA/CODE</B> sections to be of type <B>HOME</B> and increases the
<B>HOME</B> section size from 16kB to 32kB. This also means that <B>CODE/DATA/HOME</B> sections are written to the final image in the order you have specified in the linkfile.
<P>Currently  the linker doesn't calculate the GB checksums.
You must use <A HREF="fix.htm">RGBFix</A> to do this.<BR><BR>

<BR><HR><H3><BR>
<A NAME="psion2">Operation for Psion2 relocatable modules (-tp)</A></H3>
<P>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 <B>HOME, DATA and BSS</B>. 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.<BR>
The file looks like this (all values are big endian):
<PRE>
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
</PRE>

<HR>
<FONT SIZE="-1"><I><P ALIGN=RIGHT>Last updated 08 October 1997 by <A HREF="mailto:[email protected]">Carsten Sorensen</A></P></I></FONT>
</BODY>
</HTML>