Re: [cc65] Directory/Drive functions

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-06-13 15:15:48


On Thu, Jun 12, 2003 at 09:19:23PM -0400, Greg King wrote:
> I go further than that.  I changed my copy of the libraries so that they
> save-and-restore some useful things that might be trashed.  I mentioned it
> to Uz because I thought that other people might appreciate that convenience
> as much as I do [if I am wrong, my ego will survive -- just barely ;-)].

This is ok with me. I admit that it can make sense for a program to save and
restore more than the standard stuff. I just don't think that this should be
the default, because most people won't sacrifice the memory needed to do these
things if it is not really necessary.

BTW: You do probably know, but most others dont't; there's an easy way to
save and restore whatever you like without messing with the library sources.
Use an assembler module like this one:

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

        .export         _usemystuff
        .constructor    initmystuff, 32
        .destructor     donemystuff, 1

.proc   _usemystuff
        rts
.endproc

.proc   initmystuff             ; Save whatever you want here
        ...
        rts
.endproc

.proc   donemystuff             ; Restore things
        ...
        rts
.endproc

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

Declare the usemystuff function as external function:

        void usemystuff (void);

and call it somewhere from your program. The exact location doesn't matter,
since the call doesn't do anything but force the module to be linked (maybe
it's not even necessary if the module is not in a library - I will have to
check that). After doing so, initmystuff and donemystuff are called
automagically from the cc65 startup and exit code. Because of the priorities,
the functions are called before resp. after anything else. Warning: Just save
and restore variables here. Since the C stuff is not initialized, you cannot
rely on anything provided by the C runtime library.

Using such a module is an easy way to provide any special intializations your
program needs before main() is called.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
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 : 2003-06-13 15:15:57 CEST