• cc65 / apple2 HGR2 linker configuration

    From Colin Leroy-Mira@21:1/5 to All on Fri Jul 28 21:53:44 2023
    Hi there,

    I'm hoping Oliver will see this message :) I've worked a bit on a
    linker configuration allowing my program to live from $803 to $3FFF and
    use the HGR2 page. The program worked well using HGR1, but its code
    can't live entirely between $803 and $1FFF, so it's much bigger than
    needed on disk, having 8kB of zeroes on HGR1.

    I've managed to make this linker config: https://github.com/colinleroy/a2tools/blob/master/config/apple2enh-hgr2.cfg

    It seems to work good and safe. I checked that the linker errors out if
    I put too much code and it crosses the $4000 boundary; I've also
    checked that malloc() does the right thing, not touching HGR
    page 2 (it starts allocating at $6000 + BSS size + stack size).

    I'd love a second opinion though :)

    Thanks!
    --
    Colin
    https://www.colino.net/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oliver Schmidt@21:1/5 to All on Sat Jul 29 15:22:28 2023
    Hi Colin,

    I'm hoping Oliver will see this message :)


    Here I am...

    I've managed to make this linker config: >https://github.com/colinleroy/a2tools/blob/master/config/apple2enh-hgr2.cfg

    The config looks absolutely sane to me.

    It seems to work good and safe. I checked that the linker errors out if
    I put too much code and it crosses the $4000 boundary; I've also
    checked that malloc() does the right thing, not touching HGR
    page 2 (it starts allocating at $6000 + BSS size + stack size).

    The heap starts at $6000 + BSS size. The stack starts at HIMEM and
    grows downwards towards the heap.


    I'd love a second opinion though :)


    I don't see a problem. However, I'm wondering why you don't go the
    from my perspective simpler way to load your program at $4000 and use
    $803 to $2000 as additional heap.

    That alternative doesn't require an own custom linker config. Just use
    the '--start-addr $4000' cmdline parameter and add the heap as
    described in https://cc65.github.io/doc/apple2.html#ss5.2

    The HGR sample programs coming with cc65 doit this very way: https://github.com/cc65/cc65/blob/master/samples/Makefile#L108-L112

    Regards,
    Oliver

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Colin Leroy-Mira@21:1/5 to All on Sun Jul 30 15:13:16 2023
    Hi,

    The heap starts at $6000 + BSS size. The stack starts at HIMEM and
    grows downwards towards the heap.

    Uh, right :) Had a little brainfart there.

    I'd love a second opinion though :)


    I don't see a problem. However, I'm wondering why you don't go the
    from my perspective simpler way to load your program at $4000 and use
    $803 to $2000 as additional heap.

    That's mostly because I didn't think of it! Thanks for the input.

    --
    Colin
    https://www.colino.net/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Colin Leroy-Mira@21:1/5 to All on Sun Jul 30 16:24:30 2023
    Hi,

    I don't see a problem. However, I'm wondering why you don't go the
    from my perspective simpler way to load your program at $4000 and use
    $803 to $2000 as additional heap.

    That's mostly because I didn't think of it! Thanks for the input.

    Not only is it simpler, it's also cooler because I can still use VIDEOMODE_80COL and/or MIXSET.

    Thanks!
    --
    Colin
    https://www.colino.net/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oliver Schmidt@21:1/5 to All on Mon Jul 31 17:59:57 2023
    Hi Colin,

    [...]
    Thanks!

    You're welcome! Thanks for the kind feedback :-)

    Regards,
    Oliver

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)