Re: [cc65] Unable to include binaries at a particular address

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-11-17 00:17:50


Hi!

On Sun, Nov 16, 2003 at 11:20:56PM +0100, Game 64 - Benjamin Bahnsen wrote:
> I know that this topic has been discussed before, but i didn't find a
> solution to my problem in previous threads.

If you haven't done this, you may want to read the FAQ topic covering this:

        http://www.cc65.org/faq.php#ORG

>  MEMORY {
>             .
>             .
>             sound: start = $5000, size = $1000, define = yes, file = %O;
>         }

Please note that it is your job to make sure the resulting data is loaded to
$5000. Anything the linker will do for you is to relocate the data in the
segment named "SOUND" to the address $5000 and write it to the given file. For
example, if you just have this segment in your config file, and then load the
resulting binary to $1000, it won't work. While the linker can prepare the
data so it is able to run at the given address, it cannot load it to that
address. The standard setup for the C64 is to load the generated program at
$801 (the BASIC start). The linker is used to relocate the data for this
address, and the startup code will take all necessary steps to initialize all
necessary stuff so the program can run. If you want something special (like
loading something to $5000), you will have to do that yourself.
                                                              
An older mail from the mailing list may be helpful:

        http://www.cc65.org/mailarchive/2003-10/3675.html

It talks about the memory layout that is used for most platforms (including
the C64).

> The resulting file after compiling with
> ld65 main.o sound.o c64.lib -C memory.cfg
> does not contain any data at $5000. The strange thing is, that the main
> program now starts at $5ADE. My sound.bin-file has a length of $ADE...
> I have no explanation for that. Can anyone help me?

Assuming that you've added the SOUND segment as the first segment in the
SEGMENTS section: The linker will relocate the data to $5000 and write it as
first segment to the file you specified. Since you didn't take any measures to
make sure the data is actually loaded to $5000 later, there's a problem:-)

Is there really a reason to load the data to $5000? If so, you will probably
have to use your own linker and startup file, or write the data to a separate
file that is loaded from within your program to the this address. While this
is possible, I wouldn't suggest this for a first time project, especially if
you don't really need it.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-11-17 00:18:10 CET