Re: [cc65] drive code with shared segments

From: Greg King <gngking1erols.com>
Date: 2005-04-21 01:25:28
From: MagerValp; on Date: April 19, 2005, at 08:20 AM -0400
>
>>>>>> "UvB" == Ullrich von Bassewitz <uz@musoftware.de> writes:
>
> UvB> What I understand is that you have 1 shared piece of code,
> UvB> plus 4 pieces of unique code.  Is there any other code?
>
> Well, the code for the host side, that does drive-model detection,
> and uploads the shared code, plus model-specific code.
>
> UvB> What do you want the linker to output?  4 files?  1 file?
>
> One file.  The drive's memory map looks like this:
>
>   $0400 .. $04ff, RAM buffer
>   $0500 .. X, shared code
>   X + 1 .. Y, model-specific code
>
> The main program determins which drive is connected, and then uploads
> the shared code, followed by the model-specific code.  The problem is
> that the size of the shared code is not known (it's under develop-
> ment), so I can't just make two different segments in the linker.  Or,
> rather, I could, but it requires manual tweaking.  Currently, I'm
> working with a SHARED segment at $0500..$05ff, and a MODEL segment at
> $0600..$06ff; but, if either segment grows, I'll need to tweak the
> config., again.  I was hoping that ld65 would do that for me. :)
> But, I guess that that would require expression support in ld65.

Use non-relocatable code.  Make the assembler, not the linker, do the work.
In the example below, ".org" places the driver code in overlays, while
".reloc" puts that code in a (separated) sequence, in the host's memory.

; drive.s
;
; This file overlays drive-specific code in drive-space,
; without overlaying that code in host-space.

        .export         D_buffer, D_common, D_1541, D_1571, D_1581
        .export         D_common_end, D_1541_end, D_1571_end, D_1581_end

D_buffer := $0400
        ;.reloc

D_common:
        .org    $0500
D_shared:
        jmp     sub1
        jmp     sub2
        ...
        ; common drive-code
sub1:   lda     D_buffer
        ...
        rts
D_shared_end:
sub2:   jmp     $ffff
sub3:   jmp     $ffff
        ...
        .reloc
D_common_end:

D_1541:
        .org    D_shared_end
        jmp     D_1541_sub2
        jmp     D_1541_sub3
        ...
D_1541_sub2:
        ; 1541-specific code
        sta     D_buffer
        rts
D_1541_sub3:
        ...
        .reloc
D_1541_end:

D_1571:
        .org    D_shared_end
        jmp     D_1571_sub2
        jmp     D_1571_sub3
        ...
D_1571_sub2:
        ; 1571-specific code
D_1571_sub3:
        ...
        .reloc
D_1571_end:

D_1581:
        .org    D_shared_end
        jmp     D_1581_sub2
        jmp     D_1581_sub3
        ...
D_1581_sub2:
        ; 1581-specific code
D_1581_sub3:
        ...
        .reloc
D_1581_end:
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Apr 21 03:13:15 2005

This archive was generated by hypermail 2.1.8 : 2005-04-21 03:13:17 CEST