Re: [cc65] diskcmd.s error

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-07-05 18:20:43
Hi!

On Sun, Jul 05, 2009 at 02:28:30PM +0200, silverdr@wfmh.org.pl wrote:
> OK. Set of sources sent to the personal mailbox.

Thanks, I've had a look at it. The problem is caused by tricky programming
together with ld65 being too strict. Here is the relevant line again:

        jsr     isdisk          ; Disk unit?
        bcs     success

; Is this channel already open?

        ldy     opentab-FIRST_DRIVE,x
        bne     isopen

First, X is checked to contain the address of a disk on the bus, so X is at
least 8 (= first disk drive). Since the table "opentab" contains just disks,
an offset of 8 (= FIRST_DRIVE) is subtracted, so when X contains 8, the first
element of the table is addressed. The address calculation (get address of
opentab and subtract 8) is stored in the object file.

The table "opentab" is in the BSS segment. In your program, there is nothing
else in the BSS segment, so the table is at the start of the segment. So the
expression resolves to "get the address of the BSS segment and subtract 8",
which is an address that lies *outside* of the segment. And this is what the
linker doesn't like ...

The error will go away by itself if you start adding uninitialized variables
or use more library modules. As a quick workaround, use

        static char unused[8];

at the top of your C module until your program grows larger.

Thanks for the report. This was an interesting one :-)

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jul 5 18:22:58 2009

This archive was generated by hypermail 2.1.8 : 2009-07-05 18:23:00 CEST