Re: [cc65] statics in zero page

Date view Thread view Subject view

From: Greg King (gngking_at_erols.com)
Date: 2002-05-22 18:48:43


-----Original Message-----
From: Ullrich von Bassewitz <uz_at_musoftware.de>
Date: Tuesday, May 21, 2002 11:14 AM
>
> On Tue, May 21, 2002 at 04:49:19PM +0200, Christian Krüger wrote:
> > In my opinion the option is like "register" or "inline" --
> > just a recommendation for the compiler to do things in the user's mind.
>
> Yeah, but the compiler does not know how much zero-page space is available --
> this is only known to the linker.  And, the linker, on the other side,
> is not able to change zero-page addresses back to absolute ones.
>
> > Of course. I also think that things get a little bit more complicated for
> > the linker (what ZPs are necessary; which are only nice to have),
>
> How do you think the linker should handle the case "48 bytes of zero-page
> space were allocated, but only 35 bytes are available"?  I would say,
> any other solution than just refusing to link successfully is much more
> than just "a little more complicated.":-)
>
> > But, from another point-of-view:  Why should I abstain
> > from a little speed-gain if there is zero-page space left?

There are two advantages in the zero-page:  speed AND size.
(Size is why I use __fastcall__ on my C functions;
it means "small-call," also.)

> A possible solution is to declare and export the variables
> from an assembler file, and import them as zero-page variables
> into the C modules by using the "#pragma zpsym" statement.

That solution will be easier to do, after ld65's configure-scripts are
"expanded."  Instead of providing the minimum zero-page space that is needed
by the compiler, they should "allocate" the maximum contiguous space
that is not used outside of the program.  For example, "c64.cfg" should say,

"ZP: start = $02, size = $8E, type = rw, define = yes;"

(that is all of BASIC's space).  Then, files can .reserve (additional) .zeropage
variables, in the same portable way that they define .bss variables (ld65 will
set their addresses).  (The start-up file must use __ZP_START__ and __ZP_LAST__
when swapping the zero-page.)

I agree that "it won't fit" is the only reasonable reaction when ld65 runs out
of room -- in any memory-area.  The linker cannot know our goals;
so, it would not know which variables
are merely nice-to-have-sitting-down-there-if-there-were-space.  It is our job
to adjust the code, in order "to shoehorn" it into the targets.

----------------------------------------------------------------------
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 : 2002-05-22 18:49:28 CEST