Re: [cc65] Memory impact of Atari library compile time defines

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-11-26 18:18:29
On Thu, Nov 26, 2009 at 05:56:11PM +0100, Oliver Schmidt wrote:
> How does one make sure that the second one doesn't get linked even if
> -u <symbol> isn't given? I thought that it is generally a bad idea to
> have symbols defined twice inside a library - and that we "invented"
> the 'extra' stuff for that reason...

Both will be linked in, but the default one is really small. No symbols are
used twice, instead a vector will be changed by a constructor defined in the
second module. This is a few bytes overhead, but since we're talking about
0.5KB for the uppercasing code, having another 20 bytes won't kill anybody.

------------------------------- default module -----------------------------
.export ucase, ucase_jmpvec
.code
ucase:  jmp     (jmpvec)

ucase_dummy:
        rts

.data
ucase_jmpvec:
        .addr   ucase_dummy
----------------------------------------------------------------------------

----------------------------- uppercasing module ---------------------------
        .export         __ATARI_UPCASE_FILENAME__ = 1
        .import         jmpvec
        .constructor    init_ucase

.code
init_ucase:
        lda     #<ucase_doit
        sta     ucase_jmpvec
        lda     #>ucase_doit
        sta     ucase_jmpvec+1
        rts

ucase_doit:
        ; uppercasing code here
        rts

----------------------------------------------------------------------------

When linked with "-u __ATARI_UPCASE_FILENAME__", the second module will get
linked in, and the constructor will overwrite the jump vector. The total
overhead is 19 bytes (including the two bytes in the constructor table).

I have also another idea, which is cheaper, but requires changes to the
linker. I must sleep over it a night or two ...

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 Thu Nov 26 18:18:40 2009

This archive was generated by hypermail 2.1.8 : 2009-11-26 18:18:42 CET